MCPcopy Create free account
hub / github.com/clab/dynet / Decoder

Method Decoder

examples/transformer/transformer.h:993–1014  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

991
992struct Decoder{
993 explicit Decoder(DyNetModel* mod, TransformerConfig& tfc, Encoder* p_encoder)
994 {
995 _p_embed_t = mod->add_lookup_parameters(tfc._tgt_vocab_size, {tfc._num_units});
996
997 if (!tfc._use_hybrid_model && tfc._position_encoding == 1){
998 _p_embed_pos = mod->add_lookup_parameters(tfc._max_length, {tfc._num_units});
999 }
1000
1001 for (unsigned l = 0; l < tfc._nlayers; l++){
1002 _v_dec_layers.push_back(DecoderLayer(mod, tfc));
1003 }
1004
1005 if (tfc._use_hybrid_model){
1006 _p_tgt_rnn.reset(new dynet::LSTMBuilder(1/*shallow*/, tfc._num_units, tfc._num_units, *mod, true/*w/ layer norm*/));
1007 }
1008
1009 _scale_emb = std::sqrt(tfc._num_units);
1010
1011 _p_tfc = &tfc;
1012
1013 _p_encoder = p_encoder;
1014 }
1015
1016 ~Decoder(){}
1017

Callers

nothing calls this directly

Calls 4

DecoderLayerClass · 0.85
sqrtFunction · 0.50
add_lookup_parametersMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected