import tensorflow as tf
from tensorflow import keras
import matplotlib as mpl
from matplotlib import pyplot as plt
%matplotlib inline
import sklearn
import numpy as np
import pandas as pd
import os
import sys
#Get data:
fashion_mnist = keras.datasets.fashion_mnist #download the mnist data(x_train_all,y_train_all),(x_test,y_test)= fashion_mnist.load_data()#split data to train and test
x_valid ,x_train = x_train_all[:5000],x_train_all[5000:]#splot train data to train and valid
y_valid ,y_train = y_train_all[:5000],y_train_all[5000:]#splot train data to train and validprint(x_valid.shape,y_valid.shape)print(x_train.shape,y_train.shape)print(x_test.shape,y_test.shape)
#built model
model = keras.Sequential()
model.add(keras.layers.Flatten(input_shape=[28,28]))for i inrange(20):
model.add(keras.layers.Dense(100,activation="relu"))
model.add(keras.layers.Dense(10,activation="softmax"))
model.compile(
loss ="sparse_categorical_crossentropy",
optimizer ="sgd",
metrics =["accuracy"])
#train
history = model.fit(x_train_scaled,y_train,epochs=10,validation_data=[x_valid_scaled,y_valid])