(self, src, lengths=None)
return emb, out.transpose(0, 1).contiguous()
See :obj:`EncoderBase.forward()`
See :obj:`EncoderBase.forward()`
See : obj : EncoderBase . forward ()
def forward(self, src, lengths=None):
        """ See :obj:`EncoderBase.forward()`"""
        self._check_args(src, lengths)

        emb = self.embeddings(src)

        out = emb.transpose(0, 1).contiguous()
        words = src[:, :, 0].transpose(0, 1)
        w_batch, w_len = words.size()
        padding_idx = self.embeddings.word_padding_idx
        mask = words.data.eq(padding_idx).unsqueeze(1) \
            .expand(w_batch, w_len, w_len)
        # Run the forward pass of every layer of the tranformer.
        for i in range(self.num_layers):
            out = self.transformer[i](out, mask)
        out = self.layer_norm(out)

        return emb, out.transpose(0, 1).contiguous()
def forward ( self , src , lengths = None ) : self . _check_args ( src , lengths ) emb = self . embeddings ( src ) out = emb . transpose ( 0 , 1 ) . contiguous ( ) words = src [ : , : , 0 ] . transpose ( 0 , 1 ) w_batch , w_len = words . size ( ) padding_idx = self . embeddings . word_padding_idx mask = words . data . eq ( padding_idx ) . unsqueeze ( 1 ) . expand ( w_batch , w_len , w_len ) # Run the forward pass of every layer of the tranformer. for i in range ( self . num_layers ) : out = self . transformer [ i ] ( out , mask ) out = self . layer_norm ( out ) return emb , out . transpose ( 0 , 1 ) . contiguous ( )