Closed pankajkasar closed 3 years ago
@pankajkasar Please provide with indented code such that we can replicate the issue or if possible share a colab gist with the error, can you try with tf nightly or 2.4 and let us know if the issue exists.
The following only line which I forget to add:
model=segnet(input_shape=(256,256,3),n_labels=1)
I also added in above code. Thanks for reply.
@pankajkasar Please move the issue to closed status is resolved.
@Saduf2019 TF 2.4.0 is not yet available to us for download and use. What else option?? I will immediately close issue if i get all answers.
gist:93f2dafae3cb5a0da41746960bc6718a
Created public gist
Finally I found solution on above error. We need to change class MaxUnpooling2D definition as follows:-
class MaxUnpooling2D(Layer):
def __init__(self, size=(2, 2), **kwargs):
super(MaxUnpooling2D, self).__init__(**kwargs)
self.size = size
def call(self, inputs, output_shape=None):
updates, mask = inputs[0], inputs[1]
with tf.compat.v1.variable_scope(self.name):
mask = K.cast(mask, 'int32')
input_shape = tf.shape(updates, out_type='int32')
#print(updates.shape)
#print(mask.shape)
if output_shape is None:
output_shape = (
input_shape[0],
input_shape[1] * self.size[0],
input_shape[2] * self.size[1],
input_shape[3])
ret = tf.scatter_nd(K.expand_dims(K.flatten(mask)),
K.flatten(updates),
[K.prod(output_shape)])
input_shape = updates.shape
out_shape = [-1,
input_shape[1] * self.size[0],
input_shape[2] * self.size[1],
input_shape[3]]
return K.reshape(ret, out_shape)
def get_config(self):
config = super().get_config().copy()
config.update({
'size': self.size
})
return config
def compute_output_shape(self, input_shape):
mask_shape = input_shape[1]
return (
mask_shape[0],
mask_shape[1]*self.size[0],
mask_shape[2]*self.size[1],
mask_shape[3]
)
I am implementing SEGNET segmentation Network in python but getting the following error,
_Traceback (most recent call last): File "/scratch/pkasar.dbatu/training/NEW_SEGNET_updated_on_16_11_20.py", line 370, in
model=segnet(input_shape=(256,256,3),n_labels=1)
File "/scratch/pkasar.dbatu/training/NEW_SEGNET_updated_on_16_11_20.py", line 161, in segnet
conv_14 = Convolution2D(512, (kernel, kernel), padding="same")(unpool_1)
File "/home/pkasar.dbatu/.conda/envs/dl/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 897, in call
self._maybe_build(inputs)
File "/home/pkasar.dbatu/.conda/envs/dl/lib/python3.7/site-packages/tensorflow/python/keras/engine/base_layer.py", line 2416, in _maybe_build
self.build(input_shapes) # pylint:disable=not-callable
File "/home/pkasar.dbatu/.conda/envs/dl/lib/python3.7/site-packages/tensorflow/python/keras/layers/convolutional.py", line 153, in build
input_channel = self._get_input_channel(input_shape)
File "/home/pkasar.dbatu/.conda/envs/dl/lib/python3.7/site-packages/tensorflow/python/keras/layers/convolutional.py", line 293, in _get_inputchannel
raise ValueError('The channel dimension of the inputs '
ValueError: The channel dimension of the inputs should be defined. Found
None
.Tensorflow image is:- tensorflow 2.2.0 tensorflow-gpu 2.2.0 keras-base 2.4.3
keras-gpu 2.4.3
python 3.7.9 Please help me out Thank you in advance
@tensorflow-copybara , @tensorflow-jenkins @TensorFlow-MKL @tensorflowbutler @tensorflower-gardener
The code snippet is as follows:-