lewis-chinery / Humatch

Fast, gene-specific joint humanisation of antibody heavy and light chains.
BSD 3-Clause "New" or "Revised" License
1 stars 4 forks source link

Layer count mismatch #1

Open QUEST2179 opened 1 month ago

QUEST2179 commented 1 month ago

tried the example in notebook folder

(20, 3) is_human heavy light 0 1 QVQ-LVQSGA-EVNKPGASVKVSCKASGYTF---------TGYVVH... EIV-LTQSPVTLSLSPGERATLSCRASQSV-----------SFYLA... 1 1 QVQ-LVQSGA-EVKKPGASVKVSCKASGYTF---------TGYYMH... SYE-LTQPPS-VSVSPGQTARITCSGDALP-----------KQYAY... Traceback (most recent call last): File "C:\Users\work\antibody\Humatch-master\testClassify.py", line 25, in cnn_heavy = load_cnn(os.path.join(weights_dir, "heavy.weights.h5"), "heavy") File "C:\Users\work\antibody\Humatch-master\Humatch\model.py", line 130, in load_cnn CNN.load_weights(weights) File "C:\Users\miniconda3\envs\gpu9\lib\site-packages\keras\utils\traceback_utils.py", line 70, in error_handler raise e.with_traceback(filtered_tb) from None File "C:\Users\miniconda3\envs\gpu9\lib\site-packages\keras\saving\hdf5_format.py", line 817, in load_weights_from_hdf5_group raise ValueError( ValueError: Layer count mismatch when loading weights from file. Model expected 3 layers, found 0 saved layers.

lewis-chinery commented 1 month ago

Hi, I just tried deleting everything, reinstalling, and running the notebooks and it seemed to work OK for me (the weights download automatically). Could you please provide a bit more information:

If you do need to use a different set-up to that described in the README (especially using conda and not venv) then you could try manually downloading the weights as described in the README and trying again

jesperdlau commented 3 weeks ago

I had the same error and fixed it by upgrading Tensorflow to 2.17. Then I got a different error, something like: TypeError: generator yielded an element that did not match the expected structure. The expected structure was (tf.float64,), but the yielded element was [[[-0.47 0.24 0.07 ...

This I fixed by changing the way the data generator is used inside the classify script, for the predict_from_list_of_seq_strs function. Instead of return model.predict(test_generator, verbose=CNN_verbose) I used: return model.predict(next(iter(test_generator)), batch_size=batch_size, verbose=CNN_verbose) (Remember to "pip install ." after changing code) I other words, I parse the data itself, not the generator. I seems like the custom generator isn't compatible with Tensorflow 2.17 at least. Hope it makes sense. So far it works, but might not be the case always. It took me a long time to figure out.

@lewis-chinery Can you please share the exact package versions you have?