srcnn.py 文件源码

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

项目:srcnn-tensorflow 作者: tjvandal 项目源码 文件源码
def _loss(self, predictions):
        with tf.name_scope("loss"):
            # if training then crop center of y, else, padding was applied
            slice_amt = (np.sum(self.filter_sizes) - len(self.filter_sizes)) / 2
            slice_y = self.y_norm[:,slice_amt:-slice_amt, slice_amt:-slice_amt]
            _y = tf.cond(self.is_training, lambda: slice_y, lambda: self.y_norm)
            tf.subtract(predictions, _y)
            err = tf.square(predictions - _y)
            err_filled = utils.fill_na(err, 0)
            finite_count = tf.reduce_sum(tf.cast(tf.is_finite(err), tf.float32))
            mse = tf.reduce_sum(err_filled) / finite_count
            return mse
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号