0

minΣ(||xi-X ci||^2+ λ ||ci||),

st cii = 0,

其中 X 是形状为 d * n 的矩阵,C 是形状为 n * n 的矩阵,xi 和 ci 分别表示 X 和 C 的列。

X在这里是已知的,基于X我们想找到C。

4

1 回答 1

2

通常会有这样的损失,您需要对其进行矢量化,而不是使用列:

loss = X - tf.matmul(X, C)
loss = tf.reduce_sum(tf.square(loss))

reg_loss = tf.reduce_sum(tf.square(C), 0)  # L2 loss for each column
reg_loss = tf.reduce_sum(tf.sqrt(reg_loss))

total_loss = loss + lambd * reg_loss

要在 C 的对角线上实现零约束,最好的方法是用另一个常数将其添加到损失中lambd2

reg_loss2 = tf.trace(tf.square(C))
total_loss = total_loss + lambd2 * reg_loss2
于 2016-07-15T01:33:19.210 回答