When attempting to translate with the --with_scores option enabled, an error is encountered in the OpenNMT translation module. The specific error message is:
AttributeError: 'float' object has no attribute 'item'
This error arises from the translator.py file at line 437, within a list comprehension where it attempts to access the item() attribute of a float object in trans.pred_scores.
Expected Behavior:
The translation process with scores should proceed without encountering any errors, providing the translated text along with corresponding scores.
Actual Behavior:
The error mentioned above is encountered, halting the translation process and preventing the retrieval of translation scores.
Additional Context:
This issue occurs specifically when translating with scores enabled; without scores, the translation process functions as expected.
The error seems to stem from an attempt to access the item() attribute of a float object, which is invalid.
Possible Solution:
Inspect the code within the translator.py file at line 437 to identify the source of the error. Ensure that the trans.pred_scores attribute is properly handled when the --with_scores option is enabled.
When attempting to translate with the --with_scores option enabled, an error is encountered in the OpenNMT translation module. The specific error message is:
AttributeError: 'float' object has no attribute 'item'
This error arises from the translator.py file at line 437, within a list comprehension where it attempts to access the item() attribute of a float object in trans.pred_scores.
Expected Behavior: The translation process with scores should proceed without encountering any errors, providing the translated text along with corresponding scores.
Actual Behavior: The error mentioned above is encountered, halting the translation process and preventing the retrieval of translation scores.
Additional Context:
This issue occurs specifically when translating with scores enabled; without scores, the translation process functions as expected. The error seems to stem from an attempt to access the item() attribute of a float object, which is invalid. Possible Solution: Inspect the code within the translator.py file at line 437 to identify the source of the error. Ensure that the trans.pred_scores attribute is properly handled when the --with_scores option is enabled.
Environment:
Python version: 3.9 OpenNMT version: 3.5.1 Operating System: Ubuntu