Ex 3
Ex 3
AIM:
ALGORITHM:
STEP 3: Normalize the image data by scaling pixel values to the range [0, 1].
STEP 5: Build an Artificial Neural Network (ANN) using Sequential() with Dense layers.
STEP 6: Compile the model using the Adam optimizer, sparse categorical crossentropy loss, and
accuracy metric.
STEP 7: Train the model using the training data for 10 epochs with a batch size of 90 and 20%
validation split.
STEP 10: Visualize the first 5 test images with their predicted labels using Matplotlib.
PROGRAM:
import tensorflow as t
x_train = x_train.reshape(-1, 32 * 32 * 3)
CSE/NM/NN&DL / 513322104003/DHIVYA G
x_test = x_test.reshape(-1, 32 * 32 * 3)
model = models.Sequential([
layers.Dense(256, activation='relu'),
])
predictions = model.predict(x_test)
plt.figure(figsize=(10, 5))
for i in range(5):
plt.subplot(1, 5, i + 1)
plt.title(f'Predicted: {predictions[i].argmax()}')
plt.axis('off')
plt.show()
OUTPUT:
RESULT:
Thus, the python code for Basic Image Classification is executed successfully.
CSE/NM/NN&DL / 513322104003/DHIVYA G