mirror of
https://github.com/tensorflow/haskell.git
synced 2024-12-28 12:39:46 +01:00
6b19e54722
* Update README to refer to 2.3.0-gpu. * Remove old package documentation from haddock directory.
12 lines
No EOL
5.9 KiB
HTML
12 lines
No EOL
5.9 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1" /><title>TensorFlow.NN</title><link href="linuwial.css" rel="stylesheet" type="text/css" title="Linuwial" /><link rel="stylesheet" type="text/css" href="quick-jump.css" /><link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=PT+Sans:400,400i,700" /><script src="haddock-bundle.min.js" async="async" type="text/javascript"></script><script type="text/x-mathjax-config">MathJax.Hub.Config({ tex2jax: { processClass: "mathjax", ignoreClass: ".*" } });</script><script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script></head><body><div id="package-header"><span class="caption">tensorflow-ops-0.3.0.0: Friendly layer around TensorFlow bindings.</span><ul class="links" id="page-menu"><li><a href="src/TensorFlow.NN.html">Source</a></li><li><a href="index.html">Contents</a></li><li><a href="doc-index.html">Index</a></li></ul></div><div id="content"><div id="module-header"><table class="info"><tr><th>Safe Haskell</th><td>None</td></tr><tr><th>Language</th><td>Haskell2010</td></tr></table><p class="caption">TensorFlow.NN</p></div><div id="synopsis"><details id="syn"><summary>Synopsis</summary><ul class="details-toggle" data-details-id="syn"><li class="src short"><a href="#v:sigmoidCrossEntropyWithLogits">sigmoidCrossEntropyWithLogits</a> :: (<a href="../tensorflow-0.3.0.0/TensorFlow-Build.html#t:MonadBuild" title="TensorFlow.Build">MonadBuild</a> m, <a href="../tensorflow-0.3.0.0/TensorFlow-Types.html#t:OneOf" title="TensorFlow.Types">OneOf</a> '[<a href="../base-4.13.0.0/Prelude.html#t:Float" title="Prelude">Float</a>, <a href="../base-4.13.0.0/Prelude.html#t:Double" title="Prelude">Double</a>] a, <a href="../tensorflow-0.3.0.0/TensorFlow-Types.html#t:TensorType" title="TensorFlow.Types">TensorType</a> a, <a href="../base-4.13.0.0/Prelude.html#t:Num" title="Prelude">Num</a> a) => <a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Tensor" title="TensorFlow.Tensor">Tensor</a> <a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Value" title="TensorFlow.Tensor">Value</a> a -> <a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Tensor" title="TensorFlow.Tensor">Tensor</a> <a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Value" title="TensorFlow.Tensor">Value</a> a -> m (<a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Tensor" title="TensorFlow.Tensor">Tensor</a> <a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Value" title="TensorFlow.Tensor">Value</a> a)</li></ul></details></div><div id="interface"><h1>Documentation</h1><div class="top"><p class="src"><a id="v:sigmoidCrossEntropyWithLogits" class="def">sigmoidCrossEntropyWithLogits</a> <a href="src/TensorFlow.NN.html#sigmoidCrossEntropyWithLogits" class="link">Source</a> <a href="#v:sigmoidCrossEntropyWithLogits" class="selflink">#</a></p><div class="subs arguments"><p class="caption">Arguments</p><table><tr><td class="src">:: (<a href="../tensorflow-0.3.0.0/TensorFlow-Build.html#t:MonadBuild" title="TensorFlow.Build">MonadBuild</a> m, <a href="../tensorflow-0.3.0.0/TensorFlow-Types.html#t:OneOf" title="TensorFlow.Types">OneOf</a> '[<a href="../base-4.13.0.0/Prelude.html#t:Float" title="Prelude">Float</a>, <a href="../base-4.13.0.0/Prelude.html#t:Double" title="Prelude">Double</a>] a, <a href="../tensorflow-0.3.0.0/TensorFlow-Types.html#t:TensorType" title="TensorFlow.Types">TensorType</a> a, <a href="../base-4.13.0.0/Prelude.html#t:Num" title="Prelude">Num</a> a)</td><td class="doc empty"> </td></tr><tr><td class="src">=> <a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Tensor" title="TensorFlow.Tensor">Tensor</a> <a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Value" title="TensorFlow.Tensor">Value</a> a</td><td class="doc"><p><strong>logits</strong></p></td></tr><tr><td class="src">-> <a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Tensor" title="TensorFlow.Tensor">Tensor</a> <a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Value" title="TensorFlow.Tensor">Value</a> a</td><td class="doc"><p><strong>targets</strong></p></td></tr><tr><td class="src">-> m (<a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Tensor" title="TensorFlow.Tensor">Tensor</a> <a href="../tensorflow-0.3.0.0/TensorFlow-Tensor.html#t:Value" title="TensorFlow.Tensor">Value</a> a)</td><td class="doc empty"> </td></tr></table></div><div class="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))
|
|
= z * -log(1 <em> (1 + exp(-x))) + (1 - z) * -log(exp(-x) </em> (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))</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><div id="footer"><p>Produced by <a href="http://www.haskell.org/haddock/">Haddock</a> version 2.23.0</p></div></body></html> |