Gaius-Augustus / learnMSA

Learning and Aligning Large Protein Families with support of protein language models.
MIT License
19 stars 3 forks source link

TypeError: Exception encountered when calling MsaHmmLayer.call(). #13

Open hspfatemeh opened 2 weeks ago

hspfatemeh commented 2 weeks ago

Hi there. I have an error when run third cell of "learnMSA_demo.ipynb" file. please tell my mistake.

train_filename = "/kaggle/input/egfefgegf/egf.fasta"


---> 45 B = B[:,1:max_model_length+1,:20] + self.epsilon 
     46 B /= tf.reduce_sum(B, axis=-1, keepdims=True) 
     47 B = tf.reshape(B, (-1, 20))

TypeError: Exception encountered when calling MsaHmmLayer.call().

in user code:

    File "/opt/conda/lib/python3.10/site-packages/learnMSA/msa_hmm/MsaHmmLayer.py", line 257, in _forward_recursion_impl  *
        prior = cell.get_prior_log_density()
    File "/opt/conda/lib/python3.10/site-packages/learnMSA/msa_hmm/MsaHmmCell.py", line 178, in get_prior_log_density  *
        em_priors = [tf.reduce_sum(em.get_prior_log_density(), 1) for em in self.emitter]
    File "/opt/conda/lib/python3.10/site-packages/learnMSA/msa_hmm/Emitter.py", line 155, in get_prior_log_density  *
        return self.prior(self.make_B(), lengths=self.lengths)
    File "/opt/conda/lib/python3.10/site-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler  **
        raise e.with_traceback(filtered_tb) from None
    File "/opt/conda/lib/python3.10/site-packages/learnMSA/msa_hmm/Priors.py", line 45, in call
        B = B[:,1:max_model_length+1,:20] + self.epsilon

    TypeError: Exception encountered when calling AminoAcidPrior.call().

    Only integers, slices (`:`), ellipsis (`...`), tf.newaxis (`None`) and scalar tf.int32/tf.int64 tensors are valid indices, got <tf.Tensor 'amino_acid_prior_2_1/add:0' shape=() dtype=float32>

    Arguments received by AminoAcidPrior.call():
      • B=tf.Tensor(shape=(10, 61, 24), dtype=float32)
      • lengths=tf.Tensor(shape=(10,), dtype=float32)

Arguments received by MsaHmmLayer.call():
  • args=('<KerasTensor shape=(None, None, None, 24), dtype=float32, sparse=False, name=keras_tensor_2>', '<KerasTensor shape=(None, None), dtype=int64, sparse=False, name=keras_tensor_1>')
  • kwargs={'training': 'False'}
felbecker commented 2 weeks ago

Hello,

Sorry that you have to face inconveniences when using learnMSA.

I can not reproduce your error on the current main branch. I tested TensorFlow 2.10 + Python 3.9 and Tensorflow 2.17 + Python 3.12.

Please make sure your repo is up to date. If it still doesn't work, my best guess is a version incompatiblity.

Best, Felix

felbecker commented 3 days ago

Hi, have you been able to resolve your issue or do you need further help with this? Best, Felix