最近,对深度学习感兴趣,报了日月光华深度学习课程,所以给大家分享全部的代码、PPT、数据集资源:下载链接

以下是fashion mnist数据集的识别分类代码:

import tensorflow as tf
import matplotlib.pyplot as plt
import numpy as np
(train_image,train_lable),(test_image,test_label)= tf.keras.datasets.fashion_mnist.load_data()
print(train_image.shape)
print(test_image.shape)
#归一化
train_image = train_image/255
test_image = test_image/255

model = tf.keras.Sequential()
#不能把二维数据进行dense运算(28,28)
#28*28
model.add(tf.keras.layers.Flatten(input_shape=(28,28)))
#128,不能太大,会过拟合
model.add(tf.keras.layers.Dense(128,activation='relu'))
#概率输出,分10类
model.add(tf.keras.layers.Dense(10,activation='softmax'))
model.compile(optimizer = 'adam',loss = 'sparse_categorical_crossentropy',
              metrics=['acc'])
history = model.fit(train_image,train_lable,epochs=10)
history.history.keys()
plt.plot(history.epoch,history.history.get("loss"))
plt.plot(history.epoch,history.history.get("acc"))
plt.show()
model.evaluate(test_image,test_label)

希望大家在深度学习的路上越走越远!

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐