大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺
MSELOSS
CLASS torch.nn.MSELoss(size_average=None, reduce=None, reduction: str = 'mean')
创建一个标准来测量输入x和目标y中每个元素之间的均方误差(L2范数平方)。
未减少的损失(即 reduction 设置为 'none')可以描述为:

其中 N 是 batch size. 如果 reduction 不是 'none' (默认为 'mean'), 那么:

x和y是任意形状的张量,每个张量总共有n个元素。
平均值运算仍对所有元素进行运算,并除以n。
如果设置 reduction = 'sum',则可以避免除以n。
Parameters
-
size_average (bool, optional) – Deprecated (see
reduction). By default, the losses are averaged over each loss element in the batch. Note that for some losses, there are multiple elements per sample. If the fieldsize_averageis set toFalse, the losses are instead summed for each minibatch. Ignored when reduce isFalse. Default:True。默认情况下,损失是batch中每个损失元素的平均数。 请注意,对于某些损失,每个样本有多个元素。 如果将size_average字段设置为False,则损失是每个minibatch的总和。 当reduce为False时被忽略。 默认值:True。 -
reduce (bool, optional) – Deprecated (see
reduction). By default, the losses are averaged or summed over observations for each minibatch depending onsize_average. WhenreduceisFalse, returns a loss per batch element instead and ignoressize_average. Default:True。默认情况下,根据size_average对每个minibatch的观察结果求平均或求和。 当reduce为False时,返回每个batch元素损失,并忽略size_average。 默认值:True。 -
reduction (string, optional) – Specifies the reduction to apply to the output:
'none'|'mean'|'sum'.'none': no reduction will be applied,'mean': the sum of the output will be divided by the number of elements in the output,'sum': the output will be summed. Note:size_averageandreduceare in the process of being deprecated, and in the meantime, specifying either of those two args will overridereduction. Default:'mean'。指定要应用于输出的缩减量:’none’| “mean” | ‘sum’。 ‘none’:不应用任何reduction,’mean’:输出的总和除以输出中元素的数量,’sum’:输出的总和。 注意:size_average和reduce正在弃用过程中,与此同时,指定这两个args中的任何一个将覆盖reduction。 默认值:’mean’。
Shape:
-
Input: (N, ∗) where ∗ means, any number of additional dimensions
-
Target: (N, ∗) , same shape as the input
Examples:
>>> loss = nn.MSELoss() >>> input = torch.randn(3, 5, requires_grad=True) >>> target = torch.randn(3, 5) >>> output = loss(input, target) >>> output.backward()
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/192108.html原文链接:https://javaforall.net
