anaconda 安装包
链接:https://pan.baidu.com/s/1wh6mYu1uMLlPM5Ai5ONCXQ
提取码:3rlo
两个库
pip install tensorflow==2.8.0 keras==2.8 -i https://pypi.douban.com/simple/
Looking in indexes: https://pypi.douban.com/simple/
pip install protobuf==3.20 -i https://pypi.douban.com/simple/
Looking in indexes: https://pypi.douban.com/simple/
测试代码
import tensorflow as tf
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.mnist.load_data()
x_train = x_train.reshape(x_train.shape[0], 28, 28, 1).astype('float32')
x_test = x_test.reshape(x_test.shape[0], 28, 28, 1).astype('float32')
model = tf.keras.models.Sequential([
tf.keras.layers.Conv2D(filters=6, kernel_size=(5, 5), activation='sigmoid', input_shape=(28, 28, 1)),
tf.keras.layers.MaxPool2D(pool_size=(2, 2), strides=2),
tf.keras.layers.Conv2D(filters=16, kernel_size=(5, 5), activation='sigmoid'),
tf.keras.layers.MaxPool2D(pool_size=(2, 2), strides=2),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(120, activation='sigmoid'),
tf.keras.layers.Dense(84, activation='sigmoid'),
tf.keras.layers.Dense(10, activation='softmax'),
])
model.compile(optimizer='adam', loss='sparse_categorical_crossentropy', metrics=['accuracy'])
model.fit(x_train, y_train, epochs=10)
model.evaluate(x_test, y_test)
标签:layers,jupyer,keras,28,test,train,tf,tensorflow,按照 From: https://www.cnblogs.com/china520/p/16818062.html