keras-unet-collection icon indicating copy to clipboard operation
keras-unet-collection copied to clipboard

ASPP block error in resunet_a_2d

Open Raito03 opened this issue 1 month ago • 0 comments

while running the resUnet_a_2d model i got this error --

File /opt/conda/lib/python3.10/site-packages/keras_unet_collection/model_resunet_a_2d.py:177, in resunet_a_2d_base(input_tensor, filter_num, dilation_num, aspp_num_down, aspp_num_up, activation, batch_norm, pool, unpool, name) 173 X = ResUNET_a_block(X, f, kernel_size=3, dilation_num=dilation[ind_], activation=activation, 174 batch_norm=batch_norm, name='{}resblock{}'.format(name, ind_)) 175 X_skip.append(X) --> 177 X = ASPP_conv(X, aspp_num_down, activation=activation, batch_norm=batch_norm, name='{}aspp_bottom'.format(name)) 179 X_skip = X_skip[:-1][::-1] 180 dilation = dilation_[:-1][::-1]

File /opt/conda/lib/python3.10/site-packages/keras_unet_collection/layer_utils.py:351, in ASPP_conv(X, channel, activation, batch_norm, name) 348 activation_func = eval(activation) 349 bias_flag = not batch_norm --> 351 shape_before = X.get_shape().as_list() 352 b4 = GlobalAveragePooling2D(name='{}_avepool_b4'.format(name))(X) 354 b4 = expand_dims(expand_dims(b4, 1), 1, name='{}_expdim_b4'.format(name))

AttributeError: 'KerasTensor' object has no attribute 'get_shape'

i searched ChatGPT and got the solution that-- "The error you're encountering indicates that the ASPP_conv function is attempting to call get_shape().as_list() on a KerasTensor, which no longer has this method in the newer versions of TensorFlow/Keras. Instead, you should use tf.shape() or tf.keras.backend.int_shape() to handle this."

can you update the code please to make the aspp block work

Raito03 avatar May 21 '24 16:05 Raito03