# SigmoidCrossEntropyWithLogits

public class SigmoidCrossEntropyWithLogits

### Public Methods

 static Operand sigmoidCrossEntropyWithLogits(Scope scope, Operand labels, Operand logits) Computes sigmoid cross entropy given `logits`.

## Public Methods

#### public static Operand<T> sigmoidCrossEntropyWithLogits(Scope scope, Operand<T> labels, Operand<T> logits)

Computes sigmoid cross entropy given `logits`.

Measures the probability error in discrete classification tasks in which each class is independent and not mutually exclusive. For instance, one could perform multilabel classification where a picture can contain both an elephant and a dog at the same time.

For brevity, let `x = logits`, `z = labels`. The logistic loss in pseudo-code is

``` z * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x))
= z * -log(1 / (1 + exp(-x))) + (1 - z) * -log(exp(-x) / (1 + exp(-x)))
= z * log(1 + exp(-x)) + (1 - z) * (-log(exp(-x)) + log(1 + exp(-x)))
= z * log(1 + exp(-x)) + (1 - z) * (x + log(1 + exp(-x))
= (1 - z) * x + log(1 + exp(-x))
= x - x * z + log(1 + exp(-x))
```

For `x < 0`, to avoid overflow in `exp(-x)`, we reformulate the above

``` x - x * z + log(1 + exp(-x))
= log(exp(x)) - x * z + log(1 + exp(-x))
= - x * z + log(1 + exp(x))
```

Hence, to ensure stability and avoid overflow, the implementation uses this equivalent formulation

```   max(x, 0) - x * z + log(1 + exp(-abs(x)))
```

logits and `labels` must have the same type and shape.

##### Parameters
scope The TensorFlow scope the labels the logits of type float32 or float64
##### Returns
• the component-wise logistic losses.
##### Throws
IllegalArgumentException if logits' and labels' do not have the same shape
[{ "type": "thumb-down", "id": "missingTheInformationINeed", "label":"Missing the information I need" },{ "type": "thumb-down", "id": "tooComplicatedTooManySteps", "label":"Too complicated / too many steps" },{ "type": "thumb-down", "id": "outOfDate", "label":"Out of date" },{ "type": "thumb-down", "id": "samplesCodeIssue", "label":"Samples / code issue" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]