OpenNMT-py
OpenNMT-py copied to clipboard
dump input encoding feature added
This PR intends to add the dump input encoding feature, which dumps sentence encodings ( hidden state output from the last layer of the encoder) to a text file. This feature was a part of the OpenNMT Lua implementation.
Hey @peps0791
This looks like a good idea indeed!
I'm not a fan of having architecture-specific code in onmt.translate.translator
though.
I think it may be better to do this on onmt.encoders
level, with a dedicated method for each different encoder that may need it.
Thanks for the feedback, @francoishernandez!
Just to make sure I understand correctly, should I add the dump_encoding method declaration to the EncoderBase class, with each encoder class implementing that method?
Also, could you please review the code (line 660-669), and see if it's correct, so I don't repeat the error across all methods?
Just to make sure I understand correctly, should I add the dump_encoding method declaration to the EncoderBase class, with each encoder class implementing that method?
Yes
Also, could you please review the code (line 660-669), and see if it's correct, so I don't repeat the error across all methods?
This looks ok.
Anyways, as the structure is different for the different encoders, this won't be the same code everywhere. That's the whole point of putting this method in each encoder class.