使用损失函数更新神经网络的权重

问题描述 投票:0回答:1

我对使用tf.reduce_mean(tf.nn.l2_loss(prediction - output))线感到困惑。

在进行反向传播时,输出应该是一个向量,因为从实际输出中减去每个输出神经元的预测输出,并且对于所有输出神经元重复这一过程,因此我们得到一个大小为(n,1)的向量。如果我们使用tf.reduce_mean(tf.nn.l2_loss(prediction - output)),则输出是单个值。我无法理解如何传播此单个值来更新权重。它不应该总是一个载体吗?

neural-network backpropagation loss-function
1个回答
0
投票

你的错误必须是一个向量。但是,这一行

tf.reduce_mean

是平均损失超过批次,而不是矢量。见https://stats.stackexchange.com/questions/201452/is-it-common-practice-to-minimize-the-mean-loss-over-the-batches-instead-of-the

© www.soinside.com 2019 - 2024. All rights reserved.