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
评论列表
文章目录