当前位置: 代码网 > it编程>前端脚本>Python > 关于TensorFlow、Keras、Python版本匹配一览表

关于TensorFlow、Keras、Python版本匹配一览表

2024年05月18日 Python 我要评论
tensorflow、keras、python 版本匹配一览表兴冲冲装完软件,发现运行不了,查了下资料,发现是tensorflow、keras、python 版本匹配问题。这里提供一个版本匹配清单,需

tensorflow、keras、python 版本匹配一览表

兴冲冲装完软件,发现运行不了,查了下资料,发现是tensorflow、keras、python 版本匹配问题。

这里提供一个版本匹配清单,需要严格按此标准安装。

版本匹配清单

frameworkenv namedescription
tensorflow 2.2tensorflow-2.2tensorflow 2.2.0 + keras 2.3.1 on python 3.7.
tensorflow 2.1tensorflow-2.1tensorflow 2.1.0 + keras 2.3.1 on python 3.6.
tensorflow 2.0tensorflow-2.0tensorflow 2.0.0 + keras 2.3.1 on python 3.6.
tensorflow 1.15tensorflow-1.15tensorflow 1.15.0 + keras 2.3.1 on python 3.6.
tensorflow 1.14tensorflow-1.14tensorflow 1.14.0 + keras 2.2.5 on python 3.6.
tensorflow 1.13tensorflow-1.13tensorflow 1.13.0 + keras 2.2.4 on python 3.6.
tensorflow 1.12tensorflow-1.12tensorflow 1.12.0 + keras 2.2.4 on python 3.6.
tensorflow-1.12:py2tensorflow 1.12.0 + keras 2.2.4 on python 2.
tensorflow 1.11tensorflow-1.11tensorflow 1.11.0 + keras 2.2.4 on python 3.6.
tensorflow-1.11:py2tensorflow 1.11.0 + keras 2.2.4 on python 2.
tensorflow 1.10tensorflow-1.10tensorflow 1.10.0 + keras 2.2.0 on python 3.6.
tensorflow-1.10:py2tensorflow 1.10.0 + keras 2.2.0 on python 2.
tensorflow 1.9tensorflow-1.9tensorflow 1.9.0 + keras 2.2.0 on python 3.6.
tensorflow-1.9:py2tensorflow 1.9.0 + keras 2.2.0 on python 2.
tensorflow 1.8tensorflow-1.8tensorflow 1.8.0 + keras 2.1.6 on python 3.6.
tensorflow-1.8:py2tensorflow 1.8.0 + keras 2.1.6 on python 2.
tensorflow 1.7tensorflow-1.7tensorflow 1.7.0 + keras 2.1.6 on python 3.6.
tensorflow-1.7:py2tensorflow 1.7.0 + keras 2.1.6 on python 2.
tensorflow 1.5tensorflow-1.5tensorflow 1.5.0 + keras 2.1.6 on python 3.6.
tensorflow-1.5:py2tensorflow 1.5.0 + keras 2.0.8 on python 2.
tensorflow 1.4tensorflow-1.4tensorflow 1.4.0 + keras 2.0.8 on python 3.6.
tensorflow-1.4:py2tensorflow 1.4.0 + keras 2.0.8 on python 2.
tensorflow 1.3tensorflow-1.3tensorflow 1.3.0 + keras 2.0.6 on python 3.6.
tensorflow-1.3:py2tensorflow 1.3.0 + keras 2.0.6 on python 2.

附上一段测试程序(鸢尾花分类简化版)

这一段代码不需要准备数据文件,可直接验证是否可以训练模型。

#ex7-2.py
#导入库包
import numpy as np
import keras
import matplotlib.pyplot as plt
from keras.models import sequential
from keras.layers import dense
#读入数据
train_x = np.array([[1.4, 0.2],
                        [1.7, 0.4],
                        [1.5, 0.4],
                        [2.3, 0.7],
                        [2.7, 1.1],
                        [2.6, 0.9],
                        [4.6, 1.3],
                        [3.5, 1.0],
                        [3.9, 1.2]])
train_y = np.array([[1, 0, 0],
                        [1, 0, 0],
                        [1, 0, 0],
                        [0, 1, 0],
                        [0, 1, 0],
                        [0, 1, 0],
                        [0, 0, 1],
                        [0, 0, 1],
                        [0, 0, 1]])
#搭建模型
model = sequential()
model.add(dense(units = 2, input_dim = 2))
#model.add(dense(units = 2, input_dim = 2, activation = 'sigmoid'))
model.add(dense(units = 3, activation = 'softmax'))
#编译模型
model.compile(optimizer = 'adam', loss = 'mse')
#训练模型
model.fit(x = train_x, y = train_y, epochs = 10000)
#保存模型
keras.models.save_model(model, 'iris2.model')

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com