assignment5.py 文件源码

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

项目:pfi-internship2016 作者: hvy 项目源码 文件源码
def __call__(self, x, t):
        """Perform a forward pass and compute the loss. This method ultimately
        defines the model.

        Args:
            x (chainer.Variable): Input vector.
            t (chainer.Variable): Target vector. Usually identical to `x` in
                the case of an Autoencoder.

        Returns:
            chainer.Variable: Loss.
        """
        # Test different activation functions and dropout.
        h = self.l1(x)
        y = self.l2(h)

        if self.train:
            # Scale the MSE by 5, i.e  0.5 * 10 so that the loss can be compared to
            # the loss computed in Assignment 4. Factor 0.5, since the Chainer
            # implementation doesn't scale the error by 0.5 and factor 10, since
            # the previous assignment loss functions does not compute the mean,
            # and the number of summed elements are 10.
            self.loss = 5 * F.mean_squared_error(y, t)

            return self.loss
        else:
            return y
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号