predictive_autoencoder.py 文件源码

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

项目:Multitask-and-Transfer-Learning 作者: AI-ON 项目源码 文件源码
def __call__(self, x_image, t_image, x_action, t_action):
        self.y_image, self.y_action = self.predictor(x_image, x_action)

        predicted_action = self.action_meaning(
            F.argmax(self.y_action, axis=1).data[0])
        real_action = self.action_meaning(t_action)
        if predicted_action != real_action:
            print("Predicted action:", predicted_action,
                  "it was actually", real_action)
        image_loss = F.mean_squared_error(self.y_image, t_image)
        self.error_mask = normalize_2d(F.squared_error(self.y_image, t_image))
        action_loss = F.softmax_cross_entropy(
            self.y_action,
            F.expand_dims(np.array(t_action, dtype=np.int32), axis=0),
        )
        print('Image loss', image_loss.data, ', Action loss:', action_loss.data)
        return self.weight * image_loss + (1.0 - self.weight) * action_loss
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号