def _get_cost(self, inputs):
Z, X, lmbd = self.inputs
with tf.name_scope("Cost"):
rec = tf.matmul(Z, tf.constant(self.D))
Er = tf.reduce_mean(
tf.reduce_sum(tf.squared_difference(rec, X),
reduction_indices=[1]))/2
cost = Er + lmbd * tf.reduce_mean(
tf.reduce_sum(tf.abs(Z), reduction_indices=[1]))
return cost
评论列表
文章目录