安装 tensorflow2.3.1
2020-11-20 本文已影响0人
fdsun
tensorflow官网:https://tensorflow.google.cn/install
1,安装python3.8.3
2,使用豆瓣镜像源:pip config set global.index-url https://pypi.douban.com/simple
3,pip install tensorflow
4,安装cuda10.2和cudnn (未进行)
- example
import tensorflow as tf
import numpy as np
from tensorflow import keras
model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')
xs = np.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype=float)
ys = np.array([1.0, 1.5, 2.0, 2.5, 3.0, 3.5], dtype=float)
model.fit(xs, ys, epochs=1000)
print(model.predict([8.0, 9.0, 10.0]))
参考链接:
https://www.cnblogs.com/fanfan-1/p/12419607.html
https://blog.csdn.net/u012263517/article/details/105279508/