im getting error as follows :Input 0 of layer conv2d_transpose_117 is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [12, 16, 256]
could someone please explain whats gone wrong here ? line:ublock 7
ublock6 = upsampling_block(cblock5[0], cblock4[1],n_filters * 8)
ublock7 = upsampling_block(ublock6[0], cblock3[1],n_filters * 4)
ublock8 = upsampling_block(ublock7[0], cblock2[1],n_filters * 2)
ublock9 = upsampling_block(ublock8[0], cblock1[1],n_filters * 1)
YOUR CODE ENDS HERE*
conv9 = Conv2D(n_filters,
3,
activation='relu',
padding='same',
kernel_initializer='he_normal')(ublock9)
Add a Conv2D layer with n_classes filter, kernel size of 1 and a ‘same’ padding
conv10 = Conv2D(None, None, padding=None)(conv9)
YOUR CODE STARTS HERE
conv10 = Conv2D(n_classes ,kernel_size=1, padding='same')(conv9)
YOUR CODE ENDS HERE
model = tf.keras.Model(inputs=inputs, outputs=conv10)
return model
complete error:
ValueError Traceback (most recent call last)
in
4 num_channels = 3
5
----> 6 unet = unet_model((img_height, img_width, num_channels))
7 comparator(summary(unet), outputs.unet_model_output)
in unet_model(input_size, n_filters, n_classes)
36 # YOUR CODE STARTS HERE
37 ublock6 = upsampling_block(cblock5[0], cblock4[1],n_filters * 8)
—> 38 ublock7 = upsampling_block(ublock6[0], cblock3[1],n_filters * 4)
39 ublock8 = upsampling_block(ublock7[0], cblock2[1],n_filters * 2)
40 ublock9 = upsampling_block(ublock8[0], cblock1[1],n_filters * 1)
in upsampling_block(expansive_input, contractive_input, n_filters)
18 kernel_size=3, # Kernel size
19 strides=2,
—> 20 padding=‘same’)(expansive_input)
21
22 # Merge the previous output and the contractive_input
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in call (self, *args, **kwargs)
924 if _in_functional_construction_mode(self, inputs, args, kwargs, input_list):
925 return self._functional_construction_call(inputs, args, kwargs,
→ 926 input_list)
927
928 # Maintains info about the Layer.call
stack.
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py in _functional_construction_call(self, inputs, args, kwargs, input_list)
1090 # TODO(reedwm): We should assert input compatibility after the inputs
1091 # are casted, not before.
→ 1092 input_spec.assert_input_compatibility(self.input_spec, inputs, self.name)
1093 graph = backend.get_graph()
1094 # Use self._name_scope()
to avoid auto-incrementing the name.
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/input_spec.py in assert_input_compatibility(input_spec, inputs, layer_name)
194 ‘, found ndim=’ + str(ndim) +
195 '. Full shape received: ’ +
→ 196 str(x.shape.as_list()))
197 # Check dtype.
198 if spec.dtype is not None:
ValueError: Input 0 of layer conv2d_transpose_117 is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [12, 16, 256]