import tensorflow as tf from tensorflow import keras fashion_mnist=keras.datasets.fashion_mnist (train_images,train_labels),(test_images,test_labels)=fashion_mnist.load_data() train_images=train_images/255.0 test_images=test_images/255.0 model=keras.Sequential(layers=[ keras.layers.Flatten(input_shape=(28,28)), keras.layers.Dense(128,activation='relu'), keras.layers.Dense(10) ]) model.compile(optimizer='adam', loss=keras.losses.SparseCategoricalCrossentropy( from_logits=True), metrics=['accuracy']) model.fit(train_images,train_labels,epochs=3,batch_size=64) #测试 model.evaluate(test_images,test_labels) predicted_model=keras.Sequential(layers=[model,keras.layers.Softmax()]) predicted=predicted_model.predict(train_images[:10]) print(predicted)