You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I've encountered an issue related to scalar-matrix arithmetic operations.
Whenever a multiplication, addition, subtraction, or division operation occurs between a float/int and an instance of dynet.Expression, this exception is raised if the float/int precedes a dynet.Expression instance.
If, on the contrary, an instance of dynet.Expression is placed before float/int, no exception occurs. I suppose that this happens due to the strict order of arguments in methods for scalar-matrix operators (matrix goes first, then scalar goes): https://dynet.readthedocs.io/en/latest/operations.html
Traceback (most recent call last):
File "postcorrection/multisource_wrapper.py", line 63, in <module>
pretrainer = PretrainHandler(
File "/Users/fyodorsizov/Documents/git/ocr-post-correction/postcorrection/pretrain_handler.py", line 81, in __init__
self.pretrain_model(pretrain_src1, pretrain_src2, pretrain_tgt, epochs)
File "/Users/fyodorsizov/Documents/git/ocr-post-correction/postcorrection/pretrain_handler.py", line 88, in pretrain_model
self.seq2seq_trainer.train(
File "/Users/fyodorsizov/Documents/git/ocr-post-correction/postcorrection/seq2seq_trainer.py", line 53, in train
losses.append(self.model.get_loss(src1, src2, tgt))
File "/Users/fyodorsizov/Documents/git/ocr-post-correction/postcorrection/multisource_model.py", line 295, in get_loss
return self.decode_loss(src1, src2, tgt)
File "/Users/fyodorsizov/Documents/git/ocr-post-correction/postcorrection/multisource_model.py", line 278, in decode_loss
probs, _ = self.get_pointergen_probs(
File "/Users/fyodorsizov/Documents/git/ocr-post-correction/postcorrection/multisource_model.py", line 204, in get_pointergen_probs
copy_probs = a_t * (1 - p_gen)
TypeError: unsupported operand type(s) for -: 'int' and '_dynet.Expression'
Have you seen something like this before? Any idea how to fix this other than changing the order of terms inside the code or overriding __mul__, __add__, etc methods?
The text was updated successfully, but these errors were encountered:
sfedia
added a commit
to sfedia/ocr-post-correction
that referenced
this issue
Jul 11, 2024
Hi! I've encountered an issue related to scalar-matrix arithmetic operations.
Whenever a multiplication, addition, subtraction, or division operation occurs between a float/int and an instance of
dynet.Expression
, this exception is raised if the float/int precedes adynet.Expression
instance.If, on the contrary, an instance of
dynet.Expression
is placed before float/int, no exception occurs. I suppose that this happens due to the strict order of arguments in methods for scalar-matrix operators (matrix goes first, then scalar goes): https://dynet.readthedocs.io/en/latest/operations.htmlHave you seen something like this before? Any idea how to fix this other than changing the order of terms inside the code or overriding
__mul__
,__add__
, etc methods?The text was updated successfully, but these errors were encountered: