Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vnet_2d: Inputs have incompatible shapes. Received shapes (32, 32, 512) and (32, 32, 256) #45

Open
mehran66 opened this issue Apr 8, 2022 · 2 comments

Comments

@mehran66
Copy link

mehran66 commented Apr 8, 2022

I tested all of the models and they all worked fine, except the vnet_2d:

model.vnet_2d((128, 128, 3), filter_num=[64, 128, 256, 512], n_labels=7,
res_num_ini=1, res_num_max=3, activation='ReLU',
output_activation="Softmax",
batch_norm=True, pool=True, unpool=True,
name='vnet')

Traceback (most recent call last):
File "C:\Users\mehra\anaconda3\envs\gis2\lib\code.py", line 90, in runcode
exec(code, self.locals)
File "", line 1, in
File "C:\Users\mehra\OneDrive\Desktop\deep_learning\tf_keras\semantic_segmentation\model.py", line 116, in model_application
base_model = unet_collection(pixels, n_classes, activation, backbone_model_name, main_model_name, weights)
File "C:\Users\mehra\OneDrive\Desktop\deep_learning\tf_keras\semantic_segmentation\models_code\unet_collection.py", line 78, in unet_collection
base_model = kuc_model.vnet_2d((pixels, pixels, 3), filter_num=[64, 128, 256, 512], n_labels=n_classes,
File "C:\Users\mehra\anaconda3\envs\gis2\lib\site-packages\keras_unet_collection_model_vnet_2d.py", line 225, in vnet_2d
X = vnet_2d_base(X, filter_num, res_num_ini=res_num_ini, res_num_max= res_num_max,
File "C:\Users\mehra\anaconda3\envs\gis2\lib\site-packages\keras_unet_collection_model_vnet_2d.py", line 165, in vnet_2d_base
X = vnet_right(X, [X_skip[i],], f, res_num=res_num_list[i],
File "C:\Users\mehra\anaconda3\envs\gis2\lib\site-packages\keras_unet_collection_model_vnet_2d.py", line 82, in vnet_right
X = Res_CONV_stack(X, X_skip, channel, res_num, activation=activation,
File "C:\Users\mehra\anaconda3\envs\gis2\lib\site-packages\keras_unet_collection\layer_utils.py", line 271, in Res_CONV_stack
X = add([X_skip, X], name='{}_add'.format(name))
File "C:\Users\mehra\anaconda3\envs\gis2\lib\site-packages\keras\layers\merge.py", line 791, in add
return Add(**kwargs)(inputs)
File "C:\Users\mehra\anaconda3\envs\gis2\lib\site-packages\keras\utils\traceback_utils.py", line 67, in error_handler
raise e.with_traceback(filtered_tb) from None
File "C:\Users\mehra\anaconda3\envs\gis2\lib\site-packages\keras\layers\merge.py", line 78, in _compute_elemwise_op_output_shape
raise ValueError(
ValueError: Inputs have incompatible shapes. Received shapes (32, 32, 512) and (32, 32, 256)

@MIMIWAWA
Copy link

MIMIWAWA commented Jul 2, 2022

Me neither~
Could you please fix this bug?

@tombinic
Copy link

tombinic commented Oct 24, 2024

The bug still be present. I fixed with this lines:
if X.shape[-1] != X_skip.shape[-1]: X_skip = Conv2D(channel, (1, 1), padding='same', use_bias=False, name='{}_conv_match'.format(name))(X_skip)
inside Res_CONV_stack method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants