Created by: sidgoyal78
Addresses second part of #7999 (closed)
Background
The fluid example of NMT model has 2 parts:
train_main()
and decode_main()
. As discussed with @jacquesqiao , the current implementation of the book chapter (as of Feb 8, 2018), is a bit disjoint. More specifically, the decode_main
should ideally use the parameters post training (that is, after calling train_main()
). However, currently the train_main()
demonstrates the working example of dynamic RNN training, and current decode_main()
uses a random initialization of the weights in the encoder-decoder and demonstrates correctness of beam search. Hence, both of the modules are pretty independent.
Current progress (updated)
In order to add inference example for the "inference project", one option is to add "infer" methods for each of the two train_main()
and decode_main()
. This is what is done in this PR.
- For the infer method for
train_main
, we have to provide both source as well as target sequence, even though ideally we don't have access to the target (This is the same issue as in PR #8176). This works. - For the infer method for
decode_main
, we add the function in Python and it works. - The C++ unit-tests corresponding to the 2 infer methods have been added. Since, we don't have a CUDA implementation of beam search op yet, the unit-test for decode runs only for CPU.