| 624 | //--- Encoder Layer |
| 625 | struct 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 |
nothing calls this directly
no test coverage detected