<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><htmlxmlns="http://www.w3.org/1999/xhtml"><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"/><title>TensorFlow.NN</title><linkhref="ocean.css"rel="stylesheet"type="text/css"title="Ocean"/><scriptsrc="haddock-util.js"type="text/javascript"></script><scripttype="text/javascript">//<![CDATA[
window.onload = function () {pageLoad();setSynopsis("mini_TensorFlow-NN.html");};
</script></head><body><divid="package-header"><ulclass="links"id="page-menu"><li><ahref="src/TensorFlow-NN.html">Source</a></li><li><ahref="index.html">Contents</a></li><li><ahref="doc-index.html">Index</a></li></ul><pclass="caption">tensorflow-nn-0.1.0.0: Friendly layer around TensorFlow bindings.</p></div><divid="content"><divid="module-header"><tableclass="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><pclass="caption">TensorFlow.NN</p></div><divid="synopsis"><pid="control.syn"class="caption expander"onclick="toggleSection('syn')">Synopsis</p><ulid="section.syn"class="hide"onclick="toggleSection('syn')"><liclass="src short"><ahref="#v:sigmoidCrossEntropyWithLogits">sigmoidCrossEntropyWithLogits</a> :: (<ahref="../tensorflow-0.1.0.0/TensorFlow-Types.html#t:OneOf">OneOf</a> `[<ahref="../base-4.8.2.0/Prelude.html#t:Float">Float</a>, <ahref="../base-4.8.2.0/Prelude.html#t:Double">Double</a>]` a, <ahref="../tensorflow-0.1.0.0/TensorFlow-Types.html#t:TensorType">TensorType</a> a, <ahref="../base-4.8.2.0/Prelude.html#t:Num">Num</a> a) =><ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Tensor">Tensor</a><ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Value">Value</a> a -><ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Tensor">Tensor</a><ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Value">Value</a> a -><ahref="../tensorflow-0.1.0.0/TensorFlow-Build.html#t:Build">Build</a> (<ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Tensor">Tensor</a><ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Value">Value</a> a)</li></ul></div><divid="interface"><h1>Documentation</h1><divclass="top"><pclass="src"><aname="v:sigmoidCrossEntropyWithLogits"class="def">sigmoidCrossEntropyWithLogits</a><ahref="src/TensorFlow-NN.html#sigmoidCrossEntropyWithLogits"class="link">Source</a></p><divclass="subs arguments"><pclass="caption">Arguments</p><table><tr><tdclass="src">:: (<ahref="../tensorflow-0.1.0.0/TensorFlow-Types.html#t:OneOf">OneOf</a> `[<ahref="../base-4.8.2.0/Prelude.html#t:Float">Float</a>, <ahref="../base-4.8.2.0/Prelude.html#t:Double">Double</a>]` a, <ahref="../tensorflow-0.1.0.0/TensorFlow-Types.html#t:TensorType">TensorType</a> a, <ahref="../base-4.8.2.0/Prelude.html#t:Num">Num</a> a)</td><tdclass="doc empty"> </td></tr><tr><tdclass="src">=><ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Tensor">Tensor</a><ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Value">Value</a> a</td><tdclass="doc"><p><strong>logits</strong></p></td></tr><tr><tdclass="src">-><ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Tensor">Tensor</a><ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Value">Value</a> a</td><tdclass="doc"><p><strong>targets</strong></p></td></tr><tr><tdclass="src">-><ahref="../tensorflow-0.1.0.0/TensorFlow-Build.html#t:Build">Build</a> (<ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Tensor">Tensor</a><ahref="../tensorflow-0.1.0.0/TensorFlow-Tensor.html#t:Value">Value</a> a)</td><tdclass="doc empty"> </td></tr></table></div><divclass="doc"><p>Computes sigmoid cross entropy given <code>logits</code>.</p><p>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.</p><p>For brevity, let `x = logits`, `z = targets`. The logistic loss is</p><p>z * -log(sigmoid(x)) + (1 - z) * -log(1 - sigmoid(x))
= x - x * z + log(1 + exp(-x))</p><p>For x < 0, to avoid overflow in exp(-x), we reformulate the above</p><p>x - x * z + log(1 + exp(-x))
= log(exp(x)) - x * z + log(1 + exp(-x))
= - x * z + log(1 + exp(x))</p><p>Hence, to ensure stability and avoid overflow, the implementation uses this
equivalent formulation</p><p>max(x, 0) - x * z + log(1 + exp(-abs(x)))</p><p><code>logits</code> and <code>targets</code> must have the same type and shape.</p></div></div></div></div><divid="footer"><p>Produced by <ahref="http://www.haskell.org/haddock/">Haddock</a> version 2.16.1</p></div></body></html>