highway.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:jack 作者: uclmr 项目源码 文件源码
def forward(self, x):
        """
            :param x: tensor with shape of [batch_size, size]
            :return: tensor with shape of [batch_size, size]
            applies ?(x) ? (f(G(x))) + (1 - ?(x)) ? (Q(x)) transformation | G and Q is affine transformation,
            f is non-linear transformation, ?(x) is affine transformation with sigmoid non-linearition
            and ? is element-wise multiplication
            """

        for layer in range(self.num_layers):
            gate = F.sigmoid(self.gate[layer](x))

            nonlinear = self.f(self.nonlinear[layer](x))
            linear = self.linear[layer](x)

            x = gate * nonlinear + (1 - gate) * linear

        return x
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号