Softmax Regession Exp-3
import tensorflow as tf from tensorflow import keras import numpy as np (( train_data , train_labels ), ( mnist_data , mnist_labels ))= tf .keras.datasets.mnist.load_data() train_data = train_data / np .float32( 255 ) train_labels = train_labels .astype( np .int32) mnist_data = mnist_data / np .float32( 255 ) mnist_labels = mnist_labels .astype( np .int32) feature_columns =[ tf .feature_column.numeric_column( "x" , shape =[ 28 , 28 ])] classifier = tf .estimator.LinearClassifier( feature_columns = feature_columns , n_classes = 10 , model_dir = "mnist_model/" ) train_input_fn = tf .compat.v1.estimator.inputs.numpy_input_fn( x ={ "x" : train_data }, y = train_labels , batch_size = 100 , num_epochs = None , shuffle = True ) classifier .train( input_fn = train_input_fn , steps = 5 ) val_input_fn = tf .compat.v1.estimator.inputs.numpy_input_fn( x ={ "x" : mnist_data },