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
predictions | The predicted outputs. |
labels | The ground truth output tensor, same dimensions as 'predictions'. |
weights | Coefficients for the loss a scalar, a tensor of shape [batch_size] or a tensor whose shape matches predictions . |
scope | The 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) . |
weights | Coefficients for the loss. The tensor must be a scalar or a tensor of shape [batch_size] or [batch_size, 1]. |
scope | the 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. |
weights | Coefficients for the loss. The tensor must be a scalar or a tensor of shape [batch_size]. |
label_smoothing | If greater than 0 then smooth the labels. |
scope | the 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). |
weights | Coefficients for the loss. The tensor must be a scalar, a tensor of shape [batch_size] or shape [batch_size, num_classes]. |
label_smoothing | If greater than 0 then smooth the labels. |
scope | The scope for the operations performed in computing the loss. |