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

Method EncoderLayer

examples/transformer/transformer.h:626–637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

624//--- Encoder Layer
625struct EncoderLayer{
626 explicit EncoderLayer(DyNetModel* mod, TransformerConfig& tfc)
627 :_self_attention_sublayer(mod, tfc)
628 , _feed_forward_sublayer(mod, tfc)
629 {
630 // for layer normalisation
631 _p_ln1_g = mod->add_parameters({tfc._num_units}, dynet::ParameterInitConst(1.f));
632 _p_ln1_b = mod->add_parameters({tfc._num_units}, dynet::ParameterInitConst(0.f));
633 _p_ln2_g = mod->add_parameters({tfc._num_units}, dynet::ParameterInitConst(1.f));
634 _p_ln2_b = mod->add_parameters({tfc._num_units}, dynet::ParameterInitConst(0.f));
635
636 _p_tfc = &tfc;
637 }
638
639 ~EncoderLayer(){}
640

Callers

nothing calls this directly

Calls 2

ParameterInitConstClass · 0.50
add_parametersMethod · 0.45

Tested by

no test coverage detected