Reputation: 180
I'm a newbie to Keras. I'm playing around Keras to get some intuition and stuck with here.
input_image = tf.keras.Input(shape=(16,16,3))
x = tf.keras.layers.Conv2D(32,(3,3), padding = 'same')(input_image)
model = tf.keras.Model(input_image , x)
model.compile(optimizer='Adam',loss = 'MSE')
inputs = np.random.normal(size = (16,16,3))
outputs = np.random.normal(size = (16,16,32))
model.fit(x = inputs , y =outputs)
I just wanted to see the output shape that model.summary says (None, 16, 16, 32). But now I have two questions. One is the output shape and another is why my code doesn't work. I hope someone tells me what I'm missing. Thanks~
Upvotes: 4
Views: 839
Reputation: 13349
inputs = np.random.normal(size = (1,16,16,3)) #<---- here
outputs = np.random.normal(size = (1,16,16,32)) #<---here
They should be 4D not 3D in shape. You need to give the detail of batch also.
(batch_size, w,h,c)
<---- 4D
You are missing batch_size
32,(3,3)
from tf.keras.layers.Conv2D(32,(3,3), padding = 'same')(input_image)
You have 32 filters. So the channel depth will be 32. But since you have used the padding='same' so your output will have the same dimension as input. Only differ in depth.
Upvotes: 2