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},
        y=mnist_labels,
        num_epochs=1,
        shuffle=False)
mnist_results=classifier.evaluate(input_fn=val_input_fn)
print(mnist_results)

Comments

Popular posts from this blog

Naturally Simulated Prosthetic Arm With Electro Myo Grapy(EMG)-Robotic Arm (Product Creation):

IOT based Home automation Project Controlled by Google Assistant--Product Creation

SEQUENCE MODEL EX-13