0% found this document useful (0 votes)
35 views3 pages

Vedant@13

Uploaded by

Vedant Andhale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views3 pages

Vedant@13

Uploaded by

Vedant Andhale
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

13

April 15, 2024

[1]: import tensorflow as tf


from keras.datasets import mnist
from keras.models import Sequential
from keras.layers import Dense, Flatten

2024-04-15 08:24:45.627101: I external/local_tsl/tsl/cuda/cudart_stub.cc:32]


Could not find cuda drivers on your machine, GPU will not be used.
2024-04-15 08:24:45.630120: I external/local_tsl/tsl/cuda/cudart_stub.cc:32]
Could not find cuda drivers on your machine, GPU will not be used.
2024-04-15 08:24:45.670122: I tensorflow/core/platform/cpu_feature_guard.cc:210]
This TensorFlow binary is optimized to use available CPU instructions in
performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild
TensorFlow with the appropriate compiler flags.
2024-04-15 08:24:46.729378: W
tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not
find TensorRT

[2]: # Load and preprocess the MNIST dataset


(X_train, y_train), (X_test, y_test) = mnist.load_data()

#reshaping of input values


X_train = X_train / 255.0 #(28,28)
X_test = X_test / 255.0

# Define the model architecture


model = Sequential([
Flatten(input_shape=(28, 28)),
Dense(128, activation='relu'),
Dense(10, activation='softmax')
])

Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-


datasets/mnist.npz
11490434/11490434 �������������������� 2s
0us/step
/home/codespace/.python/current/lib/python3.10/site-
packages/keras/src/layers/reshaping/flatten.py:37: UserWarning: Do not pass an

1
`input_shape`/`input_dim` argument to a layer. When using Sequential models,
prefer using an `Input(shape)` object as the first layer in the model instead.
super().__init__(**kwargs)

[3]: # Compile the model


model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy', #multi class␣
↪classification problems

metrics=['accuracy'])

# Train the model


model.fit(X_train, y_train, epochs=10, batch_size=64 )

# Evaluate the model


loss, accuracy = model.evaluate(X_test, y_test)
print(f"Test Loss: {loss}")
print(f"Test Accuracy: {accuracy}")

Epoch 1/10
2024-04-15 08:24:51.656526: W
external/local_tsl/tsl/framework/cpu_allocator_impl.cc:83] Allocation of
188160000 exceeds 10% of free system memory.
938/938 �������������������� 3s 2ms/step -
accuracy: 0.8570 - loss: 0.5127
Epoch 2/10
938/938 �������������������� 2s 2ms/step -
accuracy: 0.9589 - loss: 0.1427
Epoch 3/10
938/938 �������������������� 2s 2ms/step -
accuracy: 0.9735 - loss: 0.0929
Epoch 4/10
938/938 �������������������� 3s 3ms/step -
accuracy: 0.9801 - loss: 0.0699
Epoch 5/10
938/938 �������������������� 4s 4ms/step -
accuracy: 0.9839 - loss: 0.0539
Epoch 6/10
938/938 �������������������� 3s 2ms/step -
accuracy: 0.9882 - loss: 0.0408
Epoch 7/10
938/938 �������������������� 2s 2ms/step -
accuracy: 0.9901 - loss: 0.0352
Epoch 8/10
938/938 �������������������� 3s 2ms/step -
accuracy: 0.9912 - loss: 0.0305
Epoch 9/10
938/938 �������������������� 3s 3ms/step -

2
accuracy: 0.9932 - loss: 0.0243
Epoch 10/10
938/938 �������������������� 2s 2ms/step -
accuracy: 0.9951 - loss: 0.0199
125/313 �������������������� 0s 811us/step -
accuracy: 0.9772 - loss: 0.0816
2024-04-15 08:25:17.483211: W
external/local_tsl/tsl/framework/cpu_allocator_impl.cc:83] Allocation of
31360000 exceeds 10% of free system memory.
313/313 �������������������� 0s 1ms/step -
accuracy: 0.9763 - loss: 0.0809
Test Loss: 0.06995158642530441
Test Accuracy: 0.979200005531311

You might also like