import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
(train_images,train_lables),(test_images,test_labels) = tf.keras.datasets.mnist.load_data()
train_images = train_images/255
test_images = test_images/255
print(train_images.shape)
ds_train_img = tf.data.Dataset.from_tensor_slices(train_images)
print(ds_train_img)
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
(train_images,train_lables),(test_images,test_labels) = tf.keras.datasets.mnist.load_data()
train_images = train_images/255
test_images = test_images/255
print(train_images.shape)
ds_train_img = tf.data.Dataset.from_tensor_slices(train_images)
print(ds_train_img)
ds_train_lab = tf.data.Dataset.from_tensor_slices(train_lables)
print(ds_train_lab)
ds_train = tf.data.Dataset.zip((ds_train_img,ds_train_lab))
print(ds_train)
ds_train = ds_train.shuffle(10000).repeat().batch(64)
model = tf.keras.Sequential([
tf.keras.layers.Flatten(input_shape=(28,28)),
tf.keras.layers.Dense(128,activation="relu"),
tf.keras.layers.Dense(10,activation="softmax")
])
model.compile(optimizer="adam",
loss="sparse_categorical_crossentropy",
metrics=["accuracy"])
steps_per_epochs = train_images.shape[0]//64
model.fit(ds_train,epochs=5,steps_per_epoch=steps_per_epochs)
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
import tensorflow as tf
(train_images,train_lables),(test_images,test_labels) = tf.keras.datasets.mnist.load_data()
train_images = train_images/255
test_images = test_images/255
ds_train_img = tf.data.Dataset.from_tensor_slices(train_images)
ds_train_lab = tf.data.Dataset.from_tensor_slices(train_lables)
ds_train = tf.data.Dataset.zip((ds_train_img,ds_train_lab))
ds_train = ds_train.shuffle(10000).repeat().batch(64)
ds_test = tf.data.Dataset.from_tensor_slices((test_images,test_labels))
ds_test = ds_test.batch(64)
model = tf.keras.Sequential([
tf.keras.layers.Flatten(input_shape=(28,28)),
tf.keras.layers.Dense(128,activation="relu"),
tf.keras.layers.Dense(10,activation="softmax")
])
model.compile(optimizer="adam",
loss="sparse_categorical_crossentropy",
metrics=["accuracy"])
steps_per_epochs = train_images.shape[0]//64
model.fit(ds_train,
epochs=5,
steps_per_epoch=steps_per_epochs,
validation_data=ds_test,
validation_steps=10000//64)