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

ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (0, 1) #17

Open
st-pfister opened this issue Aug 26, 2021 · 14 comments

Comments

@st-pfister
Copy link

Hey,

thank you for developing this tool, very excited to use it.
I wanted to run the following script on my fast5_pass files:

(Deeplexicon) beckmannlab-arch% python3 deeplexicon.py -p ~/"run/user/1005/gvfs/afp-volume:host=XXX.XX.XX.XX,user=stefan,volume=beckmannlab/stefan/Data (not complete)/read files DeePlexiCon/DeePlexiCon test 1/fast5_pass/fast5_pass" -f multi -m /home/beckmannlab/deeplexicon/models/resnet20-final.h5 > output.tsv

When running this script, I get the following:

Using TensorFlow backend.
WARNING: Logging before flag parsing goes to stderr.
W0825 11:59:11.809371 140291947890368 deprecation_wrapper.py:119] From /home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:517: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.

W0825 11:59:11.833133 140291947890368 deprecation_wrapper.py:119] From /home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:4185: The name tf.truncated_normal is deprecated. Please use tf.random.truncated_normal instead.

W0825 11:59:11.845560 140291947890368 deprecation_wrapper.py:119] From /home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:245: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.

W0825 11:59:11.845713 140291947890368 deprecation_wrapper.py:119] From /home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:174: The name tf.get_default_session is deprecated. Please use tf.compat.v1.get_default_session instead.

W0825 11:59:11.845817 140291947890368 deprecation_wrapper.py:119] From /home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:181: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.

2021-08-25 11:59:11.845981: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2021-08-25 11:59:11.865134: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3401065000 Hz
2021-08-25 11:59:11.865529: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x55aff10a6260 executing computations on platform Host. Devices:
2021-08-25 11:59:11.865553: I tensorflow/compiler/xla/service/service.cc:175] StreamExecutor device (0): ,
2021-08-25 11:59:11.877678: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412] (One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--tf_xla_cpu_global_jit was not set. If you want XLA:CPU, either set that envvar, or use experimental_jit_scope to enable XLA:CPU. To confirm that XLA is active, pass --vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or set the envvar XLA_FLAGS=--xla_hlo_profile.
W0825 11:59:11.893048 140291947890368 deprecation_wrapper.py:119] From /home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:1834: The name tf.nn.fused_batch_norm is deprecated. Please use tf.compat.v1.nn.fused_batch_norm instead.

W0825 11:59:13.072088 140291947890368 deprecation_wrapper.py:119] From /home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/keras/backend/tensorflow_backend.py:3980: The name tf.nn.avg_pool is deprecated. Please use tf.nn.avg_pool2d instead.

W0825 11:59:17.393233 140291947890368 deprecation_wrapper.py:119] From /home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/keras/optimizers.py:790: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.

W0825 11:59:17.728567 140291947890368 deprecation.py:323] From /home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/tensorflow/python/ops/math_grad.py:1250: add_dispatch_support..wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
Traceback (most recent call last):
File "deeplexicon.py", line 622, in
main()
File "deeplexicon.py", line 304, in main
C = classify(model, labels, np.array(images), False, args.threshold)
File "deeplexicon.py", line 611, in classify
y = model.predict(x, verbose=0)
File "/home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/keras/engine/training.py", line 1149, in predict
x, _, _ = self._standardize_user_data(x)
File "/home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/keras/engine/training.py", line 751, in _standardize_user_data
exception_prefix='input')
File "/home/beckmannlab/Deeplexicon/Deeplexicon/lib/python3.7/site-packages/keras/engine/training_utils.py", line 128, in standardize_input_data
'with shape ' + str(data_shape))
ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (0, 1)
(Deeplexicon) beckmannlab-arch% --vmodule=xla_compilation_cache=1
zsh: command not found: --vmodule=xla_compilation_cache=1

I installed all packages in the versions given in the "Additional Information" section and am using Linux. I also tried it on a Mac using conda, but also could not get the script running (here with different Errors).

Hope I was able to state my problem and hope one can help me!

Bests,
stefan.

@Psy-Fer
Copy link
Owner

Psy-Fer commented Aug 26, 2021

G'day Stefan.

The issue here seems to be the array fed to the classifier isn't being populated.

Was there any other output? did it process any files and just fail part way through? there should be some messages letting the user know that reads are being segmented, and then they go through classification.

Let me know any more info you can give me. Trying to figure out if it's struggling to read the fast5 files from that very long, non-linux friendly path, or if it's something else.

Cheers,
James

@st-pfister
Copy link
Author

st-pfister commented Aug 26, 2021

Hey,
thank you for your quick reply.

There was no other output in the terminal, and also the output.tsv file was empty (a table has been created though with no entries)..
I tried the script with a shorter directory without a server-IP, but I do get the same error/output.

Cheers,
stefan.

@Psy-Fer
Copy link
Owner

Psy-Fer commented Aug 26, 2021

Ahh, okay.

Are the fast5 files using vbz compression (not compatible yet, though there is a pull request that adds it)?
Can you move 1 fast5 file to a local folder to test on?

does the same error occur when using

python3 deeplexicon_sub.py dmux -p path/to/fast5s/ -m /home/beckmannlab/deeplexicon/models/resnet20-final.h5 > output.tsv

@st-pfister
Copy link
Author

st-pfister commented Aug 26, 2021

So the same error occurs when using the deeplexicon_sub.py, irregardless of the fast5 file being on a local folder or server..

Yes to the vbz! I just recently upgraded my MinKNOW GUI to 4.3.20, with MinKNOW version 21.06.0 and in the release not it is stated that "VBZ and Gzip new compression defaults".
Should I then change the script according to the available pull request?

Thank you!

@Psy-Fer
Copy link
Owner

Psy-Fer commented Aug 26, 2021

ooh, yea, that's the issues.

I have not had a chance to test the pull request just yet, but if you have the skill to merge and run that pull request, it should work. Leszek knows what he's doing, so I'm betting it will work fine.

Let me know how it goes, or if you need me to give an ETA on the pull request review (working on something else at the moment that is almost done).

@st-pfister
Copy link
Author

Thank you for hinting me towards the problem, I would definitely like to try the work of Leszek.
However, I could not merge the request yet as it says "Only those with write access to this repository can merge pull requests."

@Psy-Fer
Copy link
Owner

Psy-Fer commented Aug 31, 2021

Okay, i've reviewed the merge and tested it, and now accepted and merged it.

If you do a git pull to get the most up to date code, you should be able to try again.

Let me know how it goes :)

@rpeiro
Copy link

rpeiro commented Apr 21, 2022

Hey, thank you for this software. I have just install it, but I got the same error when running this command:

python3 /home/rpeiro/software/deeplexicon/deeplexicon_sub.py dmux -p FAS46772_pass_49565cac_3.fast5 -f multi -m /home/rpeiro/software/deeplexicon/models/resnet20-final.h5 > output.tsv

The output is:

Using TensorFlow backend.
2022-04-21 08:22:36.226090: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2022-04-21 08:22:36.386874: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 3591490000 Hz
2022-04-21 08:22:36.429902: I tensorflow/compiler/xla/service/service.cc:150] XLA service 0x55ea3a07d4a0 executing computations on platform Host. Devices:
2022-04-21 08:22:36.429938: I tensorflow/compiler/xla/service/service.cc:158] StreamExecutor device (0): ,
WARNING:tensorflow:From /home/rpeiro/software/Deeplexicon/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py:263: colocate_with (from tensorflow.python.framework.ops) is deprecated and will be removed in a future version.
Instructions for updating:
Colocations handled automatically by placer.
WARNING:tensorflow:From /home/rpeiro/software/Deeplexicon/lib/python3.7/site-packages/tensorflow/python/ops/math_ops.py:3066: to_int32 (from tensorflow.python.ops.math_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.cast instead.
Traceback (most recent call last):
File "/home/rpeiro/software/deeplexicon/deeplexicon_sub.py", line 1437, in
main()
File "/home/rpeiro/software/deeplexicon/deeplexicon_sub.py", line 292, in main
dmux_pipeline(args)
File "/home/rpeiro/software/deeplexicon/deeplexicon_sub.py", line 453, in dmux_pipeline
C = classify(model, labels, np.array(images), False, args.threshold)
File "/home/rpeiro/software/deeplexicon/deeplexicon_sub.py", line 828, in classify
y = model.predict(x, verbose=0)
File "/home/rpeiro/software/Deeplexicon/lib/python3.7/site-packages/keras/engine/training.py", line 1149, in predict
x, _, _ = self._standardize_user_data(x)
File "/home/rpeiro/software/Deeplexicon/lib/python3.7/site-packages/keras/engine/training.py", line 751, in _standardize_user_data
exception_prefix='input')
File "/home/rpeiro/software/Deeplexicon/lib/python3.7/site-packages/keras/engine/training_utils.py", line 128, in standardize_input_data
'with shape ' + str(data_shape))
ValueError: Error when checking input: expected input_1 to have 4 dimensions, but got array with shape (0, 1)

The output file output.tsv contains only a header:

fast5 ReadID Barcode Confidence Interval P_bc_1 P_bc_2 P_bc_3 P_bc_4

Is there a solution to this issue?
Thanx in advance

@ShawnSimp
Copy link

Hello, was solution for this error found? i'm currently dealing with the exact issue.

@Psy-Fer
Copy link
Owner

Psy-Fer commented Dec 1, 2022

Hello,
Deeplexicon is in a bit of a sorry state. It was built while tensorflow and many of the other packages around it were going through rapid development and upgrades. While trying to lock down specific versions and make it as stable as I could, it still has some issues that are difficult to pin down. Ideally, I would like to update the whole thing to the latest tensorflow and retrain the models.

I'll see if I can solve this particular issue. It looks like the data isn't getting through the model.predict call as x isn't the correct shape. I'll have a look at it this week and see what I can do.

James

@Psy-Fer
Copy link
Owner

Psy-Fer commented Dec 1, 2022

Minor update, this has spurred Martin and I to get a student to update Deeplexicon as a project.

I'll still look at this issue though.

@N-damo
Copy link

N-damo commented Jul 10, 2023

I add this line(if len(labels) == 0:return ) in deeplexicon_multi.py, it works for me
image

btw, in multiprocess, I suggest it should add '\n' in 'print("{}\t{}\t{}\t{}\t{}\n".format(fast5s[readID], readID, barcode_out[out], cm, "\t".join(["{:.5f}".format(prob[i]) for i in range(0,len(prob))])))' ,because without the lock in code,it will compete each other in the print output
image

@Psy-Fer
Copy link
Owner

Psy-Fer commented Jul 10, 2023

Thanks for picking that up.

We are considering doing a new release for RNA004, in which case I'll re-write this whole thing to be more stable (and waaaaay faster). Just trying to see what ONT is doing to see if it's worth it or not.

@enovoa
Copy link
Collaborator

enovoa commented Jan 13, 2024

Hi @N-damo and @rpeiro, can you please try running Deeplexicon through the masterOfPores nextflow workflow and see if the error persists? Please note that DeePlexiCon works only with CUDA version 10, if using GPU mode (see DeePlexiCon dependencies here ). Thanks!

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

6 participants