Registrations Closing Soon for DevOps Certification Training by CloudxLab | Registrations Closing inEnroll Now
With reference to the class labels and the class names as given in the official documantation of Keras, let us store all them in a list
class_names as follows.
plt.imshow(X, cmap="binary") displays
X data as an image.
cmap is used to map scalar data to colors.
cmap=binary maps the image color to black and white format while displaying the image.
plt.axis('off') is used to turn off the axes for subplots( you could remove this line and observe the difference for yourself).
plt.subplot(a,b) is used to create a figure and a set of subplots with
a rows and
plt.subplots_adjust() is used to tune the subplot layout.
Write the following code to store the class names of the data set.
class_names = ["T-shirt/top", "Trouser", "Pullover", "Dress", "Coat", "Sandal", "Shirt", "Sneaker", "Bag", "Ankle boot"]
Plot an image using Matplotlib's
plt.imshow() function, with a 'binary' color map:
print("Class label is:", y_train) print("Class name is:", class_names[y_train]) plt.imshow(X_train, cmap="binary") plt.axis('off') plt.show()
Let's take a look at a sample of the images in the dataset.
n_rows = 4 n_cols = 10 plt.figure(figsize=(15, 6)) for row in range(n_rows): for col in range(n_cols): index = n_cols * row + col plt.subplot(n_rows, n_cols, index + 1) plt.imshow(X_train[index],cmap="binary") plt.axis('off') plt.title(class_names[y_train[index]], fontsize=12) plt.subplots_adjust(wspace=0.2, hspace=0.5) plt.show()
No hints are availble for this assesment
Answer is not availble for this assesment
Note - Having trouble with the assessment engine? Follow the steps listed here