OpenNMT-py icon indicating copy to clipboard operation
OpenNMT-py copied to clipboard

dump input encoding feature added

Open piyp791 opened this issue 4 years ago • 3 comments

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.

piyp791 avatar Mar 24 '20 04:03 piyp791

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.

francoishernandez avatar Mar 26 '20 09:03 francoishernandez

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?

piyp791 avatar Mar 26 '20 10:03 piyp791

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.

francoishernandez avatar Mar 26 '20 13:03 francoishernandez