What is input_shape?

I was reading a website and saw this

model = models.Sequential()model.add(layers.Conv2D(32, (3, 3), activation='relu', input_shape=(32, 32, 3)))model.add(layers.MaxPooling2D((2, 2)))model.add(layers.Conv2D(64, (3, 3), activation='relu'))model.add(layers.MaxPooling2D((2, 2)))model.add(layers.Conv2D(64, (3, 3), activation='relu'))

This a piece of a computer program.

The input_shape receive 3 inputs. What does the first input mean. Is it the width of the image? Is it the height of the image?

Hi @david_lopez1 ,

The first is to input the width of the image, the second is the height of the image and the third is the number of channels (the image has 3 channels (red, green, and blue)).

I hope this helps you!


In the given code snippet, the input_shape (32, 32, 3*)* refers to the dimensions of the input image that the model will accept. The three values in the tuple represent the width, height, and number of color channels of the image, respectively.

1 Like