tf1常用损失函数

tf.nn.sigmoid_cross_entropy_with_logits() 表示和sigmoid搭配使用的交叉熵
tf.nn.softmax_cross_entropy_with_logits() 表示和softmax搭配使用的交叉熵

这两种模型预测logit要经过sigmoid或者softmax,label要进行onehot

还有contrib下面的Module: tf.contrib.losses  |  TensorFlow Core v1.15.0

tf.contrib.losses.mean_squared_error

predictionsThe predicted outputs.
labelsThe ground truth output tensor, same dimensions as 'predictions'.
weightsCoefficients for the loss a scalar, a tensor of shape [batch_size] or a tensor whose shape matches predictions.
scopeThe scope for the operations performed in computing the loss.

tf.contrib.losses.sparse_softmax_cross_entropy

logits[batch_size, num_classes] logits outputs of the network .
labels[batch_size, 1] or [batch_size] labels of dtype int32 or int64 in the range [0, num_classes).
weightsCoefficients for the loss. The tensor must be a scalar or a tensor of shape [batch_size] or [batch_size, 1].
scopethe scope for the operations performed in computing the loss.

tf.contrib.losses.softmax_cross_entropy

logits[batch_size, num_classes] logits outputs of the network .
onehot_labels[batch_size, num_classes] one-hot-encoded labels.
weightsCoefficients for the loss. The tensor must be a scalar or a tensor of shape [batch_size].
label_smoothingIf greater than 0 then smooth the labels.
scopethe scope for the operations performed in computing the loss.

tf.contrib.losses.sigmoid_cross_entropy

logits[batch_size, num_classes] logits outputs of the network .
multi_class_labels[batch_size, num_classes] labels in (0, 1).
weightsCoefficients for the loss. The tensor must be a scalar, a tensor of shape [batch_size] or shape [batch_size, num_classes].
label_smoothingIf greater than 0 then smooth the labels.
scopeThe scope for the operations performed in computing the loss.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值