Python 3.x 计算矩阵之间的损失
在谷歌的一篇文章()中,使用这个 loss函数为了最小化错误,我用Python用Tensorflow编写了这个函数Python 3.x 计算矩阵之间的损失,python-3.x,machine-learning,deep-learning,tensorflow2.0,loss-function,Python 3.x,Machine Learning,Deep Learning,Tensorflow2.0,Loss Function,在谷歌的一篇文章()中,使用这个 loss函数为了最小化错误,我用Python用Tensorflow编写了这个函数 def loss_cal(noise_source, mask, target): landa = 0.113 masked_spec = noise_source*mask cc = K.l2_normalize(tf.abs(tf.pow(tf.maximum(1e-4, target), 0.3))-tf.abs(tf.pow(tf.maximum(
def loss_cal(noise_source, mask, target):
landa = 0.113
masked_spec = noise_source*mask
cc = K.l2_normalize(tf.abs(tf.pow(tf.maximum(1e-4, target), 0.3))-tf.abs(tf.pow(tf.maximum(1e-4, masked_spec), 0.3)))
cm = K.l2_normalize(tf.math.pow(tf.maximum(1e-4, target), 0.3)-tf.math.pow(tf.maximum(1e-4, masked_spec), 0.3))
res = tf.math.square(cc)+landa*tf.math.square(cm)
return res
但是它返回一个矩阵,而损失函数必须在一个scare中返回,请纠正我,我的实现错了吗?或者有可能训练一个以损失为矩阵的模型?您不应该使用just,而不是
l2_normalize返回使用范数值规格化的矩阵 您不应该使用just,而不是
l2_normalize返回使用范数值规格化的矩阵 但在本文中,使用l2_normalize@WalidBousseta在公式中,他们使用2-范数(欧几里德范数),这是tf.norm的默认值。这是一个标量。l2_normalize使用2-范数规范化矩阵_normalize@WalidBousseta在公式中,他们使用2-范数(欧几里德范数),这是tf.norm的默认值。这是一个标量。l2_规格化使用2-范数规格化矩阵。