InvalidArgumentError: Exception encountered when calling layer 'encoder' (type TFMarianEncoder)
I am fine-tuning a translation model which translates English to Swahili with my own datasets. Everything goes well during training but when I try to use the pre-trained model i run into thefollowing error. Any help will be highly appreciated.If the problem is with my data please provide a step-by-step way in which I could solve it because am a beginner. ThanksInvalidArgumentError                      Traceback (most recent call last)in <cell line: 5>()3 # Replace this with your own checkpoint4 model_checkpoint = “KigenCHESS/new-en-to-sw”----> 5 translaton = pipeline(“translation”, model=model_checkpoint)10 frames/usr/local/lib/python3.9/dist-packages/transformers/models/marian/modeling_tf_marian.py in call(self, input_ids, inputs_embeds, attention_mask, head_mask, output_attentions, output_hidden_states, return_dict, training)789                     ),790                 )→ 791                 inputs_embeds = self.embed_tokens(input_ids) * self.embed_scale792793         embed_pos = self.embed_positions(input_shape)InvalidArgumentError: Exception encountered when calling layer ‘encoder’ (type TFMarianEncoder).cannot compute Mul as input#1(zero-based) was expected to be a half tensor but is a float tensor [Op:Mul]Call arguments received by layer ‘encoder’ (type TFMarianEncoder):• input_ids=tf.Tensor(shape=(3, 5), dtype=int32)• inputs_embeds=None• attention_mask=tf.Tensor(shape=(3, 5), dtype=int32)• head_mask=None• output_attentions=False• output_hidden_states=False• return_dict=True• training=False
2023-04-26T13:56:51Z
Same problem, replying to get notified
2023-04-26T14:24:57Z
I found the solution by commenting out this code tf.keras.mixed_precision.set_global_policy(“mixed_float16”)
2023-04-26T15:57:16Z
that worked for me too, thanks a lot!
2024-02-04T06:30:59Z
KigenCHESS:tf.keras.mixed_precision.set_global_policy(“mixed_float16”)Hi,I’m having the same issue. In which part of the code did you comment outtf.keras.mixed_precision.set_global_policy(“mixed_float16”)?Thanks.