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

tensor dimension input error when running 3D N2V #143

Open
ywu130 opened this issue Aug 19, 2023 · 7 comments
Open

tensor dimension input error when running 3D N2V #143

ywu130 opened this issue Aug 19, 2023 · 7 comments

Comments

@ywu130
Copy link

ywu130 commented Aug 19, 2023

Hello, I encountered this error when running the example 3D training for N2V. The error says: Node: 'model/batch_normalization/FusedBatchNormV3'
2 root error(s) found.
(0) INVALID_ARGUMENT: input must be 4-dimensional[4,32,64,64,32]
[[{{node model/batch_normalization/FusedBatchNormV3}}]]
[[gradient_tape/model/batch_normalization_1/FusedBatchNormGradV3/_184]]
(1) INVALID_ARGUMENT: input must be 4-dimensional[4,32,64,64,32]
[[{{node model/batch_normalization/FusedBatchNormV3}}]]
0 successful operations.
0 derived errors ignored. [Op:__inference_train_function_3323];
It seems it is expecting 2D input, not 3D (5D tensor). And indeed the 2D training example works for me. I am running the example notebook locally. My N2V version: 0.3.2; my tensorflow version: 2.13.0; I am using a M1 macbook.
was this error related to version issue? What would you suggest me to do? Thank you!

@jdeschamps
Copy link
Member

Hi!

We will try to have a look in the coming days! In the mean time, you could try with older versions of tensorflow. I am pretty sure the notebook was tested with TF2.10 but not with TF2.13.

@ywu130
Copy link
Author

ywu130 commented Aug 23, 2023

Thank you! I am using a M1 macbook and it only supports TF2.13 to my knowledge. Also I tested the napari-n2v plugins. II used napari 0.4.18 and TF2.13, and napari-n2v 0.1.0. Same issue (tensor dimension error) appeared.

@jdeschamps
Copy link
Member

It seems to be a known M1 problem, but there also seem to be solutions. Could you try the suggestion here: #133?

@jdeschamps
Copy link
Member

Any luck?

@ywu130
Copy link
Author

ywu130 commented Aug 30, 2023

still no luck. I created a new conda environment with tensorflow 2.9.0 and tensorflow-metal 0.5.0. And n2v 0.3.2. I reproduced the error I got earlier (the same as #133 ). 2D works fine still.

@veegalinova
Copy link
Contributor

Seems like a tensorflow-metal specific issue, and also reproduces on M2. Unfortunately, I wasn't able to find a solution yet.

For now, training of 3D model on M1/M2 seems possible only on CPU:

with tf.device("/cpu:0"):
    history = model.train(X, X_val)

@Emmakikix
Copy link

Emmakikix commented Mar 25, 2024

I had a similar issue when I ran 2D-RGB and it prompted:
"InvalidArgumentError: image must be 3-dimensional[3,64,64,3] [Op:EncodePng]"
N2V version: 0.3.3; tensorflow version: 2.7.0; I am using windows 10;
This happedened when the training finished the first epoch. I tried running with cpu but it didn't work.

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

4 participants