Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Test CNN over the cifar10 data set, which contains 32x32 colour images from 10 classes: 1. Use the below code to load the data set.

image text in transcribed

Test CNN over the cifar10 data set, which contains 32x32 colour images from 10 classes: 1. Use the below code to load the data set. from keras.datasets import cifar10 (x_train, y_train), (x_test, y_test) = cifar10.load_data() print("Train samples:", x_train. shape, y_train.shape) print("Test samples:", x_test. shape, y_test. shape) 2. Show the 10 classes NUM_CLASSES = 10 cifar10_classes = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"] # show random images from train cols = 8 rows = 2 fig = plt. figure(figsize=(2 * cols - 1, 2.5 * rows - 1)) for i in range(cols): for j in range(rows): random_index = np.random.randint(0, len(y-train)) ax = fig.add_subplot(rows, cols, i * rows + j + 1) ax.grid('off') ax.axis('off') ax. imshow(x_train[random_index, :]) ax.set_title(cifar10_classes [y_train[random_index, 0]]) plt.show 3. Define a CNN architecture and train your own model by playing with the network setup: like, performs convolution, performs 2D max pooling, changing activation function from ReLU to LeakyReLU, adding dropout etc. # import necessary building blocks from keras.models import Sequential from keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Activation, Dropout from keras.layers.advanced_activations import LeakyReLU Test CNN over the cifar10 data set, which contains 32x32 colour images from 10 classes: 1. Use the below code to load the data set. from keras.datasets import cifar10 (x_train, y_train), (x_test, y_test) = cifar10.load_data() print("Train samples:", x_train. shape, y_train.shape) print("Test samples:", x_test. shape, y_test. shape) 2. Show the 10 classes NUM_CLASSES = 10 cifar10_classes = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"] # show random images from train cols = 8 rows = 2 fig = plt. figure(figsize=(2 * cols - 1, 2.5 * rows - 1)) for i in range(cols): for j in range(rows): random_index = np.random.randint(0, len(y-train)) ax = fig.add_subplot(rows, cols, i * rows + j + 1) ax.grid('off') ax.axis('off') ax. imshow(x_train[random_index, :]) ax.set_title(cifar10_classes [y_train[random_index, 0]]) plt.show 3. Define a CNN architecture and train your own model by playing with the network setup: like, performs convolution, performs 2D max pooling, changing activation function from ReLU to LeakyReLU, adding dropout etc. # import necessary building blocks from keras.models import Sequential from keras.layers import Conv2D, MaxPooling2D, Flatten, Dense, Activation, Dropout from keras.layers.advanced_activations import LeakyReLU

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Differentiate 3sin(9x+2x)

Answered: 1 week ago