神经网络实现fashion数据集

import tensorflow as tf
import numpy as np
fashion=tf.keras.datasets.fashion_mnist

(x_train,y_train),(x_test,y_test)=fashion.load_data()


model=tf.keras.Sequential([tf.keras.layers.Flatten(),
                          tf.keras.layers.Dense(128,activation='relu'),
                          tf.keras.layers.Dense(10,activation='softmax')])

model.compile(optimizer='adam',
              loss=tf.keras.losses.SparseCategoricalCrossentropy(from_logits=False),
              metrics=['sparse_categorical_accuracy'])

model.fit(x_train,y_train,batch_size=32,epochs=3,validation_data=(x_test,y_test),validation_freq=1)

model.summary()

注:数据集下载不成功的原因是没挂vpn,挂vpn后即可成功下载!

posted @ 2020-08-12 16:09  爬到牢底坐穿  阅读(295)  评论(0编辑  收藏  举报