mirror of
https://github.com/tensorflow/haskell.git
synced 2024-12-29 04:59:46 +01:00
6b19e54722
* Update README to refer to 2.3.0-gpu. * Remove old package documentation from haddock directory.
5069 lines
No EOL
662 KiB
HTML
5069 lines
No EOL
662 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><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-- Copyright 2016 TensorFlow authors.</span><span>
|
|
</span><span id="line-2"></span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-3"></span><span class="hs-comment">-- Licensed under the Apache License, Version 2.0 (the "License");</span><span>
|
|
</span><span id="line-4"></span><span class="hs-comment">-- you may not use this file except in compliance with the License.</span><span>
|
|
</span><span id="line-5"></span><span class="hs-comment">-- You may obtain a copy of the License at</span><span>
|
|
</span><span id="line-6"></span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-7"></span><span class="hs-comment">-- http://www.apache.org/licenses/LICENSE-2.0</span><span>
|
|
</span><span id="line-8"></span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-9"></span><span class="hs-comment">-- Unless required by applicable law or agreed to in writing, software</span><span>
|
|
</span><span id="line-10"></span><span class="hs-comment">-- distributed under the License is distributed on an "AS IS" BASIS,</span><span>
|
|
</span><span id="line-11"></span><span class="hs-comment">-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span><span>
|
|
</span><span id="line-12"></span><span class="hs-comment">-- See the License for the specific language governing permissions and</span><span>
|
|
</span><span id="line-13"></span><span class="hs-comment">-- limitations under the License.</span><span>
|
|
</span><span id="line-14"></span><span>
|
|
</span><span id="line-15"></span><span class="hs-pragma">{-# LANGUAGE ConstraintKinds #-}</span><span>
|
|
</span><span id="line-16"></span><span class="hs-pragma">{-# LANGUAGE DataKinds #-}</span><span>
|
|
</span><span id="line-17"></span><span class="hs-pragma">{-# LANGUAGE FlexibleContexts #-}</span><span>
|
|
</span><span id="line-18"></span><span class="hs-pragma">{-# LANGUAGE OverloadedStrings #-}</span><span>
|
|
</span><span id="line-19"></span><span class="hs-pragma">{-# LANGUAGE RankNTypes #-}</span><span>
|
|
</span><span id="line-20"></span><span class="hs-pragma">{-# LANGUAGE ScopedTypeVariables #-}</span><span>
|
|
</span><span id="line-21"></span><span class="hs-pragma">{-# LANGUAGE TypeFamilies #-}</span><span>
|
|
</span><span id="line-22"></span><span class="hs-pragma">{-# LANGUAGE ViewPatterns #-}</span><span>
|
|
</span><span id="line-23"></span><span class="hs-pragma">{-# LANGUAGE TypeApplications #-}</span><span>
|
|
</span><span id="line-24"></span><span>
|
|
</span><span id="line-25"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">TensorFlow.Gradient</span><span>
|
|
</span><span id="line-26"></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientCompatible"><span class="hs-identifier">GradientCompatible</span></a></span><span>
|
|
</span><span id="line-27"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#gradients"><span class="hs-identifier">gradients</span></a></span><span>
|
|
</span><span id="line-28"></span><span> </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-29"></span><span>
|
|
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Control.Monad</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">forM</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">zipWithM</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Control.Monad.State.Strict</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">State</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">evalState</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">gets</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">modify</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.ByteString</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">ByteString</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.Complex</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">Complex</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.ProtoLens.Default</span></span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">def</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.Int</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">Int32</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">Int64</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.Foldable</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">foldlM</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.List</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">foldl'</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">sortBy</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.Map.Strict</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">Map</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><span class="hs-identifier">Data.IntSet</span></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">IntSet</span></span><span>
|
|
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.Maybe</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">fromMaybe</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">maybeToList</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">mapMaybe</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.Ord</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">comparing</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.ProtoLens.TextFormat</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">showMessage</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.Set</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">Set</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.Text</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">Text</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Data.Tuple</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">swap</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Lens.Family2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">Lens'</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">view</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-operator">(&)</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-operator">(^.)</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-operator">(.~)</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-operator">(%~)</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">under</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Lens.Family2.State.Strict</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">uses</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Lens.Family2.Stock</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">at</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">intAt</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Lens.Family2.Unchecked</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">lens</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">adapter</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Prelude</span></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">sum</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">tanh</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Text.Printf</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">printf</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><span class="hs-identifier">Data.Graph.Inductive.Basic</span></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">FGL</span></span><span>
|
|
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><span class="hs-identifier">Data.Graph.Inductive.Graph</span></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">FGL</span></span><span>
|
|
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><span class="hs-identifier">Data.Graph.Inductive.PatriciaTree</span></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">FGL</span></span><span>
|
|
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><span class="hs-identifier">Data.Graph.Inductive.Query.DFS</span></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">FGL</span></span><span>
|
|
</span><span id="line-56"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><span class="hs-identifier">Data.IntMap.Strict</span></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">IntMap</span></span><span>
|
|
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><span class="hs-identifier">Data.Map.Strict</span></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Map</span></span><span>
|
|
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><span class="hs-identifier">Data.Set</span></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Set</span></span><span>
|
|
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><span class="hs-identifier">Data.Text</span></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Text</span></span><span>
|
|
</span><span id="line-60"></span><span>
|
|
</span><span id="line-61"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><span class="hs-identifier">TensorFlow.GenOps.Core</span></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">CoreOps</span></span><span>
|
|
</span><span id="line-62"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">TensorFlow.Build</span></span><span>
|
|
</span><span id="line-63"></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier">MonadBuild</span></span><span>
|
|
</span><span id="line-64"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">Build</span></span><span>
|
|
</span><span id="line-65"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">build</span></span><span>
|
|
</span><span id="line-66"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">renderedNodeDefs</span></span><span>
|
|
</span><span id="line-67"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">opDef</span></span><span>
|
|
</span><span id="line-68"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">opAttr</span></span><span>
|
|
</span><span id="line-69"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">opInputs</span></span><span>
|
|
</span><span id="line-70"></span><span> </span><span class="hs-special">)</span><span>
|
|
</span><span id="line-71"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">TensorFlow.BuildOp</span></span><span>
|
|
</span><span id="line-72"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="TensorFlow.Ops.html"><span class="hs-identifier">TensorFlow.Ops</span></a></span><span>
|
|
</span><span id="line-73"></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier">addN</span></span><span>
|
|
</span><span id="line-74"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">broadcastGradientArgs</span></span><span>
|
|
</span><span id="line-75"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="TensorFlow.Ops.html#expandDims"><span class="hs-identifier">expandDims</span></a></span><span>
|
|
</span><span id="line-76"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">fill</span></span><span>
|
|
</span><span id="line-77"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">matMul</span></span><span>
|
|
</span><span id="line-78"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">matMul'</span></span><span>
|
|
</span><span id="line-79"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="TensorFlow.Ops.html#reducedShape"><span class="hs-identifier">reducedShape</span></a></span><span>
|
|
</span><span id="line-80"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">reluGrad</span></span><span>
|
|
</span><span id="line-81"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">tanh</span></span><span>
|
|
</span><span id="line-82"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">tanhGrad</span></span><span>
|
|
</span><span id="line-83"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">reshape</span></span><span>
|
|
</span><span id="line-84"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="TensorFlow.Ops.html#scalar"><span class="hs-identifier">scalar</span></a></span><span>
|
|
</span><span id="line-85"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier">shape</span></a></span><span>
|
|
</span><span id="line-86"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">softmaxCrossEntropyWithLogits</span></span><span>
|
|
</span><span id="line-87"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">sum</span></span><span>
|
|
</span><span id="line-88"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">sigmoid</span></span><span>
|
|
</span><span id="line-89"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">sigmoidGrad</span></span><span>
|
|
</span><span id="line-90"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="TensorFlow.Ops.html#scalarize"><span class="hs-identifier">scalarize</span></a></span><span>
|
|
</span><span id="line-91"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="TensorFlow.Ops.html#vector"><span class="hs-identifier">vector</span></a></span><span>
|
|
</span><span id="line-92"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">zerosLike</span></span><span>
|
|
</span><span id="line-93"></span><span> </span><span class="hs-special">)</span><span>
|
|
</span><span id="line-94"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">TensorFlow.Output</span></span><span>
|
|
</span><span id="line-95"></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier">NodeName</span></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-96"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">Output</span></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-97"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">OutputIx</span></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-98"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">outputIndex</span></span><span>
|
|
</span><span id="line-99"></span><span> </span><span class="hs-special">)</span><span>
|
|
</span><span id="line-100"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">TensorFlow.Tensor</span></span><span>
|
|
</span><span id="line-101"></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier">Tensor</span></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-102"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">Value</span></span><span>
|
|
</span><span id="line-103"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">render</span></span><span>
|
|
</span><span id="line-104"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">expr</span></span><span>
|
|
</span><span id="line-105"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">Rendered</span></span><span>
|
|
</span><span id="line-106"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">tensorNodeName</span></span><span>
|
|
</span><span id="line-107"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">renderedOutput</span></span><span>
|
|
</span><span id="line-108"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">renderValue</span></span><span>
|
|
</span><span id="line-109"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">ToTensor</span></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-110"></span><span> </span><span class="hs-special">)</span><span>
|
|
</span><span id="line-111"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">TensorFlow.Types</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">Attribute</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">OneOf</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">TensorType</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">attrLens</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-112"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Proto.Tensorflow.Core.Framework.NodeDef</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier">NodeDef</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-113"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><span class="hs-identifier">Proto.Tensorflow.Core.Framework.NodeDef_Fields</span></span><span>
|
|
</span><span id="line-114"></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier">attr</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">input</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">op</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier">name</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-115"></span><span>
|
|
</span><span id="line-116"></span><span class="hs-keyword">type</span><span> </span><span id="GradientCompatible"><span class="annot"><a href="TensorFlow.Gradient.html#GradientCompatible"><span class="hs-identifier hs-var">GradientCompatible</span></a></span></span><span> </span><span id="local-6989586621679156923"><span class="annot"><a href="#local-6989586621679156923"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-117"></span><span> </span><span class="hs-comment">-- TODO(fmayle): MaxPoolGrad doesn't support Double for some reason.</span><span>
|
|
</span><span id="line-118"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Num</span></span><span> </span><span class="annot"><a href="#local-6989586621679156923"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">OneOf</span></span><span> </span><span class="hs-special">'</span><span class="hs-special">[</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Float</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Complex</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Float</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Complex</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span> </span><span class="hs-special">]</span><span> </span><span class="annot"><a href="#local-6989586621679156923"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-119"></span><span>
|
|
</span><span id="line-120"></span><span class="hs-comment">-- TODO(fmayle): Support control flow.</span><span>
|
|
</span><span id="line-121"></span><span class="hs-comment">-- TODO(fmayle): Support gate_gradients-like option to avoid race conditions.</span><span>
|
|
</span><span id="line-122"></span><span class="hs-comment">-- TODO(fmayle): Do we need to consider control inputs? See _PendingCount in</span><span>
|
|
</span><span id="line-123"></span><span class="hs-comment">-- tensorflow/python/ops/gradients.py.</span><span>
|
|
</span><span id="line-124"></span><span class="hs-comment">-- TODO(fmayle): Maybe store the gradient functions and numOutputs on the OpDef.</span><span>
|
|
</span><span id="line-125"></span><span>
|
|
</span><span id="line-126"></span><span>
|
|
</span><span id="line-127"></span><span class="hs-comment">-- | Gradient of @y@ w.r.t. each element of @xs@.</span><span>
|
|
</span><span id="line-128"></span><span class="annot"><a href="TensorFlow.Gradient.html#gradients"><span class="hs-identifier hs-type">gradients</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679156922"><span class="annot"><a href="#local-6989586621679156922"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span id="local-6989586621679156921"><span class="annot"><a href="#local-6989586621679156921"><span class="hs-identifier hs-type">v1</span></a></span></span><span> </span><span id="local-6989586621679156920"><span class="annot"><a href="#local-6989586621679156920"><span class="hs-identifier hs-type">t</span></a></span></span><span> </span><span id="local-6989586621679156919"><span class="annot"><a href="#local-6989586621679156919"><span class="hs-identifier hs-type">m</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier hs-type">MonadBuild</span></span><span> </span><span class="annot"><a href="#local-6989586621679156919"><span class="hs-identifier hs-type">m</span></a></span><span>
|
|
</span><span id="line-129"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Rendered</span></span><span> </span><span class="annot"><a href="#local-6989586621679156920"><span class="hs-identifier hs-type">t</span></a></span><span>
|
|
</span><span id="line-130"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ToTensor</span></span><span> </span><span class="annot"><a href="#local-6989586621679156920"><span class="hs-identifier hs-type">t</span></a></span><span>
|
|
</span><span id="line-131"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientCompatible"><span class="hs-identifier hs-type">GradientCompatible</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679156922"><span class="hs-identifier hs-type">a</span></a></span><span>
|
|
</span><span id="line-132"></span><span> </span><span class="hs-special">)</span><span>
|
|
</span><span id="line-133"></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><a href="#local-6989586621679156921"><span class="hs-identifier hs-type">v1</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679156922"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-comment">-- ^ The output of the graph.</span><span>
|
|
</span><span id="line-134"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679156920"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679156922"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-comment">-- ^ Tensors for which gradients are computed.</span><span>
|
|
</span><span id="line-135"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><a href="#local-6989586621679156919"><span class="hs-identifier hs-type">m</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Value</span></span><span> </span><span class="annot"><a href="#local-6989586621679156922"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-136"></span><span id="gradients"><span class="annot"><span class="annottext">gradients :: Tensor v1 a -> [t a] -> m [Tensor Value a]
|
|
</span><a href="TensorFlow.Gradient.html#gradients"><span class="hs-identifier hs-var hs-var">gradients</span></a></span></span><span> </span><span id="local-6989586621679156918"><span class="annot"><span class="annottext">y :: Tensor v1 a
|
|
</span><a href="#local-6989586621679156918"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span id="local-6989586621679156917"><span class="annot"><span class="annottext">xs :: [t a]
|
|
</span><a href="#local-6989586621679156917"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Build [Tensor Value a] -> m [Tensor Value a]
|
|
forall (m :: * -> *) a. MonadBuild m => Build a -> m a
|
|
</span><span class="hs-identifier hs-var">build</span></span><span> </span><span class="annot"><span class="annottext">(Build [Tensor Value a] -> m [Tensor Value a])
|
|
-> Build [Tensor Value a] -> m [Tensor Value a]
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="hs-keyword">do</span><span>
|
|
</span><span id="line-137"></span><span> </span><span class="hs-comment">-- The gradients are computed using "reverse accumulation", similarly to</span><span>
|
|
</span><span id="line-138"></span><span> </span><span class="hs-comment">-- what is described here:</span><span>
|
|
</span><span id="line-139"></span><span> </span><span class="hs-comment">-- https://en.wikipedia.org/wiki/Automatic_differentiation#The_chain_rule.2C_forward_and_reverse_accumulation</span><span>
|
|
</span><span id="line-140"></span><span> </span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-141"></span><span> </span><span class="hs-comment">-- The code is summarised as follows:</span><span>
|
|
</span><span id="line-142"></span><span> </span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-143"></span><span> </span><span class="hs-comment">-- 1. Create an fgl graph of the relevant nodes (ops) and edges (tensors).</span><span>
|
|
</span><span id="line-144"></span><span> </span><span class="hs-comment">-- 2. Initialize the gradient of y to 1 (∂y/∂y = 1) and the rest of tensor's</span><span>
|
|
</span><span id="line-145"></span><span> </span><span class="hs-comment">-- gradients to nothing.</span><span>
|
|
</span><span id="line-146"></span><span> </span><span class="hs-comment">-- 3. Process the nodes in reverse topological order (i.e. each node comes</span><span>
|
|
</span><span id="line-147"></span><span> </span><span class="hs-comment">-- after all of its outputs so that the output gradients for a node have</span><span>
|
|
</span><span id="line-148"></span><span> </span><span class="hs-comment">-- been completely calculated before it is processed):</span><span>
|
|
</span><span id="line-149"></span><span> </span><span class="hs-comment">-- a. Record the gradient for each of the node's output tensors (∂y/∂w</span><span>
|
|
</span><span id="line-150"></span><span> </span><span class="hs-comment">-- for each output tensor w).</span><span>
|
|
</span><span id="line-151"></span><span> </span><span class="hs-comment">-- b. Calculate the gradient of y w.r.t. each of the node's input</span><span>
|
|
</span><span id="line-152"></span><span> </span><span class="hs-comment">-- tensors using the gradients of the node's output tensors.</span><span>
|
|
</span><span id="line-153"></span><span> </span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-154"></span><span> </span><span class="hs-comment">-- Written differently, for each output tensor w and input tensor v:</span><span>
|
|
</span><span id="line-155"></span><span> </span><span class="hs-comment">-- ∂y/∂w = ... (calculated in previous steps)</span><span>
|
|
</span><span id="line-156"></span><span> </span><span class="hs-comment">-- ∂w/∂v = ... (op specific)</span><span>
|
|
</span><span id="line-157"></span><span> </span><span class="hs-comment">-- ∂y/∂v = ∂y/∂w * ∂w/∂v (technically, if tensor v is an input</span><span>
|
|
</span><span id="line-158"></span><span> </span><span class="hs-comment">-- to multiple nodes, then this is only</span><span>
|
|
</span><span id="line-159"></span><span> </span><span class="hs-comment">-- part of ∂y/∂v)</span><span>
|
|
</span><span id="line-160"></span><span> </span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-161"></span><span> </span><span class="hs-comment">-- 4. Lookup the recorded gradient for each x in xs.</span><span>
|
|
</span><span id="line-162"></span><span>
|
|
</span><span id="line-163"></span><span> </span><span id="local-6989586621679156916"><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156916"><span class="hs-identifier hs-var">y'</span></a></span></span><span> </span><span class="hs-glyph"><-</span><span> </span><span class="annot"><span class="annottext">Tensor v1 a -> BuildT Identity (Tensor Value a)
|
|
forall (m :: * -> *) (v :: * -> *) a.
|
|
MonadBuild m =>
|
|
Tensor v a -> m (Tensor Value a)
|
|
</span><span class="hs-identifier hs-var">renderValue</span></span><span> </span><span class="annot"><span class="annottext">Tensor v1 a
|
|
</span><a href="#local-6989586621679156918"><span class="hs-identifier hs-var">y</span></a></span><span>
|
|
</span><span id="line-164"></span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679156915"><span class="annot"><span class="annottext">yName :: NodeName
|
|
</span><a href="#local-6989586621679156915"><span class="hs-identifier hs-var hs-var">yName</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> NodeName
|
|
forall (t :: * -> *) a. Rendered t => t a -> NodeName
|
|
</span><span class="hs-identifier hs-var">tensorNodeName</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156916"><span class="hs-identifier hs-var">y'</span></a></span><span>
|
|
</span><span id="line-165"></span><span> </span><span id="local-6989586621679156914"><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156914"><span class="hs-identifier hs-var">yOne</span></a></span></span><span> </span><span class="hs-glyph"><-</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> BuildT Identity (Tensor Value a)
|
|
forall (m :: * -> *) a.
|
|
MonadBuild m =>
|
|
Tensor Build a -> m (Tensor Value a)
|
|
</span><span class="hs-identifier hs-var">render</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> BuildT Identity (Tensor Value a))
|
|
-> Tensor Build a -> BuildT Identity (Tensor Value a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t index_type.
|
|
(TensorType t, OneOf '[Int32, Int64] index_type) =>
|
|
Tensor v'1 index_type -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">fill</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156916"><span class="hs-identifier hs-var">y'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -> Tensor Build a
|
|
forall a. TensorType a => a -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#scalar"><span class="hs-identifier hs-var">scalar</span></a></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-166"></span><span> </span><span class="hs-comment">-- TODO(fmayle): Move this into Build.hs and call it unsafeNodeDefFromName?</span><span>
|
|
</span><span id="line-167"></span><span> </span><span id="local-6989586621679156913"><span class="annot"><span class="annottext">NodeName -> NodeDef
|
|
</span><a href="#local-6989586621679156913"><span class="hs-identifier hs-var">nodeDefLookup</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeDef</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph"><-</span><span> </span><span class="annot"><span class="annottext">FoldLike
|
|
(NodeName -> NodeDef)
|
|
GraphState
|
|
GraphState
|
|
(Map NodeName NodeDef)
|
|
(Map NodeName NodeDef)
|
|
-> (Map NodeName NodeDef -> NodeName -> NodeDef)
|
|
-> BuildT Identity (NodeName -> NodeDef)
|
|
forall s (m :: * -> *) r t a b.
|
|
MonadState s m =>
|
|
FoldLike r s t a b -> (a -> r) -> m r
|
|
</span><span class="hs-identifier hs-var">uses</span></span><span> </span><span class="annot"><span class="annottext">FoldLike
|
|
(NodeName -> NodeDef)
|
|
GraphState
|
|
GraphState
|
|
(Map NodeName NodeDef)
|
|
(Map NodeName NodeDef)
|
|
Lens' GraphState (Map NodeName NodeDef)
|
|
</span><span class="hs-identifier hs-var">renderedNodeDefs</span></span><span> </span><span class="annot"><span class="annottext">((Map NodeName NodeDef -> NodeName -> NodeDef)
|
|
-> BuildT Identity (NodeName -> NodeDef))
|
|
-> (Map NodeName NodeDef -> NodeName -> NodeDef)
|
|
-> BuildT Identity (NodeName -> NodeDef)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span>
|
|
</span><span id="line-168"></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679156912"><span class="annot"><span class="annottext">f :: NodeName -> Maybe NodeDef
|
|
</span><a href="#local-6989586621679156912"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679156911"><span class="annot"><span class="annottext">x :: NodeName
|
|
</span><a href="#local-6989586621679156911"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="annottext">NodeDef -> Maybe NodeDef -> NodeDef
|
|
forall a. a -> Maybe a -> a
|
|
</span><span class="hs-identifier hs-var">fromMaybe</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Char] -> NodeDef
|
|
forall a. HasCallStack => [Char] -> a
|
|
</span><span class="hs-identifier hs-var">error</span></span><span> </span><span class="annot"><span class="annottext">([Char] -> NodeDef) -> [Char] -> NodeDef
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="hs-string">"no NodeDef found for "</span></span><span> </span><span class="annot"><span class="annottext">[Char] -> [Char] -> [Char]
|
|
forall a. [a] -> [a] -> [a]
|
|
</span><span class="hs-operator hs-var">++</span></span><span> </span><span class="annot"><span class="annottext">NodeName -> [Char]
|
|
forall a. Show a => a -> [Char]
|
|
</span><span class="hs-identifier hs-var">show</span></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156911"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeName -> Maybe NodeDef
|
|
</span><a href="#local-6989586621679156912"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156911"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-169"></span><span> </span><span class="annot"><span class="annottext">((NodeName -> Maybe NodeDef) -> NodeName -> NodeDef)
|
|
-> (Map NodeName NodeDef -> NodeName -> Maybe NodeDef)
|
|
-> Map NodeName NodeDef
|
|
-> NodeName
|
|
-> NodeDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">(NodeName -> Map NodeName NodeDef -> Maybe NodeDef)
|
|
-> Map NodeName NodeDef -> NodeName -> Maybe NodeDef
|
|
forall a b c. (a -> b -> c) -> b -> a -> c
|
|
</span><span class="hs-identifier hs-var">flip</span></span><span> </span><span class="annot"><span class="annottext">NodeName -> Map NodeName NodeDef -> Maybe NodeDef
|
|
forall k a. Ord k => k -> Map k a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Map.lookup</span></span><span>
|
|
</span><span id="line-170"></span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156905"><span class="annot"><span class="annottext">gr :: Graph
|
|
</span><a href="#local-6989586621679156905"><span class="hs-identifier hs-var">gr</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156904"><span class="annot"><span class="annottext">nodeMap :: Map NodeName Node
|
|
</span><a href="#local-6989586621679156904"><span class="hs-identifier hs-var">nodeMap</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeName -> (NodeName -> NodeDef) -> (Graph, Map NodeName Node)
|
|
</span><a href="TensorFlow.Gradient.html#createGraph"><span class="hs-identifier hs-var">createGraph</span></a></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156915"><span class="hs-identifier hs-var">yName</span></a></span><span> </span><span class="annot"><span class="annottext">NodeName -> NodeDef
|
|
</span><a href="#local-6989586621679156913"><span class="hs-identifier hs-var">nodeDefLookup</span></a></span><span>
|
|
</span><span id="line-171"></span><span> </span><span id="local-6989586621679156902"><span class="annot"><span class="annottext">xnodes :: [Node]
|
|
</span><a href="#local-6989586621679156902"><span class="hs-identifier hs-var hs-var">xnodes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(t a -> Maybe Node) -> [t a] -> [Node]
|
|
forall a b. (a -> Maybe b) -> [a] -> [b]
|
|
</span><span class="hs-identifier hs-var">mapMaybe</span></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679156901"><span class="annot"><span class="annottext">x :: t a
|
|
</span><a href="#local-6989586621679156901"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="annottext">Map NodeName Node
|
|
</span><a href="#local-6989586621679156904"><span class="hs-identifier hs-var">nodeMap</span></a></span><span> </span><span class="annot"><span class="annottext">Map NodeName Node
|
|
-> FoldLike
|
|
(Maybe Node)
|
|
(Map NodeName Node)
|
|
(Map NodeName Node)
|
|
(Maybe Node)
|
|
(Maybe Node)
|
|
-> Maybe Node
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeName
|
|
-> FoldLike
|
|
(Maybe Node)
|
|
(Map NodeName Node)
|
|
(Map NodeName Node)
|
|
(Maybe Node)
|
|
(Maybe Node)
|
|
forall k v. Ord k => k -> Lens' (Map k v) (Maybe v)
|
|
</span><span class="hs-identifier hs-var">at</span></span><span> </span><span class="annot"><span class="annottext">(NodeName
|
|
-> FoldLike
|
|
(Maybe Node)
|
|
(Map NodeName Node)
|
|
(Map NodeName Node)
|
|
(Maybe Node)
|
|
(Maybe Node))
|
|
-> (t a -> NodeName)
|
|
-> t a
|
|
-> FoldLike
|
|
(Maybe Node)
|
|
(Map NodeName Node)
|
|
(Map NodeName Node)
|
|
(Maybe Node)
|
|
(Maybe Node)
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">Output -> NodeName
|
|
</span><span class="hs-identifier hs-var hs-var">outputNodeName</span></span><span> </span><span class="annot"><span class="annottext">(Output -> NodeName) -> (t a -> Output) -> t a -> NodeName
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">t a -> Output
|
|
forall (t :: * -> *) a. Rendered t => t a -> Output
|
|
</span><span class="hs-identifier hs-var">renderedOutput</span></span><span> </span><span class="annot"><span class="annottext">(t a
|
|
-> FoldLike
|
|
(Maybe Node)
|
|
(Map NodeName Node)
|
|
(Map NodeName Node)
|
|
(Maybe Node)
|
|
(Maybe Node))
|
|
-> t a
|
|
-> FoldLike
|
|
(Maybe Node)
|
|
(Map NodeName Node)
|
|
(Map NodeName Node)
|
|
(Maybe Node)
|
|
(Maybe Node)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">t a
|
|
</span><a href="#local-6989586621679156901"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[t a]
|
|
</span><a href="#local-6989586621679156917"><span class="hs-identifier hs-var">xs</span></a></span><span>
|
|
</span><span id="line-172"></span><span> </span><span class="hs-comment">-- make a set of the nodes reachable from the xnodes</span><span>
|
|
</span><span id="line-173"></span><span> </span><span class="hs-comment">-- The xnodes are not part of this set (unless reachable from another xnode)</span><span>
|
|
</span><span id="line-174"></span><span> </span><span id="local-6989586621679156899"><span class="annot"><span class="annottext">reachableSet :: IntSet
|
|
</span><a href="#local-6989586621679156899"><span class="hs-identifier hs-var hs-var">reachableSet</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Node] -> Graph -> IntSet
|
|
</span><a href="TensorFlow.Gradient.html#computeReachableSet"><span class="hs-identifier hs-var">computeReachableSet</span></a></span><span> </span><span class="annot"><span class="annottext">[Node]
|
|
</span><a href="#local-6989586621679156902"><span class="hs-identifier hs-var">xnodes</span></a></span><span> </span><span class="annot"><span class="annottext">Graph
|
|
</span><a href="#local-6989586621679156905"><span class="hs-identifier hs-var">gr</span></a></span><span>
|
|
</span><span id="line-175"></span><span>
|
|
</span><span id="line-176"></span><span> </span><span class="hs-comment">-- Set gradient of y to one.</span><span>
|
|
</span><span id="line-177"></span><span> </span><span class="hs-comment">-- TODO: nicer</span><span>
|
|
</span><span id="line-178"></span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679156897"><span class="annot"><span class="annottext">Map Node (PendingGradients a)
|
|
</span><a href="#local-6989586621679156897"><span class="hs-identifier hs-var">initPending</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Map.Map</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Node</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#PendingGradients"><span class="hs-identifier hs-type">PendingGradients</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679156922"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-179"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Map Node (PendingGradients a)
|
|
forall k a. Map k a
|
|
</span><span class="hs-identifier hs-var">Map.empty</span></span><span> </span><span class="annot"><span class="annottext">Map Node (PendingGradients a)
|
|
-> (Map Node (PendingGradients a) -> Map Node (PendingGradients a))
|
|
-> Map Node (PendingGradients a)
|
|
forall s t. s -> (s -> t) -> t
|
|
</span><span class="hs-operator hs-var">&</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node
|
|
-> Lens'
|
|
(Map Node (PendingGradients a)) (Maybe (PendingGradients a))
|
|
forall k v. Ord k => k -> Lens' (Map k v) (Maybe v)
|
|
</span><span class="hs-identifier hs-var">at</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map NodeName Node
|
|
</span><a href="#local-6989586621679156904"><span class="hs-identifier hs-var">nodeMap</span></a></span><span> </span><span class="annot"><span class="annottext">Map NodeName Node -> NodeName -> Node
|
|
forall k a. Ord k => Map k a -> k -> a
|
|
</span><span class="hs-operator hs-var">Map.!</span></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156915"><span class="hs-identifier hs-var">yName</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-180"></span><span> </span><span class="annot"><span class="annottext">LensLike'
|
|
f (Map Node (PendingGradients a)) (Maybe (PendingGradients a))
|
|
-> (([Tensor Value a] -> f [Tensor Value a])
|
|
-> Maybe (PendingGradients a) -> f (Maybe (PendingGradients a)))
|
|
-> ([Tensor Value a] -> f [Tensor Value a])
|
|
-> Map Node (PendingGradients a)
|
|
-> f (Map Node (PendingGradients a))
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">LensLike' f (Maybe (PendingGradients a)) (PendingGradients a)
|
|
forall (t :: * -> *) v.
|
|
(Monoid (t v), Foldable t) =>
|
|
Lens' (Maybe (t v)) (t v)
|
|
</span><a href="TensorFlow.Gradient.html#nonEmpty"><span class="hs-identifier hs-var">nonEmpty</span></a></span><span>
|
|
</span><span id="line-181"></span><span> </span><span class="annot"><span class="annottext">LensLike' f (Maybe (PendingGradients a)) (PendingGradients a)
|
|
-> (([Tensor Value a] -> f [Tensor Value a])
|
|
-> PendingGradients a -> f (PendingGradients a))
|
|
-> ([Tensor Value a] -> f [Tensor Value a])
|
|
-> Maybe (PendingGradients a)
|
|
-> f (Maybe (PendingGradients a))
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">OutputIx -> Lens' (PendingGradients a) (Maybe [Tensor Value a])
|
|
forall v. OutputIx -> Lens' (IntMap v) (Maybe v)
|
|
</span><a href="TensorFlow.Gradient.html#outputIxAt"><span class="hs-identifier hs-var">outputIxAt</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Output -> OutputIx
|
|
</span><span class="hs-identifier hs-var hs-var">outputIndex</span></span><span> </span><span class="annot"><span class="annottext">(Output -> OutputIx) -> Output -> OutputIx
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Output
|
|
forall (t :: * -> *) a. Rendered t => t a -> Output
|
|
</span><span class="hs-identifier hs-var">renderedOutput</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156916"><span class="hs-identifier hs-var">y'</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-182"></span><span> </span><span class="annot"><span class="annottext">LensLike' f (PendingGradients a) (Maybe [Tensor Value a])
|
|
-> (([Tensor Value a] -> f [Tensor Value a])
|
|
-> Maybe [Tensor Value a] -> f (Maybe [Tensor Value a]))
|
|
-> ([Tensor Value a] -> f [Tensor Value a])
|
|
-> PendingGradients a
|
|
-> f (PendingGradients a)
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">([Tensor Value a] -> f [Tensor Value a])
|
|
-> Maybe [Tensor Value a] -> f (Maybe [Tensor Value a])
|
|
forall (t :: * -> *) v.
|
|
(Monoid (t v), Foldable t) =>
|
|
Lens' (Maybe (t v)) (t v)
|
|
</span><a href="TensorFlow.Gradient.html#nonEmpty"><span class="hs-identifier hs-var">nonEmpty</span></a></span><span>
|
|
</span><span id="line-183"></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *).
|
|
Identical f =>
|
|
([Tensor Value a] -> f [Tensor Value a])
|
|
-> Map Node (PendingGradients a)
|
|
-> f (Map Node (PendingGradients a)))
|
|
-> [Tensor Value a]
|
|
-> Map Node (PendingGradients a)
|
|
-> Map Node (PendingGradients a)
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156914"><span class="hs-identifier hs-var">yOne</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-184"></span><span> </span><span class="hs-special">)</span><span>
|
|
</span><span id="line-185"></span><span> </span><span class="hs-comment">-- Calculate the gradients of y w.r.t. each node in the graph.</span><span>
|
|
</span><span id="line-186"></span><span> </span><span id="local-6989586621679156892"><span class="annot"><span class="annottext">Map Node (Gradients a)
|
|
</span><a href="#local-6989586621679156892"><span class="hs-identifier hs-var">gradientMap</span></a></span></span><span> </span><span class="hs-glyph"><-</span><span> </span><span class="annot"><span class="annottext">Graph
|
|
-> IntSet
|
|
-> Map Node (PendingGradients a)
|
|
-> Build (Map Node (Gradients a))
|
|
forall a.
|
|
GradientCompatible a =>
|
|
Graph
|
|
-> IntSet
|
|
-> Map Node (PendingGradients a)
|
|
-> Build (Map Node (Gradients a))
|
|
</span><a href="TensorFlow.Gradient.html#graphGrads"><span class="hs-identifier hs-var">graphGrads</span></a></span><span> </span><span class="annot"><span class="annottext">Graph
|
|
</span><a href="#local-6989586621679156905"><span class="hs-identifier hs-var">gr</span></a></span><span> </span><span class="annot"><span class="annottext">IntSet
|
|
</span><a href="#local-6989586621679156899"><span class="hs-identifier hs-var">reachableSet</span></a></span><span> </span><span class="annot"><span class="annottext">Map Node (PendingGradients a)
|
|
</span><a href="#local-6989586621679156897"><span class="hs-identifier hs-var">initPending</span></a></span><span>
|
|
</span><span id="line-187"></span><span> </span><span class="hs-comment">-- Lookup the gradients for each x.</span><span>
|
|
</span><span id="line-188"></span><span> </span><span class="annot"><span class="annottext">[t a]
|
|
-> (t a -> BuildT Identity (Tensor Value a))
|
|
-> Build [Tensor Value a]
|
|
forall (t :: * -> *) (m :: * -> *) a b.
|
|
(Traversable t, Monad m) =>
|
|
t a -> (a -> m b) -> m (t b)
|
|
</span><span class="hs-identifier hs-var">forM</span></span><span> </span><span class="annot"><span class="annottext">[t a]
|
|
</span><a href="#local-6989586621679156917"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">((t a -> BuildT Identity (Tensor Value a))
|
|
-> Build [Tensor Value a])
|
|
-> (t a -> BuildT Identity (Tensor Value a))
|
|
-> Build [Tensor Value a]
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679156890"><span class="annot"><span class="annottext">x :: t a
|
|
</span><a href="#local-6989586621679156890"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-></span><span>
|
|
</span><span id="line-189"></span><span> </span><span class="hs-keyword">let</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Output</span></span><span> </span><span id="local-6989586621679156888"><span class="annot"><span class="annottext">i :: OutputIx
|
|
</span><a href="#local-6989586621679156888"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span id="local-6989586621679156887"><span class="annot"><span class="annottext">xName :: NodeName
|
|
</span><a href="#local-6989586621679156887"><span class="hs-identifier hs-var">xName</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">t a -> Output
|
|
forall (t :: * -> *) a. Rendered t => t a -> Output
|
|
</span><span class="hs-identifier hs-var">renderedOutput</span></span><span> </span><span class="annot"><span class="annottext">t a
|
|
</span><a href="#local-6989586621679156890"><span class="hs-identifier hs-var">x</span></a></span><span>
|
|
</span><span id="line-190"></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">BuildT Identity (Tensor Value a)
|
|
-> (Tensor Value a -> BuildT Identity (Tensor Value a))
|
|
-> Maybe (Tensor Value a)
|
|
-> BuildT Identity (Tensor Value a)
|
|
forall b a. b -> (a -> b) -> Maybe a -> b
|
|
</span><span class="hs-identifier hs-var">maybe</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> BuildT Identity (Tensor Value a)
|
|
forall (m :: * -> *) a.
|
|
MonadBuild m =>
|
|
Tensor Build a -> m (Tensor Value a)
|
|
</span><span class="hs-identifier hs-var">render</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> BuildT Identity (Tensor Value a))
|
|
-> Tensor Build a -> BuildT Identity (Tensor Value a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">zerosLike</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Tensor Build a)
|
|
-> Tensor Build a -> Tensor Build a
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">t a -> Tensor Build a
|
|
forall (t :: * -> *) a.
|
|
(ToTensor t, TensorType a) =>
|
|
t a -> Tensor Build a
|
|
</span><span class="hs-identifier hs-var">toTensor</span></span><span> </span><span class="annot"><span class="annottext">t a
|
|
</span><a href="#local-6989586621679156890"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> BuildT Identity (Tensor Value a)
|
|
forall (m :: * -> *) a. Monad m => a -> m a
|
|
</span><span class="hs-identifier hs-var">return</span></span><span> </span><span class="annot"><span class="annottext">(Maybe (Tensor Value a) -> BuildT Identity (Tensor Value a))
|
|
-> Maybe (Tensor Value a) -> BuildT Identity (Tensor Value a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="hs-keyword">do</span><span>
|
|
</span><span id="line-191"></span><span> </span><span id="local-6989586621679156884"><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156884"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph"><-</span><span> </span><span class="annot"><span class="annottext">Map NodeName Node
|
|
</span><a href="#local-6989586621679156904"><span class="hs-identifier hs-var">nodeMap</span></a></span><span> </span><span class="annot"><span class="annottext">Map NodeName Node
|
|
-> FoldLike
|
|
(Maybe Node)
|
|
(Map NodeName Node)
|
|
(Map NodeName Node)
|
|
(Maybe Node)
|
|
(Maybe Node)
|
|
-> Maybe Node
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">NodeName -> Lens' (Map NodeName Node) (Maybe Node)
|
|
forall k v. Ord k => k -> Lens' (Map k v) (Maybe v)
|
|
</span><span class="hs-identifier hs-var">at</span></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156887"><span class="hs-identifier hs-var">xName</span></a></span><span>
|
|
</span><span id="line-192"></span><span> </span><span class="annot"><span class="annottext">Map Node (Gradients a)
|
|
</span><a href="#local-6989586621679156892"><span class="hs-identifier hs-var">gradientMap</span></a></span><span> </span><span class="annot"><span class="annottext">Map Node (Gradients a)
|
|
-> FoldLike
|
|
(Maybe (Tensor Value a))
|
|
(Map Node (Gradients a))
|
|
(Map Node (Gradients a))
|
|
(Maybe (Tensor Value a))
|
|
(Maybe (Tensor Value a))
|
|
-> Maybe (Tensor Value a)
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">Node -> Lens' (Map Node (Gradients a)) (Maybe (Gradients a))
|
|
forall k v. Ord k => k -> Lens' (Map k v) (Maybe v)
|
|
</span><span class="hs-identifier hs-var">at</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156884"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">LensLike'
|
|
(Constant (Maybe (Tensor Value a)))
|
|
(Map Node (Gradients a))
|
|
(Maybe (Gradients a))
|
|
-> ((Maybe (Tensor Value a)
|
|
-> Constant (Maybe (Tensor Value a)) (Maybe (Tensor Value a)))
|
|
-> Maybe (Gradients a)
|
|
-> Constant (Maybe (Tensor Value a)) (Maybe (Gradients a)))
|
|
-> FoldLike
|
|
(Maybe (Tensor Value a))
|
|
(Map Node (Gradients a))
|
|
(Map Node (Gradients a))
|
|
(Maybe (Tensor Value a))
|
|
(Maybe (Tensor Value a))
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">LensLike'
|
|
(Constant (Maybe (Tensor Value a)))
|
|
(Maybe (Gradients a))
|
|
(Gradients a)
|
|
forall (t :: * -> *) v.
|
|
(Monoid (t v), Foldable t) =>
|
|
Lens' (Maybe (t v)) (t v)
|
|
</span><a href="TensorFlow.Gradient.html#nonEmpty"><span class="hs-identifier hs-var">nonEmpty</span></a></span><span> </span><span class="annot"><span class="annottext">LensLike'
|
|
(Constant (Maybe (Tensor Value a)))
|
|
(Maybe (Gradients a))
|
|
(Gradients a)
|
|
-> ((Maybe (Tensor Value a)
|
|
-> Constant (Maybe (Tensor Value a)) (Maybe (Tensor Value a)))
|
|
-> Gradients a -> Constant (Maybe (Tensor Value a)) (Gradients a))
|
|
-> (Maybe (Tensor Value a)
|
|
-> Constant (Maybe (Tensor Value a)) (Maybe (Tensor Value a)))
|
|
-> Maybe (Gradients a)
|
|
-> Constant (Maybe (Tensor Value a)) (Maybe (Gradients a))
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">OutputIx -> Lens' (Gradients a) (Maybe (Tensor Value a))
|
|
forall v. OutputIx -> Lens' (IntMap v) (Maybe v)
|
|
</span><a href="TensorFlow.Gradient.html#outputIxAt"><span class="hs-identifier hs-var">outputIxAt</span></a></span><span> </span><span class="annot"><span class="annottext">OutputIx
|
|
</span><a href="#local-6989586621679156888"><span class="hs-identifier hs-var">i</span></a></span><span>
|
|
</span><span id="line-193"></span><span>
|
|
</span><span id="line-194"></span><span class="hs-comment">-- | Compute a set of nodes reachable from the start nodes</span><span>
|
|
</span><span id="line-195"></span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-196"></span><span class="hs-comment">-- the start nodes are excluded, unless reachable from another start node</span><span>
|
|
</span><span id="line-197"></span><span class="annot"><a href="TensorFlow.Gradient.html#computeReachableSet"><span class="hs-identifier hs-type">computeReachableSet</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">FGL.Node</span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#Graph"><span class="hs-identifier hs-type">Graph</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">IntSet.IntSet</span></span><span>
|
|
</span><span id="line-198"></span><span id="computeReachableSet"><span class="annot"><span class="annottext">computeReachableSet :: [Node] -> Graph -> IntSet
|
|
</span><a href="TensorFlow.Gradient.html#computeReachableSet"><span class="hs-identifier hs-var hs-var">computeReachableSet</span></a></span></span><span> </span><span id="local-6989586621679156883"><span class="annot"><span class="annottext">vs :: [Node]
|
|
</span><a href="#local-6989586621679156883"><span class="hs-identifier hs-var">vs</span></a></span></span><span> </span><span id="local-6989586621679156882"><span class="annot"><span class="annottext">g :: Graph
|
|
</span><a href="#local-6989586621679156882"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-199"></span><span> </span><span class="annot"><span class="annottext">[Node] -> IntSet
|
|
</span><span class="hs-identifier hs-var">IntSet.fromList</span></span><span> </span><span class="annot"><span class="annottext">([Node] -> IntSet) -> [Node] -> IntSet
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(Tree Node -> [Node]) -> [Tree Node] -> [Node]
|
|
forall (t :: * -> *) a b. Foldable t => (a -> [b]) -> t a -> [b]
|
|
</span><span class="hs-identifier hs-var">concatMap</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node -> [Node] -> [Node]
|
|
forall a. Node -> [a] -> [a]
|
|
</span><span class="hs-identifier hs-var">drop</span></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">([Node] -> [Node]) -> (Tree Node -> [Node]) -> Tree Node -> [Node]
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">Tree Node -> [Node]
|
|
forall a. Tree a -> [a]
|
|
</span><span class="hs-identifier hs-var">FGL.preorder</span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Node] -> Graph -> [Tree Node]
|
|
forall (gr :: * -> * -> *) a b.
|
|
Graph gr =>
|
|
[Node] -> gr a b -> [Tree Node]
|
|
</span><span class="hs-identifier hs-var">FGL.dff</span></span><span> </span><span class="annot"><span class="annottext">[Node]
|
|
</span><a href="#local-6989586621679156883"><span class="hs-identifier hs-var">vs</span></a></span><span> </span><span class="annot"><span class="annottext">Graph
|
|
</span><a href="#local-6989586621679156882"><span class="hs-identifier hs-var">g</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-200"></span><span>
|
|
</span><span id="line-201"></span><span id="local-6989586621679157404"><span class="annot"><a href="TensorFlow.Gradient.html#outputIxAt"><span class="hs-identifier hs-type">outputIxAt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">OutputIx</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Lens'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">IntMap.IntMap</span></span><span> </span><span class="annot"><a href="#local-6989586621679157404"><span class="hs-identifier hs-type">v</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Maybe</span></span><span> </span><span class="annot"><a href="#local-6989586621679157404"><span class="hs-identifier hs-type">v</span></a></span><span class="hs-special">)</span></span><span>
|
|
</span><span id="line-202"></span><span id="outputIxAt"><span class="annot"><span class="annottext">outputIxAt :: OutputIx -> Lens' (IntMap v) (Maybe v)
|
|
</span><a href="TensorFlow.Gradient.html#outputIxAt"><span class="hs-identifier hs-var hs-var">outputIxAt</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Node -> LensLike' f (IntMap v) (Maybe v)
|
|
forall v. Node -> Lens' (IntMap v) (Maybe v)
|
|
</span><span class="hs-identifier hs-var">intAt</span></span><span> </span><span class="annot"><span class="annottext">(Node -> LensLike' f (IntMap v) (Maybe v))
|
|
-> (OutputIx -> Node)
|
|
-> OutputIx
|
|
-> LensLike' f (IntMap v) (Maybe v)
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">OutputIx -> Node
|
|
</span><span class="hs-identifier hs-var hs-var">unOutputIx</span></span><span>
|
|
</span><span id="line-203"></span><span>
|
|
</span><span id="line-204"></span><span class="hs-comment">-- | Incomplete gradients of a node's outputs.</span><span>
|
|
</span><span id="line-205"></span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-206"></span><span class="hs-comment">-- The lists represent partial sums. The key is an OutputIx sans newtype.</span><span>
|
|
</span><span id="line-207"></span><span class="hs-keyword">type</span><span> </span><span id="PendingGradients"><span class="annot"><a href="TensorFlow.Gradient.html#PendingGradients"><span class="hs-identifier hs-var">PendingGradients</span></a></span></span><span> </span><span id="local-6989586621679156875"><span class="annot"><a href="#local-6989586621679156875"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IntMap.IntMap</span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Value</span></span><span> </span><span class="annot"><a href="#local-6989586621679156875"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-208"></span><span>
|
|
</span><span id="line-209"></span><span class="hs-comment">-- | Gradients of a node's outputs. The key is an OutputIx sans newtype.</span><span>
|
|
</span><span id="line-210"></span><span class="hs-comment">-- TODO: precache the rendering?</span><span>
|
|
</span><span id="line-211"></span><span class="hs-keyword">type</span><span> </span><span id="Gradients"><span class="annot"><a href="TensorFlow.Gradient.html#Gradients"><span class="hs-identifier hs-var">Gradients</span></a></span></span><span> </span><span id="local-6989586621679156874"><span class="annot"><a href="#local-6989586621679156874"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="hs-identifier hs-type">IntMap.IntMap</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Value</span></span><span> </span><span class="annot"><a href="#local-6989586621679156874"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-212"></span><span>
|
|
</span><span id="line-213"></span><span class="hs-comment">-- | Graph of TensorFlow operations.</span><span>
|
|
</span><span id="line-214"></span><span class="hs-keyword">type</span><span> </span><span id="Graph"><span class="annot"><a href="TensorFlow.Gradient.html#Graph"><span class="hs-identifier hs-var">Graph</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Gr</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeDef</span></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#EdgeLabel"><span class="hs-identifier hs-type">EdgeLabel</span></a></span><span>
|
|
</span><span id="line-215"></span><span>
|
|
</span><span id="line-216"></span><span class="hs-comment">-- | Data associated with an edge.</span><span>
|
|
</span><span id="line-217"></span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-218"></span><span class="hs-comment">-- Pair of</span><span>
|
|
</span><span id="line-219"></span><span class="hs-comment">-- 1. Output index of a tensor from the source node.</span><span>
|
|
</span><span id="line-220"></span><span class="hs-comment">-- 2. Input index that the tensor connects to on the destination node.</span><span>
|
|
</span><span id="line-221"></span><span class="hs-keyword">type</span><span> </span><span id="EdgeLabel"><span class="annot"><a href="TensorFlow.Gradient.html#EdgeLabel"><span class="hs-identifier hs-var">EdgeLabel</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">OutputIx</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">OutputIx</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-222"></span><span>
|
|
</span><span id="line-223"></span><span>
|
|
</span><span id="line-224"></span><span class="hs-comment">-- | State used for calculating gradients.</span><span>
|
|
</span><span id="line-225"></span><span class="hs-keyword">data</span><span> </span><span id="GradientsState"><span class="annot"><a href="TensorFlow.Gradient.html#GradientsState"><span class="hs-identifier hs-var">GradientsState</span></a></span></span><span> </span><span id="local-6989586621679157357"><span class="annot"><a href="#local-6989586621679157357"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="GradientsState"><span class="annot"><a href="TensorFlow.Gradient.html#GradientsState"><span class="hs-identifier hs-var">GradientsState</span></a></span></span><span>
|
|
</span><span id="line-226"></span><span> </span><span class="hs-special">{</span><span> </span><span id="_gradientsPending"><span class="annot"><span class="annottext">GradientsState a -> Map Node (PendingGradients a)
|
|
</span><a href="TensorFlow.Gradient.html#_gradientsPending"><span class="hs-identifier hs-var hs-var">_gradientsPending</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Map</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Node</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#PendingGradients"><span class="hs-identifier hs-type">PendingGradients</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157357"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-227"></span><span> </span><span class="hs-special">,</span><span> </span><span id="_gradientsResult"><span class="annot"><span class="annottext">GradientsState a -> Map Node (Gradients a)
|
|
</span><a href="TensorFlow.Gradient.html#_gradientsResult"><span class="hs-identifier hs-var hs-var">_gradientsResult</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Map</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Node</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#Gradients"><span class="hs-identifier hs-type">Gradients</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157357"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-228"></span><span> </span><span class="hs-special">}</span><span>
|
|
</span><span id="line-229"></span><span>
|
|
</span><span id="line-230"></span><span id="local-6989586621679157304"><span class="annot"><a href="TensorFlow.Gradient.html#gradientsPending"><span class="hs-identifier hs-type">gradientsPending</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Lens'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#GradientsState"><span class="hs-identifier hs-type">GradientsState</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157304"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Map</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Node</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#PendingGradients"><span class="hs-identifier hs-type">PendingGradients</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157304"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span><span>
|
|
</span><span id="line-231"></span><span id="gradientsPending"><span class="annot"><span class="annottext">gradientsPending :: LensLike' f (GradientsState a) (Map Node (PendingGradients a))
|
|
</span><a href="TensorFlow.Gradient.html#gradientsPending"><span class="hs-identifier hs-var hs-var">gradientsPending</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(GradientsState a -> Map Node (PendingGradients a))
|
|
-> (GradientsState a
|
|
-> Map Node (PendingGradients a) -> GradientsState a)
|
|
-> Lens
|
|
(GradientsState a)
|
|
(GradientsState a)
|
|
(Map Node (PendingGradients a))
|
|
(Map Node (PendingGradients a))
|
|
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
|
|
</span><span class="hs-identifier hs-var">lens</span></span><span> </span><span class="annot"><span class="annottext">GradientsState a -> Map Node (PendingGradients a)
|
|
forall a. GradientsState a -> Map Node (PendingGradients a)
|
|
</span><a href="TensorFlow.Gradient.html#_gradientsPending"><span class="hs-identifier hs-var hs-var">_gradientsPending</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679156869"><span class="annot"><span class="annottext">x :: GradientsState a
|
|
</span><a href="#local-6989586621679156869"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679156868"><span class="annot"><span class="annottext">y :: Map Node (PendingGradients a)
|
|
</span><a href="#local-6989586621679156868"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
</span><a href="#local-6989586621679156869"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">_gradientsPending :: Map Node (PendingGradients a)
|
|
</span><a href="TensorFlow.Gradient.html#_gradientsPending"><span class="hs-identifier hs-var">_gradientsPending</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Map Node (PendingGradients a)
|
|
</span><a href="#local-6989586621679156868"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-232"></span><span>
|
|
</span><span id="line-233"></span><span id="local-6989586621679157320"><span class="annot"><a href="TensorFlow.Gradient.html#gradientsResult"><span class="hs-identifier hs-type">gradientsResult</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Lens'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#GradientsState"><span class="hs-identifier hs-type">GradientsState</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157320"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Map</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Node</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#Gradients"><span class="hs-identifier hs-type">Gradients</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157320"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span></span><span>
|
|
</span><span id="line-234"></span><span id="gradientsResult"><span class="annot"><span class="annottext">gradientsResult :: LensLike' f (GradientsState a) (Map Node (Gradients a))
|
|
</span><a href="TensorFlow.Gradient.html#gradientsResult"><span class="hs-identifier hs-var hs-var">gradientsResult</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(GradientsState a -> Map Node (Gradients a))
|
|
-> (GradientsState a -> Map Node (Gradients a) -> GradientsState a)
|
|
-> Lens
|
|
(GradientsState a)
|
|
(GradientsState a)
|
|
(Map Node (Gradients a))
|
|
(Map Node (Gradients a))
|
|
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
|
|
</span><span class="hs-identifier hs-var">lens</span></span><span> </span><span class="annot"><span class="annottext">GradientsState a -> Map Node (Gradients a)
|
|
forall a. GradientsState a -> Map Node (Gradients a)
|
|
</span><a href="TensorFlow.Gradient.html#_gradientsResult"><span class="hs-identifier hs-var hs-var">_gradientsResult</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679156866"><span class="annot"><span class="annottext">x :: GradientsState a
|
|
</span><a href="#local-6989586621679156866"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679156865"><span class="annot"><span class="annottext">y :: Map Node (Gradients a)
|
|
</span><a href="#local-6989586621679156865"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
</span><a href="#local-6989586621679156866"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">_gradientsResult :: Map Node (Gradients a)
|
|
</span><a href="TensorFlow.Gradient.html#_gradientsResult"><span class="hs-identifier hs-var">_gradientsResult</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Map Node (Gradients a)
|
|
</span><a href="#local-6989586621679156865"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-235"></span><span>
|
|
</span><span id="line-236"></span><span>
|
|
</span><span id="line-237"></span><span class="hs-comment">-- TODO(fmayle): Use something like Data.List.Safe.</span><span>
|
|
</span><span id="line-238"></span><span class="hs-comment">-- | Safe version of (!!).</span><span>
|
|
</span><span id="line-239"></span><span id="local-6989586621679157351"><span class="annot"><a href="TensorFlow.Gradient.html#safeIndex"><span class="hs-identifier hs-type">safeIndex</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679157351"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Maybe</span></span><span> </span><span class="annot"><a href="#local-6989586621679157351"><span class="hs-identifier hs-type">a</span></a></span></span><span>
|
|
</span><span id="line-240"></span><span class="hs-identifier">_</span><span> </span><span id="safeIndex"><span class="annot"><span class="annottext">safeIndex :: [a] -> Node -> Maybe a
|
|
</span><a href="TensorFlow.Gradient.html#safeIndex"><span class="hs-operator hs-var hs-var">`safeIndex`</span></a></span></span><span> </span><span id="local-6989586621679156863"><span class="annot"><span class="annottext">n :: Node
|
|
</span><a href="#local-6989586621679156863"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156863"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Node -> Node -> Bool
|
|
forall a. Ord a => a -> a -> Bool
|
|
</span><span class="hs-operator hs-var"><</span></span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-241"></span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#safeIndex"><span class="hs-operator hs-var">`safeIndex`</span></a></span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-242"></span><span class="hs-special">(</span><span id="local-6989586621679156861"><span class="annot"><span class="annottext">x :: a
|
|
</span><a href="#local-6989586621679156861"><span class="hs-identifier hs-var">x</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="hs-identifier">_</span><span class="hs-special">)</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#safeIndex"><span class="hs-operator hs-var">`safeIndex`</span></a></span><span> </span><span class="hs-number">0</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -> Maybe a
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">a
|
|
</span><a href="#local-6989586621679156861"><span class="hs-identifier hs-var">x</span></a></span><span>
|
|
</span><span id="line-243"></span><span class="hs-special">(</span><span class="hs-identifier">_</span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679156860"><span class="annot"><span class="annottext">xs :: [a]
|
|
</span><a href="#local-6989586621679156860"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#safeIndex"><span class="hs-operator hs-var">`safeIndex`</span></a></span><span> </span><span id="local-6989586621679156859"><span class="annot"><span class="annottext">n :: Node
|
|
</span><a href="#local-6989586621679156859"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a]
|
|
</span><a href="#local-6989586621679156860"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">[a] -> Node -> Maybe a
|
|
forall a. [a] -> Node -> Maybe a
|
|
</span><a href="TensorFlow.Gradient.html#safeIndex"><span class="hs-operator hs-var">`safeIndex`</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156859"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">Node -> Node -> Node
|
|
forall a. Num a => a -> a -> a
|
|
</span><span class="hs-glyph hs-var">-</span></span><span class="annot"><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-244"></span><span>
|
|
</span><span id="line-245"></span><span class="hs-comment">-- Copy of http://hackage.haskell.org/package/lens-3.9.0.2/docs/Control-Lens-Iso.html#v%3anon</span><span>
|
|
</span><span id="line-246"></span><span id="local-6989586621679157333"><span class="annot"><a href="TensorFlow.Gradient.html#anon"><span class="hs-identifier hs-type">anon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679157333"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679157333"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Lens'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Maybe</span></span><span> </span><span class="annot"><a href="#local-6989586621679157333"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621679157333"><span class="hs-identifier hs-type">a</span></a></span></span><span>
|
|
</span><span id="line-247"></span><span id="anon"><span class="annot"><span class="annottext">anon :: a -> (a -> Bool) -> Lens' (Maybe a) a
|
|
</span><a href="TensorFlow.Gradient.html#anon"><span class="hs-identifier hs-var hs-var">anon</span></a></span></span><span> </span><span id="local-6989586621679156857"><span class="annot"><span class="annottext">a :: a
|
|
</span><a href="#local-6989586621679156857"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621679156856"><span class="annot"><span class="annottext">p :: a -> Bool
|
|
</span><a href="#local-6989586621679156856"><span class="hs-identifier hs-var">p</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Resetter (Maybe a) (f (Maybe a)) a (f a)
|
|
-> (a -> f a) -> Maybe a -> f (Maybe a)
|
|
forall s t a b. Resetter s t a b -> (a -> b) -> s -> t
|
|
</span><span class="hs-identifier hs-var">under</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Maybe a -> a) -> (a -> Maybe a) -> Adapter (Maybe a) (Maybe a) a a
|
|
forall s a b t. (s -> a) -> (b -> t) -> Adapter s t a b
|
|
</span><span class="hs-identifier hs-var">adapter</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -> Maybe a -> a
|
|
forall a. a -> Maybe a -> a
|
|
</span><span class="hs-identifier hs-var">fromMaybe</span></span><span> </span><span class="annot"><span class="annottext">a
|
|
</span><a href="#local-6989586621679156857"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">a -> Maybe a
|
|
</span><a href="#local-6989586621679156855"><span class="hs-identifier hs-var">go</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-248"></span><span> </span><span id="local-6989586621679156855"><span class="annot"><span class="annottext">go :: a -> Maybe a
|
|
</span><a href="#local-6989586621679156855"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679156854"><span class="annot"><span class="annottext">b :: a
|
|
</span><a href="#local-6989586621679156854"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">a -> Bool
|
|
</span><a href="#local-6989586621679156856"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="annot"><span class="annottext">a
|
|
</span><a href="#local-6989586621679156854"><span class="hs-identifier hs-var">b</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe a
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-249"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">otherwise</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -> Maybe a
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">a
|
|
</span><a href="#local-6989586621679156854"><span class="hs-identifier hs-var">b</span></a></span><span>
|
|
</span><span id="line-250"></span><span>
|
|
</span><span id="line-251"></span><span id="local-6989586621679156992"><span class="annot"><a href="TensorFlow.Gradient.html#non"><span class="hs-identifier hs-type">non</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Eq</span></span><span> </span><span class="annot"><a href="#local-6989586621679156992"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><a href="#local-6989586621679156992"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Lens'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Maybe</span></span><span> </span><span class="annot"><a href="#local-6989586621679156992"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><a href="#local-6989586621679156992"><span class="hs-identifier hs-type">a</span></a></span></span><span>
|
|
</span><span id="line-252"></span><span id="non"><span class="annot"><span class="annottext">non :: a -> Lens' (Maybe a) a
|
|
</span><a href="TensorFlow.Gradient.html#non"><span class="hs-identifier hs-var hs-var">non</span></a></span></span><span> </span><span id="local-6989586621679156852"><span class="annot"><span class="annottext">a :: a
|
|
</span><a href="#local-6989586621679156852"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -> (a -> Bool) -> Lens' (Maybe a) a
|
|
forall a. a -> (a -> Bool) -> Lens' (Maybe a) a
|
|
</span><a href="TensorFlow.Gradient.html#anon"><span class="hs-identifier hs-var">anon</span></a></span><span> </span><span class="annot"><span class="annottext">a
|
|
</span><a href="#local-6989586621679156852"><span class="hs-identifier hs-var">a</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
|
|
</span><a href="#local-6989586621679156852"><span class="hs-identifier hs-var">a</span></a></span><span class="annot"><span class="annottext">a -> a -> Bool
|
|
forall a. Eq a => a -> a -> Bool
|
|
</span><span class="hs-operator hs-var">==</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-253"></span><span>
|
|
</span><span id="line-254"></span><span class="hs-comment">-- | Lens that defaults Nothing to mempty.</span><span>
|
|
</span><span id="line-255"></span><span id="local-6989586621679157406"><span id="local-6989586621679157407"><span class="annot"><a href="TensorFlow.Gradient.html#nonEmpty"><span class="hs-identifier hs-type">nonEmpty</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Monoid</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679157407"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157406"><span class="hs-identifier hs-type">v</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Foldable</span></span><span> </span><span class="annot"><a href="#local-6989586621679157407"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Lens'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Maybe</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679157407"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157406"><span class="hs-identifier hs-type">v</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679157407"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157406"><span class="hs-identifier hs-type">v</span></a></span><span class="hs-special">)</span></span></span><span>
|
|
</span><span id="line-256"></span><span id="nonEmpty"><span class="annot"><span class="annottext">nonEmpty :: Lens' (Maybe (t v)) (t v)
|
|
</span><a href="TensorFlow.Gradient.html#nonEmpty"><span class="hs-identifier hs-var hs-var">nonEmpty</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">t v -> (t v -> Bool) -> Lens' (Maybe (t v)) (t v)
|
|
forall a. a -> (a -> Bool) -> Lens' (Maybe a) a
|
|
</span><a href="TensorFlow.Gradient.html#anon"><span class="hs-identifier hs-var">anon</span></a></span><span> </span><span class="annot"><span class="annottext">t v
|
|
forall a. Monoid a => a
|
|
</span><span class="hs-identifier hs-var">mempty</span></span><span> </span><span class="annot"><span class="annottext">t v -> Bool
|
|
forall (t :: * -> *) a. Foldable t => t a -> Bool
|
|
</span><span class="hs-identifier hs-var">null</span></span><span>
|
|
</span><span id="line-257"></span><span>
|
|
</span><span id="line-258"></span><span class="hs-comment">-- TODO: strictness (e.g., foldlM')</span><span>
|
|
</span><span id="line-259"></span><span>
|
|
</span><span id="line-260"></span><span class="hs-comment">-- | Calculate the gradients for every node in a graph.</span><span>
|
|
</span><span id="line-261"></span><span class="annot"><a href="TensorFlow.Gradient.html#graphGrads"><span class="hs-identifier hs-type">graphGrads</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679157396"><span class="annot"><a href="#local-6989586621679157396"><span class="hs-identifier hs-type">a</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientCompatible"><span class="hs-identifier hs-type">GradientCompatible</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157396"><span class="hs-identifier hs-type">a</span></a></span><span>
|
|
</span><span id="line-262"></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#Graph"><span class="hs-identifier hs-type">Graph</span></a></span><span>
|
|
</span><span id="line-263"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">IntSet.IntSet</span></span><span>
|
|
</span><span id="line-264"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Map</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Node</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#PendingGradients"><span class="hs-identifier hs-type">PendingGradients</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157396"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-265"></span><span> </span><span class="hs-comment">-- ^ Initial gradients (usually just 1 for the node of interest).</span><span>
|
|
</span><span id="line-266"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Map</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Node</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#Gradients"><span class="hs-identifier hs-type">Gradients</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157396"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-267"></span><span id="graphGrads"><span class="annot"><span class="annottext">graphGrads :: Graph
|
|
-> IntSet
|
|
-> Map Node (PendingGradients a)
|
|
-> Build (Map Node (Gradients a))
|
|
</span><a href="TensorFlow.Gradient.html#graphGrads"><span class="hs-identifier hs-var hs-var">graphGrads</span></a></span></span><span> </span><span id="local-6989586621679156850"><span class="annot"><span class="annottext">gr :: Graph
|
|
</span><a href="#local-6989586621679156850"><span class="hs-identifier hs-var">gr</span></a></span></span><span> </span><span id="local-6989586621679156849"><span class="annot"><span class="annottext">reachableSet :: IntSet
|
|
</span><a href="#local-6989586621679156849"><span class="hs-identifier hs-var">reachableSet</span></a></span></span><span> </span><span id="local-6989586621679156848"><span class="annot"><span class="annottext">initPending :: Map Node (PendingGradients a)
|
|
</span><a href="#local-6989586621679156848"><span class="hs-identifier hs-var">initPending</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FoldLike
|
|
(Map Node (Gradients a))
|
|
(GradientsState a)
|
|
(GradientsState a)
|
|
(Map Node (Gradients a))
|
|
(Map Node (Gradients a))
|
|
-> GradientsState a -> Map Node (Gradients a)
|
|
forall a s t b. FoldLike a s t a b -> s -> a
|
|
</span><span class="hs-identifier hs-var">view</span></span><span> </span><span class="annot"><span class="annottext">FoldLike
|
|
(Map Node (Gradients a))
|
|
(GradientsState a)
|
|
(GradientsState a)
|
|
(Map Node (Gradients a))
|
|
(Map Node (Gradients a))
|
|
forall a. Lens' (GradientsState a) (Map Node (Gradients a))
|
|
</span><a href="TensorFlow.Gradient.html#gradientsResult"><span class="hs-identifier hs-var">gradientsResult</span></a></span><span> </span><span class="annot"><span class="annottext">(GradientsState a -> Map Node (Gradients a))
|
|
-> BuildT Identity (GradientsState a)
|
|
-> Build (Map Node (Gradients a))
|
|
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
|
|
</span><span class="hs-operator hs-var"><$></span></span><span> </span><span class="annot"><span class="annottext">(GradientsState a -> Node -> BuildT Identity (GradientsState a))
|
|
-> GradientsState a -> [Node] -> BuildT Identity (GradientsState a)
|
|
forall (t :: * -> *) (m :: * -> *) b a.
|
|
(Foldable t, Monad m) =>
|
|
(b -> a -> m b) -> b -> t a -> m b
|
|
</span><span class="hs-identifier hs-var">foldlM</span></span><span> </span><span class="annot"><span class="annottext">GradientsState a -> Node -> BuildT Identity (GradientsState a)
|
|
</span><a href="#local-6989586621679156846"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
</span><a href="#local-6989586621679156845"><span class="hs-identifier hs-var">initState</span></a></span><span> </span><span class="annot"><span class="annottext">[Node]
|
|
</span><a href="#local-6989586621679156844"><span class="hs-identifier hs-var">nodeOrder</span></a></span><span>
|
|
</span><span id="line-268"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-269"></span><span> </span><span id="local-6989586621679156845"><span class="annot"><span class="annottext">initState :: GradientsState a
|
|
</span><a href="#local-6989586621679156845"><span class="hs-identifier hs-var hs-var">initState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Map Node (PendingGradients a)
|
|
-> Map Node (Gradients a) -> GradientsState a
|
|
forall a.
|
|
Map Node (PendingGradients a)
|
|
-> Map Node (Gradients a) -> GradientsState a
|
|
</span><a href="TensorFlow.Gradient.html#GradientsState"><span class="hs-identifier hs-var">GradientsState</span></a></span><span> </span><span class="annot"><span class="annottext">Map Node (PendingGradients a)
|
|
</span><a href="#local-6989586621679156848"><span class="hs-identifier hs-var">initPending</span></a></span><span> </span><span class="annot"><span class="annottext">Map Node (Gradients a)
|
|
forall k a. Map k a
|
|
</span><span class="hs-identifier hs-var">Map.empty</span></span><span>
|
|
</span><span id="line-270"></span><span> </span><span class="hs-comment">-- Reverse topological sort.</span><span>
|
|
</span><span id="line-271"></span><span> </span><span id="local-6989586621679156844"><span class="annot"><span class="annottext">nodeOrder :: [Node]
|
|
</span><a href="#local-6989586621679156844"><span class="hs-identifier hs-var hs-var">nodeOrder</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Graph -> [Node]
|
|
forall (gr :: * -> * -> *) a b. Graph gr => gr a b -> [Node]
|
|
</span><span class="hs-identifier hs-var">FGL.topsort</span></span><span> </span><span class="annot"><span class="annottext">(Graph -> [Node]) -> (Graph -> Graph) -> Graph -> [Node]
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">Graph -> Graph
|
|
forall (gr :: * -> * -> *) a b. DynGraph gr => gr a b -> gr a b
|
|
</span><span class="hs-identifier hs-var">FGL.grev</span></span><span> </span><span class="annot"><span class="annottext">(Graph -> [Node]) -> Graph -> [Node]
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Graph
|
|
</span><a href="#local-6989586621679156850"><span class="hs-identifier hs-var">gr</span></a></span><span>
|
|
</span><span id="line-272"></span><span> </span><span class="annot"><a href="#local-6989586621679156846"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientsState"><span class="hs-identifier hs-type">GradientsState</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157396"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#GradientsState"><span class="hs-identifier hs-type">GradientsState</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157396"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-273"></span><span> </span><span id="local-6989586621679156846"><span class="annot"><span class="annottext">go :: GradientsState a -> Node -> BuildT Identity (GradientsState a)
|
|
</span><a href="#local-6989586621679156846"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679156841"><span class="annot"><span class="annottext">state :: GradientsState a
|
|
</span><a href="#local-6989586621679156841"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span id="local-6989586621679156840"><span class="annot"><span class="annottext">node :: Node
|
|
</span><a href="#local-6989586621679156840"><span class="hs-identifier hs-var">node</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
|
|
</span><span id="line-274"></span><span> </span><span class="hs-comment">-- Aggregate the accumulated gradients for this node.</span><span>
|
|
</span><span id="line-275"></span><span> </span><span id="local-6989586621679156839"><span class="annot"><span class="annottext">Gradients a
|
|
</span><a href="#local-6989586621679156839"><span class="hs-identifier hs-var">outputGrads</span></a></span></span><span> </span><span class="hs-glyph"><-</span><span>
|
|
</span><span id="line-276"></span><span> </span><span class="annot"><span class="annottext">PendingGradients a -> Build (Gradients a)
|
|
forall a.
|
|
GradientCompatible a =>
|
|
PendingGradients a -> Build (Gradients a)
|
|
</span><a href="TensorFlow.Gradient.html#sumPendingGradient"><span class="hs-identifier hs-var">sumPendingGradient</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GradientsState a
|
|
</span><a href="#local-6989586621679156841"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
-> FoldLike
|
|
(PendingGradients a)
|
|
(GradientsState a)
|
|
(GradientsState a)
|
|
(PendingGradients a)
|
|
(PendingGradients a)
|
|
-> PendingGradients a
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">LensLike'
|
|
(Constant (PendingGradients a))
|
|
(GradientsState a)
|
|
(Map Node (PendingGradients a))
|
|
forall a. Lens' (GradientsState a) (Map Node (PendingGradients a))
|
|
</span><a href="TensorFlow.Gradient.html#gradientsPending"><span class="hs-identifier hs-var">gradientsPending</span></a></span><span> </span><span class="annot"><span class="annottext">LensLike'
|
|
(Constant (PendingGradients a))
|
|
(GradientsState a)
|
|
(Map Node (PendingGradients a))
|
|
-> ((PendingGradients a
|
|
-> Constant (PendingGradients a) (PendingGradients a))
|
|
-> Map Node (PendingGradients a)
|
|
-> Constant (PendingGradients a) (Map Node (PendingGradients a)))
|
|
-> FoldLike
|
|
(PendingGradients a)
|
|
(GradientsState a)
|
|
(GradientsState a)
|
|
(PendingGradients a)
|
|
(PendingGradients a)
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
-> Lens'
|
|
(Map Node (PendingGradients a)) (Maybe (PendingGradients a))
|
|
forall k v. Ord k => k -> Lens' (Map k v) (Maybe v)
|
|
</span><span class="hs-identifier hs-var">at</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156840"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">LensLike'
|
|
(Constant (PendingGradients a))
|
|
(Map Node (PendingGradients a))
|
|
(Maybe (PendingGradients a))
|
|
-> ((PendingGradients a
|
|
-> Constant (PendingGradients a) (PendingGradients a))
|
|
-> Maybe (PendingGradients a)
|
|
-> Constant (PendingGradients a) (Maybe (PendingGradients a)))
|
|
-> (PendingGradients a
|
|
-> Constant (PendingGradients a) (PendingGradients a))
|
|
-> Map Node (PendingGradients a)
|
|
-> Constant (PendingGradients a) (Map Node (PendingGradients a))
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">(PendingGradients a
|
|
-> Constant (PendingGradients a) (PendingGradients a))
|
|
-> Maybe (PendingGradients a)
|
|
-> Constant (PendingGradients a) (Maybe (PendingGradients a))
|
|
forall (t :: * -> *) v.
|
|
(Monoid (t v), Foldable t) =>
|
|
Lens' (Maybe (t v)) (t v)
|
|
</span><a href="TensorFlow.Gradient.html#nonEmpty"><span class="hs-identifier hs-var">nonEmpty</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-277"></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Gradients a -> Bool
|
|
forall (t :: * -> *) a. Foldable t => t a -> Bool
|
|
</span><span class="hs-identifier hs-var">null</span></span><span> </span><span class="annot"><span class="annottext">Gradients a
|
|
</span><a href="#local-6989586621679156839"><span class="hs-identifier hs-var">outputGrads</span></a></span><span>
|
|
</span><span id="line-278"></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">GradientsState a -> BuildT Identity (GradientsState a)
|
|
forall (f :: * -> *) a. Applicative f => a -> f a
|
|
</span><span class="hs-identifier hs-var">pure</span></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
</span><a href="#local-6989586621679156841"><span class="hs-identifier hs-var">state</span></a></span><span>
|
|
</span><span id="line-279"></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
|
|
</span><span id="line-280"></span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679156837"><span class="annot"><span class="annottext">nextState :: GradientsState a
|
|
</span><a href="#local-6989586621679156837"><span class="hs-identifier hs-var hs-var">nextState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
</span><a href="#local-6989586621679156841"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
-> (GradientsState a -> GradientsState a) -> GradientsState a
|
|
forall s t. s -> (s -> t) -> t
|
|
</span><span class="hs-operator hs-var">&</span></span><span> </span><span class="annot"><span class="annottext">forall a. Lens' (GradientsState a) (Map Node (Gradients a))
|
|
forall (f :: * -> *).
|
|
Identical f =>
|
|
LensLike' f (GradientsState a) (Map Node (Gradients a))
|
|
</span><a href="TensorFlow.Gradient.html#gradientsResult"><span class="hs-identifier hs-var">gradientsResult</span></a></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *).
|
|
Identical f =>
|
|
LensLike' f (GradientsState a) (Map Node (Gradients a)))
|
|
-> (Map Node (Gradients a) -> Map Node (Gradients a))
|
|
-> GradientsState a
|
|
-> GradientsState a
|
|
forall s t a b. Setter s t a b -> (a -> b) -> s -> t
|
|
</span><span class="hs-operator hs-var">%~</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
-> Gradients a -> Map Node (Gradients a) -> Map Node (Gradients a)
|
|
forall k a. Ord k => k -> a -> Map k a -> Map k a
|
|
</span><span class="hs-identifier hs-var">Map.insert</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156840"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Gradients a
|
|
</span><a href="#local-6989586621679156839"><span class="hs-identifier hs-var">outputGrads</span></a></span><span>
|
|
</span><span id="line-281"></span><span> </span><span class="hs-comment">-- Only consider nodes that are reachable from the inputs to</span><span>
|
|
</span><span id="line-282"></span><span> </span><span class="hs-comment">-- avoid calculating gradients that won't be used.</span><span>
|
|
</span><span id="line-283"></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156840"><span class="hs-identifier hs-var">node</span></a></span><span> </span><span class="annot"><span class="annottext">Node -> IntSet -> Bool
|
|
</span><span class="hs-operator hs-var">`IntSet.member`</span></span><span> </span><span class="annot"><span class="annottext">IntSet
|
|
</span><a href="#local-6989586621679156849"><span class="hs-identifier hs-var">reachableSet</span></a></span><span>
|
|
</span><span id="line-284"></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span>
|
|
</span><span id="line-285"></span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679156834"><span class="annot"><span class="annottext">ctx :: Context NodeDef EdgeLabel
|
|
</span><a href="#local-6989586621679156834"><span class="hs-identifier hs-var hs-var">ctx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Graph -> Node -> Context NodeDef EdgeLabel
|
|
forall (gr :: * -> * -> *) a b.
|
|
Graph gr =>
|
|
gr a b -> Node -> Context a b
|
|
</span><span class="hs-identifier hs-var">FGL.context</span></span><span> </span><span class="annot"><span class="annottext">Graph
|
|
</span><a href="#local-6989586621679156850"><span class="hs-identifier hs-var">gr</span></a></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156840"><span class="hs-identifier hs-var">node</span></a></span><span>
|
|
</span><span id="line-286"></span><span> </span><span id="local-6989586621679156832"><span class="annot"><span class="annottext">[Maybe (Tensor Value a)]
|
|
</span><a href="#local-6989586621679156832"><span class="hs-identifier hs-var">inputGrads</span></a></span></span><span> </span><span class="hs-glyph"><-</span><span> </span><span class="annot"><span class="annottext">Context NodeDef EdgeLabel
|
|
-> Gradients a -> Graph -> Build [Maybe (Tensor Value a)]
|
|
forall a.
|
|
GradientCompatible a =>
|
|
Context NodeDef EdgeLabel
|
|
-> Gradients a -> Graph -> Build [Maybe (Tensor Value a)]
|
|
</span><a href="TensorFlow.Gradient.html#calculateInputGrads"><span class="hs-identifier hs-var">calculateInputGrads</span></a></span><span> </span><span class="annot"><span class="annottext">Context NodeDef EdgeLabel
|
|
</span><a href="#local-6989586621679156834"><span class="hs-identifier hs-var">ctx</span></a></span><span> </span><span class="annot"><span class="annottext">Gradients a
|
|
</span><a href="#local-6989586621679156839"><span class="hs-identifier hs-var">outputGrads</span></a></span><span> </span><span class="annot"><span class="annottext">Graph
|
|
</span><a href="#local-6989586621679156850"><span class="hs-identifier hs-var">gr</span></a></span><span>
|
|
</span><span id="line-287"></span><span> </span><span class="hs-comment">-- Calculate the gradients for each of the node's inputs.</span><span>
|
|
</span><span id="line-288"></span><span> </span><span class="annot"><span class="annottext">GradientsState a -> BuildT Identity (GradientsState a)
|
|
forall (f :: * -> *) a. Applicative f => a -> f a
|
|
</span><span class="hs-identifier hs-var">pure</span></span><span> </span><span class="annot"><span class="annottext">(GradientsState a -> BuildT Identity (GradientsState a))
|
|
-> GradientsState a -> BuildT Identity (GradientsState a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Context NodeDef EdgeLabel
|
|
-> [Maybe (Tensor Value a)] -> GradientsState a -> GradientsState a
|
|
forall a.
|
|
(TensorType a, Num a) =>
|
|
Context NodeDef EdgeLabel
|
|
-> [Maybe (Tensor Value a)] -> GradientsState a -> GradientsState a
|
|
</span><a href="TensorFlow.Gradient.html#updatePendingGradients"><span class="hs-identifier hs-var">updatePendingGradients</span></a></span><span> </span><span class="annot"><span class="annottext">Context NodeDef EdgeLabel
|
|
</span><a href="#local-6989586621679156834"><span class="hs-identifier hs-var">ctx</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe (Tensor Value a)]
|
|
</span><a href="#local-6989586621679156832"><span class="hs-identifier hs-var">inputGrads</span></a></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
</span><a href="#local-6989586621679156837"><span class="hs-identifier hs-var">nextState</span></a></span><span>
|
|
</span><span id="line-289"></span><span> </span><span class="hs-keyword">else</span><span>
|
|
</span><span id="line-290"></span><span> </span><span class="annot"><span class="annottext">GradientsState a -> BuildT Identity (GradientsState a)
|
|
forall (f :: * -> *) a. Applicative f => a -> f a
|
|
</span><span class="hs-identifier hs-var">pure</span></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
</span><a href="#local-6989586621679156837"><span class="hs-identifier hs-var">nextState</span></a></span><span>
|
|
</span><span id="line-291"></span><span>
|
|
</span><span id="line-292"></span><span class="hs-comment">-- | Reduce accumulated gradients for each output to one Tensor.</span><span>
|
|
</span><span id="line-293"></span><span id="local-6989586621679157305"><span class="annot"><a href="TensorFlow.Gradient.html#sumPendingGradient"><span class="hs-identifier hs-type">sumPendingGradient</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientCompatible"><span class="hs-identifier hs-type">GradientCompatible</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157305"><span class="hs-identifier hs-type">a</span></a></span><span>
|
|
</span><span id="line-294"></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#PendingGradients"><span class="hs-identifier hs-type">PendingGradients</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157305"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#Gradients"><span class="hs-identifier hs-type">Gradients</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157305"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span><span>
|
|
</span><span id="line-295"></span><span id="sumPendingGradient"><span class="annot"><span class="annottext">sumPendingGradient :: PendingGradients a -> Build (Gradients a)
|
|
</span><a href="TensorFlow.Gradient.html#sumPendingGradient"><span class="hs-identifier hs-var hs-var">sumPendingGradient</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IntMap (BuildT Identity (Tensor Value a)) -> Build (Gradients a)
|
|
forall (t :: * -> *) (m :: * -> *) a.
|
|
(Traversable t, Monad m) =>
|
|
t (m a) -> m (t a)
|
|
</span><span class="hs-identifier hs-var">sequence</span></span><span> </span><span class="annot"><span class="annottext">(IntMap (BuildT Identity (Tensor Value a)) -> Build (Gradients a))
|
|
-> (PendingGradients a
|
|
-> IntMap (BuildT Identity (Tensor Value a)))
|
|
-> PendingGradients a
|
|
-> Build (Gradients a)
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">([Tensor Value a] -> Maybe (BuildT Identity (Tensor Value a)))
|
|
-> PendingGradients a -> IntMap (BuildT Identity (Tensor Value a))
|
|
forall a b. (a -> Maybe b) -> IntMap a -> IntMap b
|
|
</span><span class="hs-identifier hs-var">IntMap.mapMaybe</span></span><span> </span><span class="annot"><span class="annottext">[Tensor Value a] -> Maybe (BuildT Identity (Tensor Value a))
|
|
forall a (f :: * -> *).
|
|
(a /= ByteString, a /= Bool, MonadBuild f, TensorType a) =>
|
|
[Tensor Value a] -> Maybe (f (Tensor Value a))
|
|
</span><a href="#local-6989586621679156827"><span class="hs-identifier hs-var">f</span></a></span><span>
|
|
</span><span id="line-296"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-297"></span><span> </span><span id="local-6989586621679156827"><span class="annot"><span class="annottext">f :: [Tensor Value a] -> Maybe (f (Tensor Value a))
|
|
</span><a href="#local-6989586621679156827"><span class="hs-identifier hs-var hs-var">f</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (f (Tensor Value a))
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-298"></span><span> </span><span class="annot"><a href="#local-6989586621679156827"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156826"><span class="annot"><span class="annottext">x :: Tensor Value a
|
|
</span><a href="#local-6989586621679156826"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">f (Tensor Value a) -> Maybe (f (Tensor Value a))
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a -> f (Tensor Value a)
|
|
forall (f :: * -> *) a. Applicative f => a -> f a
|
|
</span><span class="hs-identifier hs-var">pure</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156826"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-299"></span><span> </span><span class="annot"><a href="#local-6989586621679156827"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span id="local-6989586621679156825"><span class="annot"><span class="annottext">xs :: [Tensor Value a]
|
|
</span><a href="#local-6989586621679156825"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">f (Tensor Value a) -> Maybe (f (Tensor Value a))
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> f (Tensor Value a)
|
|
forall (m :: * -> *) a.
|
|
MonadBuild m =>
|
|
Tensor Build a -> m (Tensor Value a)
|
|
</span><span class="hs-identifier hs-var">render</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> f (Tensor Value a))
|
|
-> Tensor Build a -> f (Tensor Value a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">[Tensor Value a] -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float, Variant]
|
|
t =>
|
|
[Tensor v'1 t] -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">addN</span></span><span> </span><span class="annot"><span class="annottext">[Tensor Value a]
|
|
</span><a href="#local-6989586621679156825"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-300"></span><span>
|
|
</span><span id="line-301"></span><span>
|
|
</span><span id="line-302"></span><span class="hs-comment">-- | Calculate the gradients of a node's input tensors.</span><span>
|
|
</span><span id="line-303"></span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-304"></span><span class="hs-comment">-- This is mostly just a wrapper around opGrad.</span><span>
|
|
</span><span id="line-305"></span><span class="annot"><a href="TensorFlow.Gradient.html#calculateInputGrads"><span class="hs-identifier hs-type">calculateInputGrads</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679157289"><span class="annot"><a href="#local-6989586621679157289"><span class="hs-identifier hs-type">a</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientCompatible"><span class="hs-identifier hs-type">GradientCompatible</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157289"><span class="hs-identifier hs-type">a</span></a></span><span>
|
|
</span><span id="line-306"></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Context</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeDef</span></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#EdgeLabel"><span class="hs-identifier hs-type">EdgeLabel</span></a></span><span>
|
|
</span><span id="line-307"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#Gradients"><span class="hs-identifier hs-type">Gradients</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157289"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-comment">-- ^ Output gradients of the node.</span><span>
|
|
</span><span id="line-308"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#Graph"><span class="hs-identifier hs-type">Graph</span></a></span><span>
|
|
</span><span id="line-309"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Maybe</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Value</span></span><span> </span><span class="annot"><a href="#local-6989586621679157289"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
|
|
</span><span id="line-310"></span><span id="calculateInputGrads"><span class="annot"><span class="annottext">calculateInputGrads :: Context NodeDef EdgeLabel
|
|
-> Gradients a -> Graph -> Build [Maybe (Tensor Value a)]
|
|
</span><a href="TensorFlow.Gradient.html#calculateInputGrads"><span class="hs-identifier hs-var hs-var">calculateInputGrads</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156824"><span class="annot"><span class="annottext">inputEdges :: Adj EdgeLabel
|
|
</span><a href="#local-6989586621679156824"><span class="hs-identifier hs-var">inputEdges</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156823"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156823"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">)</span><span> </span><span id="local-6989586621679156822"><span class="annot"><span class="annottext">outputGrads :: Gradients a
|
|
</span><a href="#local-6989586621679156822"><span class="hs-identifier hs-var">outputGrads</span></a></span></span><span> </span><span id="local-6989586621679156821"><span class="annot"><span class="annottext">gr :: Graph
|
|
</span><a href="#local-6989586621679156821"><span class="hs-identifier hs-var">gr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
|
|
</span><span id="line-311"></span><span> </span><span id="local-6989586621679156820"><span class="annot"><span class="annottext">[Tensor Value a]
|
|
</span><a href="#local-6989586621679156820"><span class="hs-identifier hs-var">fullOutGrads</span></a></span></span><span> </span><span class="hs-glyph"><-</span><span> </span><span class="annot"><span class="annottext">OutputIx -> NodeName -> Gradients a -> Build [Tensor Value a]
|
|
forall a.
|
|
(TensorType a, Num a) =>
|
|
OutputIx -> NodeName -> Gradients a -> Build [Tensor Value a]
|
|
</span><a href="TensorFlow.Gradient.html#fullOutputGrads"><span class="hs-identifier hs-var">fullOutputGrads</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeDef -> OutputIx
|
|
</span><a href="TensorFlow.Gradient.html#numOutputs"><span class="hs-identifier hs-var">numOutputs</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156823"><span class="hs-identifier hs-var">nodeDef</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeDef -> NodeName
|
|
</span><a href="TensorFlow.Gradient.html#nodeDefName"><span class="hs-identifier hs-var">nodeDefName</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156823"><span class="hs-identifier hs-var">nodeDef</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-312"></span><span> </span><span class="annot"><span class="annottext">Gradients a
|
|
</span><a href="#local-6989586621679156822"><span class="hs-identifier hs-var">outputGrads</span></a></span><span>
|
|
</span><span id="line-313"></span><span> </span><span class="annot"><span class="annottext">(Maybe (Tensor Build a)
|
|
-> BuildT Identity (Maybe (Tensor Value a)))
|
|
-> [Maybe (Tensor Build a)] -> Build [Maybe (Tensor Value a)]
|
|
forall (t :: * -> *) (f :: * -> *) a b.
|
|
(Traversable t, Applicative f) =>
|
|
(a -> f b) -> t a -> f (t b)
|
|
</span><span class="hs-identifier hs-var">traverse</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Tensor Build a -> BuildT Identity (Tensor Value a))
|
|
-> Maybe (Tensor Build a)
|
|
-> BuildT Identity (Maybe (Tensor Value a))
|
|
forall (t :: * -> *) (f :: * -> *) a b.
|
|
(Traversable t, Applicative f) =>
|
|
(a -> f b) -> t a -> f (t b)
|
|
</span><span class="hs-identifier hs-var">traverse</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> BuildT Identity (Tensor Value a)
|
|
forall (m :: * -> *) a.
|
|
MonadBuild m =>
|
|
Tensor Build a -> m (Tensor Value a)
|
|
</span><span class="hs-identifier hs-var">render</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([Maybe (Tensor Build a)] -> Build [Maybe (Tensor Value a)])
|
|
-> [Maybe (Tensor Build a)] -> Build [Maybe (Tensor Value a)]
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Text -> GradientFunc a
|
|
forall a. GradientCompatible a => Text -> GradientFunc a
|
|
</span><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156823"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef -> FoldLike Text NodeDef NodeDef Text Text -> Text
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">FoldLike Text NodeDef NodeDef Text Text
|
|
forall (f :: * -> *) s a.
|
|
(Functor f, HasField s "op" a) =>
|
|
LensLike' f s a
|
|
</span><span class="hs-identifier hs-var">op</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156823"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156814"><span class="hs-identifier hs-var">inputTensors</span></a></span><span> </span><span class="annot"><span class="annottext">[Tensor Value a]
|
|
</span><a href="#local-6989586621679156820"><span class="hs-identifier hs-var">fullOutGrads</span></a></span><span>
|
|
</span><span id="line-314"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-315"></span><span> </span><span class="hs-comment">-- Create a tensor from an edge (technically an Output, but it seems less</span><span>
|
|
</span><span id="line-316"></span><span> </span><span class="hs-comment">-- confusing to refer to it as a tensor here).</span><span>
|
|
</span><span id="line-317"></span><span> </span><span class="annot"><a href="#local-6989586621679156813"><span class="hs-identifier hs-type">edgeToTensor</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#EdgeLabel"><span class="hs-identifier hs-type">EdgeLabel</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Node</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Output</span></span><span>
|
|
</span><span id="line-318"></span><span> </span><span id="local-6989586621679156813"><span class="annot"><span class="annottext">edgeToTensor :: (EdgeLabel, Node) -> Output
|
|
</span><a href="#local-6989586621679156813"><span class="hs-identifier hs-var hs-var">edgeToTensor</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621679156812"><span class="annot"><span class="annottext">i :: OutputIx
|
|
</span><a href="#local-6989586621679156812"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156811"><span class="annot"><span class="annottext">n :: Node
|
|
</span><a href="#local-6989586621679156811"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-319"></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Graph -> Node -> Maybe NodeDef
|
|
forall (gr :: * -> * -> *) a b.
|
|
Graph gr =>
|
|
gr a b -> Node -> Maybe a
|
|
</span><span class="hs-identifier hs-var">FGL.lab</span></span><span> </span><span class="annot"><span class="annottext">Graph
|
|
</span><a href="#local-6989586621679156821"><span class="hs-identifier hs-var">gr</span></a></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156811"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-keyword">of</span><span>
|
|
</span><span id="line-320"></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Just</span></span><span> </span><span id="local-6989586621679156809"><span class="annot"><span class="annottext">edgeNodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156809"><span class="hs-identifier hs-var">edgeNodeDef</span></a></span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="annottext">OutputIx -> NodeName -> Output
|
|
</span><span class="hs-identifier hs-var">Output</span></span><span> </span><span class="annot"><span class="annottext">OutputIx
|
|
</span><a href="#local-6989586621679156812"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> NodeName
|
|
</span><span class="hs-identifier hs-var">NodeName</span></span><span> </span><span class="annot"><span class="annottext">(Text -> NodeName) -> Text -> NodeName
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156809"><span class="hs-identifier hs-var">edgeNodeDef</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef -> FoldLike Text NodeDef NodeDef Text Text -> Text
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">FoldLike Text NodeDef NodeDef Text Text
|
|
forall (f :: * -> *) s a.
|
|
(Functor f, HasField s "name" a) =>
|
|
LensLike' f s a
|
|
</span><span class="hs-identifier hs-var">name</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-321"></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Nothing</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="annottext">[Char] -> Output
|
|
forall a. HasCallStack => [Char] -> a
|
|
</span><span class="hs-identifier hs-var">error</span></span><span> </span><span class="annot"><span class="annottext">([Char] -> Output) -> [Char] -> Output
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="hs-string">"calculateInputGrads: missing input node for "</span></span><span>
|
|
</span><span id="line-322"></span><span> </span><span class="annot"><span class="annottext">[Char] -> [Char] -> [Char]
|
|
forall a. [a] -> [a] -> [a]
|
|
</span><span class="hs-operator hs-var">++</span></span><span> </span><span class="annot"><span class="annottext">Text -> [Char]
|
|
</span><span class="hs-identifier hs-var">Text.unpack</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156823"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef -> FoldLike Text NodeDef NodeDef Text Text -> Text
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">FoldLike Text NodeDef NodeDef Text Text
|
|
forall (f :: * -> *) s a.
|
|
(Functor f, HasField s "name" a) =>
|
|
LensLike' f s a
|
|
</span><span class="hs-identifier hs-var">name</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-323"></span><span> </span><span class="hs-comment">-- Input tensors, sorted by input index.</span><span>
|
|
</span><span id="line-324"></span><span> </span><span id="local-6989586621679156814"><span class="annot"><span class="annottext">inputTensors :: [Output]
|
|
</span><a href="#local-6989586621679156814"><span class="hs-identifier hs-var hs-var">inputTensors</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((EdgeLabel, Node) -> Output) -> Adj EdgeLabel -> [Output]
|
|
forall a b. (a -> b) -> [a] -> [b]
|
|
</span><span class="hs-identifier hs-var">map</span></span><span> </span><span class="annot"><span class="annottext">(EdgeLabel, Node) -> Output
|
|
</span><a href="#local-6989586621679156813"><span class="hs-identifier hs-var">edgeToTensor</span></a></span><span> </span><span class="annot"><span class="annottext">(Adj EdgeLabel -> [Output]) -> Adj EdgeLabel -> [Output]
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">((EdgeLabel, Node) -> (EdgeLabel, Node) -> Ordering)
|
|
-> Adj EdgeLabel -> Adj EdgeLabel
|
|
forall a. (a -> a -> Ordering) -> [a] -> [a]
|
|
</span><span class="hs-identifier hs-var">sortBy</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">((EdgeLabel, Node) -> OutputIx)
|
|
-> (EdgeLabel, Node) -> (EdgeLabel, Node) -> Ordering
|
|
forall a b. Ord a => (b -> a) -> b -> b -> Ordering
|
|
</span><span class="hs-identifier hs-var">comparing</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">EdgeLabel -> OutputIx
|
|
forall a b. (a, b) -> b
|
|
</span><span class="hs-identifier hs-var">snd</span></span><span> </span><span class="annot"><span class="annottext">(EdgeLabel -> OutputIx)
|
|
-> ((EdgeLabel, Node) -> EdgeLabel)
|
|
-> (EdgeLabel, Node)
|
|
-> OutputIx
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">(EdgeLabel, Node) -> EdgeLabel
|
|
forall a b. (a, b) -> a
|
|
</span><span class="hs-identifier hs-var">fst</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Adj EdgeLabel
|
|
</span><a href="#local-6989586621679156824"><span class="hs-identifier hs-var">inputEdges</span></a></span><span>
|
|
</span><span id="line-325"></span><span>
|
|
</span><span id="line-326"></span><span class="hs-comment">-- | Convert a Map of gradients to a list, with zeros for missing outputs.</span><span>
|
|
</span><span id="line-327"></span><span id="local-6989586621679157271"><span class="annot"><a href="TensorFlow.Gradient.html#fullOutputGrads"><span class="hs-identifier hs-type">fullOutputGrads</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">TensorType</span></span><span> </span><span class="annot"><a href="#local-6989586621679157271"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Num</span></span><span> </span><span class="annot"><a href="#local-6989586621679157271"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-328"></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><span class="hs-identifier hs-type">OutputIx</span></span><span> </span><span class="hs-comment">-- ^ Number of outputs.</span><span>
|
|
</span><span id="line-329"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span>
|
|
</span><span id="line-330"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#Gradients"><span class="hs-identifier hs-type">Gradients</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157271"><span class="hs-identifier hs-type">a</span></a></span><span>
|
|
</span><span id="line-331"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Value</span></span><span> </span><span class="annot"><a href="#local-6989586621679157271"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
|
|
</span><span id="line-332"></span><span id="fullOutputGrads"><span class="annot"><span class="annottext">fullOutputGrads :: OutputIx -> NodeName -> Gradients a -> Build [Tensor Value a]
|
|
</span><a href="TensorFlow.Gradient.html#fullOutputGrads"><span class="hs-identifier hs-var hs-var">fullOutputGrads</span></a></span></span><span> </span><span id="local-6989586621679156806"><span class="annot"><span class="annottext">n :: OutputIx
|
|
</span><a href="#local-6989586621679156806"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621679156805"><span class="annot"><span class="annottext">o :: NodeName
|
|
</span><a href="#local-6989586621679156805"><span class="hs-identifier hs-var">o</span></a></span></span><span> </span><span id="local-6989586621679156804"><span class="annot"><span class="annottext">gs :: Gradients a
|
|
</span><a href="#local-6989586621679156804"><span class="hs-identifier hs-var">gs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-333"></span><span> </span><span class="annot"><span class="annottext">(OutputIx -> BuildT Identity (Tensor Value a))
|
|
-> [OutputIx] -> Build [Tensor Value a]
|
|
forall (t :: * -> *) (m :: * -> *) a b.
|
|
(Traversable t, Monad m) =>
|
|
(a -> m b) -> t a -> m (t b)
|
|
</span><span class="hs-identifier hs-var">mapM</span></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679156802"><span class="annot"><span class="annottext">i :: OutputIx
|
|
</span><a href="#local-6989586621679156802"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="annottext">BuildT Identity (Tensor Value a)
|
|
-> (Tensor Value a -> BuildT Identity (Tensor Value a))
|
|
-> Maybe (Tensor Value a)
|
|
-> BuildT Identity (Tensor Value a)
|
|
forall b a. b -> (a -> b) -> Maybe a -> b
|
|
</span><span class="hs-identifier hs-var">maybe</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> BuildT Identity (Tensor Value a)
|
|
forall (m :: * -> *) a.
|
|
MonadBuild m =>
|
|
Tensor Build a -> m (Tensor Value a)
|
|
</span><span class="hs-identifier hs-var">render</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> BuildT Identity (Tensor Value a))
|
|
-> Tensor Build a -> BuildT Identity (Tensor Value a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">OutputIx -> Tensor Build a
|
|
</span><a href="#local-6989586621679156801"><span class="hs-identifier hs-var">zero</span></a></span><span> </span><span class="annot"><span class="annottext">OutputIx
|
|
</span><a href="#local-6989586621679156802"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> BuildT Identity (Tensor Value a)
|
|
forall (m :: * -> *) a. Monad m => a -> m a
|
|
</span><span class="hs-identifier hs-var">return</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Gradients a
|
|
</span><a href="#local-6989586621679156804"><span class="hs-identifier hs-var">gs</span></a></span><span> </span><span class="annot"><span class="annottext">Gradients a
|
|
-> FoldLike
|
|
(Maybe (Tensor Value a))
|
|
(Gradients a)
|
|
(Gradients a)
|
|
(Maybe (Tensor Value a))
|
|
(Maybe (Tensor Value a))
|
|
-> Maybe (Tensor Value a)
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">OutputIx -> Lens' (Gradients a) (Maybe (Tensor Value a))
|
|
forall v. OutputIx -> Lens' (IntMap v) (Maybe v)
|
|
</span><a href="TensorFlow.Gradient.html#outputIxAt"><span class="hs-identifier hs-var">outputIxAt</span></a></span><span> </span><span class="annot"><span class="annottext">OutputIx
|
|
</span><a href="#local-6989586621679156802"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-number">0</span></span><span class="hs-glyph">..</span><span class="annot"><span class="annottext">OutputIx
|
|
</span><a href="#local-6989586621679156806"><span class="hs-identifier hs-var">n</span></a></span><span class="annot"><span class="annottext">OutputIx -> OutputIx -> OutputIx
|
|
forall a. Num a => a -> a -> a
|
|
</span><span class="hs-glyph hs-var">-</span></span><span class="annot"><span class="hs-number">1</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-334"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-335"></span><span> </span><span class="hs-comment">-- A tensor of zeros with the same shape as the i'th output.</span><span>
|
|
</span><span id="line-336"></span><span> </span><span id="local-6989586621679156801"><span class="annot"><span class="annottext">zero :: OutputIx -> Tensor Build a
|
|
</span><a href="#local-6989586621679156801"><span class="hs-identifier hs-var hs-var">zero</span></a></span></span><span> </span><span id="local-6989586621679156800"><span class="annot"><span class="annottext">i :: OutputIx
|
|
</span><a href="#local-6989586621679156800"><span class="hs-identifier hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">zerosLike</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Tensor Build a)
|
|
-> Tensor Build a -> Tensor Build a
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutputIx -> NodeName -> Output
|
|
</span><span class="hs-identifier hs-var">Output</span></span><span> </span><span class="annot"><span class="annottext">OutputIx
|
|
</span><a href="#local-6989586621679156800"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156805"><span class="hs-identifier hs-var">o</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-337"></span><span>
|
|
</span><span id="line-338"></span><span>
|
|
</span><span id="line-339"></span><span class="hs-comment">-- | Update the pending gradients of a node's inputs.</span><span>
|
|
</span><span id="line-340"></span><span class="annot"><a href="TensorFlow.Gradient.html#updatePendingGradients"><span class="hs-identifier hs-type">updatePendingGradients</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679157288"><span class="annot"><a href="#local-6989586621679157288"><span class="hs-identifier hs-type">a</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">TensorType</span></span><span> </span><span class="annot"><a href="#local-6989586621679157288"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Num</span></span><span> </span><span class="annot"><a href="#local-6989586621679157288"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-341"></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Context</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeDef</span></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#EdgeLabel"><span class="hs-identifier hs-type">EdgeLabel</span></a></span><span>
|
|
</span><span id="line-342"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Maybe</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Value</span></span><span> </span><span class="annot"><a href="#local-6989586621679157288"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
|
|
</span><span id="line-343"></span><span> </span><span class="hs-comment">-- ^ Gradient of each input tensor.</span><span>
|
|
</span><span id="line-344"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientsState"><span class="hs-identifier hs-type">GradientsState</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157288"><span class="hs-identifier hs-type">a</span></a></span><span>
|
|
</span><span id="line-345"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientsState"><span class="hs-identifier hs-type">GradientsState</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157288"><span class="hs-identifier hs-type">a</span></a></span><span>
|
|
</span><span id="line-346"></span><span id="updatePendingGradients"><span class="annot"><span class="annottext">updatePendingGradients :: Context NodeDef EdgeLabel
|
|
-> [Maybe (Tensor Value a)] -> GradientsState a -> GradientsState a
|
|
</span><a href="TensorFlow.Gradient.html#updatePendingGradients"><span class="hs-identifier hs-var hs-var">updatePendingGradients</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156798"><span class="annot"><span class="annottext">inputEdges :: Adj EdgeLabel
|
|
</span><a href="#local-6989586621679156798"><span class="hs-identifier hs-var">inputEdges</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156797"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156797"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">)</span><span> </span><span id="local-6989586621679156796"><span class="annot"><span class="annottext">inputGrads :: [Maybe (Tensor Value a)]
|
|
</span><a href="#local-6989586621679156796"><span class="hs-identifier hs-var">inputGrads</span></a></span></span><span> </span><span id="local-6989586621679156795"><span class="annot"><span class="annottext">initState :: GradientsState a
|
|
</span><a href="#local-6989586621679156795"><span class="hs-identifier hs-var">initState</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-347"></span><span> </span><span class="annot"><span class="annottext">(GradientsState a -> (EdgeLabel, Node) -> GradientsState a)
|
|
-> GradientsState a -> Adj EdgeLabel -> GradientsState a
|
|
forall (t :: * -> *) b a.
|
|
Foldable t =>
|
|
(b -> a -> b) -> b -> t a -> b
|
|
</span><span class="hs-identifier hs-var">foldl'</span></span><span> </span><span class="annot"><span class="annottext">GradientsState a -> (EdgeLabel, Node) -> GradientsState a
|
|
</span><a href="#local-6989586621679156794"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
</span><a href="#local-6989586621679156795"><span class="hs-identifier hs-var">initState</span></a></span><span> </span><span class="annot"><span class="annottext">Adj EdgeLabel
|
|
</span><a href="#local-6989586621679156798"><span class="hs-identifier hs-var">inputEdges</span></a></span><span>
|
|
</span><span id="line-348"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-349"></span><span> </span><span class="annot"><a href="#local-6989586621679156794"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientsState"><span class="hs-identifier hs-type">GradientsState</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157288"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#EdgeLabel"><span class="hs-identifier hs-type">EdgeLabel</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Node</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientsState"><span class="hs-identifier hs-type">GradientsState</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157288"><span class="hs-identifier hs-type">a</span></a></span><span>
|
|
</span><span id="line-350"></span><span> </span><span id="local-6989586621679156794"><span class="annot"><span class="annottext">go :: GradientsState a -> (EdgeLabel, Node) -> GradientsState a
|
|
</span><a href="#local-6989586621679156794"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span id="local-6989586621679156793"><span class="annot"><span class="annottext">state :: GradientsState a
|
|
</span><a href="#local-6989586621679156793"><span class="hs-identifier hs-var">state</span></a></span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621679156792"><span class="annot"><span class="annottext">outIndex :: OutputIx
|
|
</span><a href="#local-6989586621679156792"><span class="hs-identifier hs-var">outIndex</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">OutputIx</span></span><span> </span><span id="local-6989586621679156790"><span class="annot"><span class="annottext">inIndex :: Node
|
|
</span><a href="#local-6989586621679156790"><span class="hs-identifier hs-var">inIndex</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156789"><span class="annot"><span class="annottext">node :: Node
|
|
</span><a href="#local-6989586621679156789"><span class="hs-identifier hs-var">node</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-351"></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Value a)
|
|
</span><a href="#local-6989586621679156788"><span class="hs-identifier hs-var">maybeGradient</span></a></span><span> </span><span class="hs-keyword">of</span><span>
|
|
</span><span id="line-352"></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Nothing</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
</span><a href="#local-6989586621679156793"><span class="hs-identifier hs-var">state</span></a></span><span>
|
|
</span><span id="line-353"></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Just</span></span><span> </span><span id="local-6989586621679156787"><span class="annot"><span class="annottext">g :: Tensor Value a
|
|
</span><a href="#local-6989586621679156787"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="hs-glyph">-></span><span>
|
|
</span><span id="line-354"></span><span> </span><span class="hs-comment">-- Add to the list of pending gradients for this tensor.</span><span>
|
|
</span><span id="line-355"></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
</span><a href="#local-6989586621679156793"><span class="hs-identifier hs-var">state</span></a></span><span> </span><span class="annot"><span class="annottext">GradientsState a
|
|
-> (GradientsState a -> GradientsState a) -> GradientsState a
|
|
forall s t. s -> (s -> t) -> t
|
|
</span><span class="hs-operator hs-var">&</span></span><span> </span><span class="annot"><span class="annottext">LensLike' f (GradientsState a) (Map Node (PendingGradients a))
|
|
forall a. Lens' (GradientsState a) (Map Node (PendingGradients a))
|
|
</span><a href="TensorFlow.Gradient.html#gradientsPending"><span class="hs-identifier hs-var">gradientsPending</span></a></span><span>
|
|
</span><span id="line-356"></span><span> </span><span class="annot"><span class="annottext">LensLike' f (GradientsState a) (Map Node (PendingGradients a))
|
|
-> (([Tensor Value a] -> f [Tensor Value a])
|
|
-> Map Node (PendingGradients a)
|
|
-> f (Map Node (PendingGradients a)))
|
|
-> ([Tensor Value a] -> f [Tensor Value a])
|
|
-> GradientsState a
|
|
-> f (GradientsState a)
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
-> Lens'
|
|
(Map Node (PendingGradients a)) (Maybe (PendingGradients a))
|
|
forall k v. Ord k => k -> Lens' (Map k v) (Maybe v)
|
|
</span><span class="hs-identifier hs-var">at</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156789"><span class="hs-identifier hs-var">node</span></a></span><span>
|
|
</span><span id="line-357"></span><span> </span><span class="annot"><span class="annottext">LensLike'
|
|
f (Map Node (PendingGradients a)) (Maybe (PendingGradients a))
|
|
-> (([Tensor Value a] -> f [Tensor Value a])
|
|
-> Maybe (PendingGradients a) -> f (Maybe (PendingGradients a)))
|
|
-> ([Tensor Value a] -> f [Tensor Value a])
|
|
-> Map Node (PendingGradients a)
|
|
-> f (Map Node (PendingGradients a))
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">LensLike' f (Maybe (PendingGradients a)) (PendingGradients a)
|
|
forall (t :: * -> *) v.
|
|
(Monoid (t v), Foldable t) =>
|
|
Lens' (Maybe (t v)) (t v)
|
|
</span><a href="TensorFlow.Gradient.html#nonEmpty"><span class="hs-identifier hs-var">nonEmpty</span></a></span><span>
|
|
</span><span id="line-358"></span><span> </span><span class="annot"><span class="annottext">LensLike' f (Maybe (PendingGradients a)) (PendingGradients a)
|
|
-> (([Tensor Value a] -> f [Tensor Value a])
|
|
-> PendingGradients a -> f (PendingGradients a))
|
|
-> ([Tensor Value a] -> f [Tensor Value a])
|
|
-> Maybe (PendingGradients a)
|
|
-> f (Maybe (PendingGradients a))
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">OutputIx -> Lens' (PendingGradients a) (Maybe [Tensor Value a])
|
|
forall v. OutputIx -> Lens' (IntMap v) (Maybe v)
|
|
</span><a href="TensorFlow.Gradient.html#outputIxAt"><span class="hs-identifier hs-var">outputIxAt</span></a></span><span> </span><span class="annot"><span class="annottext">OutputIx
|
|
</span><a href="#local-6989586621679156792"><span class="hs-identifier hs-var">outIndex</span></a></span><span>
|
|
</span><span id="line-359"></span><span> </span><span class="annot"><span class="annottext">LensLike' f (PendingGradients a) (Maybe [Tensor Value a])
|
|
-> (([Tensor Value a] -> f [Tensor Value a])
|
|
-> Maybe [Tensor Value a] -> f (Maybe [Tensor Value a]))
|
|
-> ([Tensor Value a] -> f [Tensor Value a])
|
|
-> PendingGradients a
|
|
-> f (PendingGradients a)
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">([Tensor Value a] -> f [Tensor Value a])
|
|
-> Maybe [Tensor Value a] -> f (Maybe [Tensor Value a])
|
|
forall (t :: * -> *) v.
|
|
(Monoid (t v), Foldable t) =>
|
|
Lens' (Maybe (t v)) (t v)
|
|
</span><a href="TensorFlow.Gradient.html#nonEmpty"><span class="hs-identifier hs-var">nonEmpty</span></a></span><span>
|
|
</span><span id="line-360"></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *).
|
|
Identical f =>
|
|
([Tensor Value a] -> f [Tensor Value a])
|
|
-> GradientsState a -> f (GradientsState a))
|
|
-> ([Tensor Value a] -> [Tensor Value a])
|
|
-> GradientsState a
|
|
-> GradientsState a
|
|
forall s t a b. Setter s t a b -> (a -> b) -> s -> t
|
|
</span><span class="hs-operator hs-var">%~</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156787"><span class="hs-identifier hs-var">g</span></a></span><span class="annot"><span class="annottext">Tensor Value a -> [Tensor Value a] -> [Tensor Value a]
|
|
forall a. a -> [a] -> [a]
|
|
</span><span class="hs-glyph hs-var">:</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-361"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-362"></span><span> </span><span id="local-6989586621679156786"><span class="annot"><span class="annottext">badSizeErr :: Maybe (Tensor Value a)
|
|
</span><a href="#local-6989586621679156786"><span class="hs-identifier hs-var hs-var">badSizeErr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Char] -> Maybe (Tensor Value a)
|
|
forall a. HasCallStack => [Char] -> a
|
|
</span><span class="hs-identifier hs-var">error</span></span><span> </span><span class="annot"><span class="annottext">([Char] -> Maybe (Tensor Value a))
|
|
-> [Char] -> Maybe (Tensor Value a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">[Char] -> Node -> Node -> [Char] -> [Char]
|
|
forall r. PrintfType r => [Char] -> r
|
|
</span><span class="hs-identifier hs-var">printf</span></span><span> </span><span class="annot"><span class="hs-string">"updatePendingGradients: bad input index \
|
|
\%d for inputGrads of length %d in %s"</span></span><span>
|
|
</span><span id="line-364"></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156790"><span class="hs-identifier hs-var">inIndex</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Maybe (Tensor Value a)] -> Node
|
|
forall (t :: * -> *) a. Foldable t => t a -> Node
|
|
</span><span class="hs-identifier hs-var">length</span></span><span> </span><span class="annot"><span class="annottext">[Maybe (Tensor Value a)]
|
|
</span><a href="#local-6989586621679156796"><span class="hs-identifier hs-var">inputGrads</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-365"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> [Char]
|
|
forall a. Show a => a -> [Char]
|
|
</span><span class="hs-identifier hs-var">show</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156797"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef -> FoldLike Text NodeDef NodeDef Text Text -> Text
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">FoldLike Text NodeDef NodeDef Text Text
|
|
forall (f :: * -> *) s a.
|
|
(Functor f, HasField s "name" a) =>
|
|
LensLike' f s a
|
|
</span><span class="hs-identifier hs-var">name</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-366"></span><span> </span><span id="local-6989586621679156788"><span class="annot"><span class="annottext">maybeGradient :: Maybe (Tensor Value a)
|
|
</span><a href="#local-6989586621679156788"><span class="hs-identifier hs-var hs-var">maybeGradient</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Value a)
|
|
-> Maybe (Maybe (Tensor Value a)) -> Maybe (Tensor Value a)
|
|
forall a. a -> Maybe a -> a
|
|
</span><span class="hs-identifier hs-var">fromMaybe</span></span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Value a)
|
|
</span><a href="#local-6989586621679156786"><span class="hs-identifier hs-var">badSizeErr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Maybe (Tensor Value a)] -> Node -> Maybe (Maybe (Tensor Value a))
|
|
forall a. [a] -> Node -> Maybe a
|
|
</span><a href="TensorFlow.Gradient.html#safeIndex"><span class="hs-identifier hs-var">safeIndex</span></a></span><span> </span><span class="annot"><span class="annottext">[Maybe (Tensor Value a)]
|
|
</span><a href="#local-6989586621679156796"><span class="hs-identifier hs-var">inputGrads</span></a></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156790"><span class="hs-identifier hs-var">inIndex</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-367"></span><span>
|
|
</span><span id="line-368"></span><span>
|
|
</span><span id="line-369"></span><span class="hs-comment">-- | Create a graph that includes a node and its transitive dependencies.</span><span>
|
|
</span><span id="line-370"></span><span class="annot"><a href="TensorFlow.Gradient.html#createGraph"><span class="hs-identifier hs-type">createGraph</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeDef</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-371"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="TensorFlow.Gradient.html#Graph"><span class="hs-identifier hs-type">Graph</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Map</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">FGL.Node</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-372"></span><span id="createGraph"><span class="annot"><span class="annottext">createGraph :: NodeName -> (NodeName -> NodeDef) -> (Graph, Map NodeName Node)
|
|
</span><a href="TensorFlow.Gradient.html#createGraph"><span class="hs-identifier hs-var hs-var">createGraph</span></a></span></span><span> </span><span id="local-6989586621679156784"><span class="annot"><span class="annottext">nodeName :: NodeName
|
|
</span><a href="#local-6989586621679156784"><span class="hs-identifier hs-var">nodeName</span></a></span></span><span> </span><span id="local-6989586621679156783"><span class="annot"><span class="annottext">nodeDefLookup :: NodeName -> NodeDef
|
|
</span><a href="#local-6989586621679156783"><span class="hs-identifier hs-var">nodeDefLookup</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(NodeName -> NodeDef) -> Gr NodeName EdgeLabel -> Graph
|
|
forall (gr :: * -> * -> *) a c b.
|
|
DynGraph gr =>
|
|
(a -> c) -> gr a b -> gr c b
|
|
</span><span class="hs-identifier hs-var">FGL.nmap</span></span><span> </span><span class="annot"><span class="annottext">NodeName -> NodeDef
|
|
</span><a href="#local-6989586621679156783"><span class="hs-identifier hs-var">nodeDefLookup</span></a></span><span> </span><span class="annot"><span class="annottext">Gr NodeName EdgeLabel
|
|
</span><a href="#local-6989586621679156781"><span class="hs-identifier hs-var">graph</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Map NodeName Node
|
|
</span><a href="#local-6989586621679156780"><span class="hs-identifier hs-var">nodeMap</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-373"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-374"></span><span> </span><span class="hs-comment">-- Parse a tensor name.</span><span>
|
|
</span><span id="line-375"></span><span> </span><span class="annot"><a href="#local-6989586621679156779"><span class="hs-identifier hs-type">parseTensorName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Text</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Maybe</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">OutputIx</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-376"></span><span> </span><span id="local-6989586621679156779"><span class="annot"><span class="annottext">parseTensorName :: Text -> Maybe (NodeName, OutputIx)
|
|
</span><a href="#local-6989586621679156779"><span class="hs-identifier hs-var hs-var">parseTensorName</span></a></span></span><span> </span><span id="local-6989586621679156778"><span class="annot"><span class="annottext">n :: Text
|
|
</span><a href="#local-6989586621679156778"><span class="hs-identifier hs-var">n</span></a></span></span><span>
|
|
</span><span id="line-377"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Text -> Bool
|
|
</span><span class="hs-identifier hs-var">Text.null</span></span><span> </span><span class="annot"><span class="annottext">Text
|
|
</span><a href="#local-6989586621679156778"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Char] -> Maybe (NodeName, OutputIx)
|
|
forall a. HasCallStack => [Char] -> a
|
|
</span><span class="hs-identifier hs-var">error</span></span><span> </span><span class="annot"><span class="hs-string">"parseTensorName: empty name"</span></span><span>
|
|
</span><span id="line-378"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Text -> Char
|
|
</span><span class="hs-identifier hs-var">Text.head</span></span><span> </span><span class="annot"><span class="annottext">Text
|
|
</span><a href="#local-6989586621679156778"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">Char -> Char -> Bool
|
|
forall a. Eq a => a -> a -> Bool
|
|
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="hs-char">'^'</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (NodeName, OutputIx)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span> </span><span class="hs-comment">-- Control edge</span><span>
|
|
</span><span id="line-379"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">otherwise</span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-380"></span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156775"><span class="annot"><span class="annottext">nm :: Text
|
|
</span><a href="#local-6989586621679156775"><span class="hs-identifier hs-var">nm</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156774"><span class="annot"><span class="annottext">indexStr :: Text
|
|
</span><a href="#local-6989586621679156774"><span class="hs-identifier hs-var">indexStr</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Text -> Text -> (Text, Text)
|
|
</span><span class="hs-identifier hs-var">Text.breakOn</span></span><span> </span><span class="annot"><span class="hs-string">":"</span></span><span> </span><span class="annot"><span class="annottext">Text
|
|
</span><a href="#local-6989586621679156778"><span class="hs-identifier hs-var">n</span></a></span><span>
|
|
</span><span id="line-381"></span><span> </span><span id="local-6989586621679156772"><span class="annot"><span class="annottext">index :: Node
|
|
</span><a href="#local-6989586621679156772"><span class="hs-identifier hs-var hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Text -> Bool
|
|
</span><span class="hs-identifier hs-var">Text.null</span></span><span> </span><span class="annot"><span class="annottext">Text
|
|
</span><a href="#local-6989586621679156774"><span class="hs-identifier hs-var">indexStr</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="hs-number">0</span></span><span>
|
|
</span><span id="line-382"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">otherwise</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Char] -> Node
|
|
forall a. Read a => [Char] -> a
|
|
</span><span class="hs-identifier hs-var">read</span></span><span> </span><span class="annot"><span class="annottext">([Char] -> Node) -> [Char] -> Node
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Text -> [Char]
|
|
</span><span class="hs-identifier hs-var">Text.unpack</span></span><span> </span><span class="annot"><span class="annottext">(Text -> [Char]) -> Text -> [Char]
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Text -> Text
|
|
</span><span class="hs-identifier hs-var">Text.tail</span></span><span> </span><span class="annot"><span class="annottext">Text
|
|
</span><a href="#local-6989586621679156774"><span class="hs-identifier hs-var">indexStr</span></a></span><span>
|
|
</span><span id="line-383"></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(NodeName, OutputIx) -> Maybe (NodeName, OutputIx)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> NodeName
|
|
</span><span class="hs-identifier hs-var">NodeName</span></span><span> </span><span class="annot"><span class="annottext">Text
|
|
</span><a href="#local-6989586621679156775"><span class="hs-identifier hs-var">nm</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Node -> OutputIx
|
|
</span><span class="hs-identifier hs-var">OutputIx</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156772"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-384"></span><span>
|
|
</span><span id="line-385"></span><span> </span><span class="hs-comment">-- Build a map from node name to outward edges.</span><span>
|
|
</span><span id="line-386"></span><span> </span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-387"></span><span> </span><span class="hs-comment">-- The state is the set of visited nodes.</span><span>
|
|
</span><span id="line-388"></span><span> </span><span class="annot"><a href="#local-6989586621679156769"><span class="hs-identifier hs-type">collect</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Maybe</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">OutputIx</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">OutputIx</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-389"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span>
|
|
</span><span id="line-390"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">State</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Set</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-391"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Map</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">OutputIx</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">OutputIx</span></span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-392"></span><span> </span><span id="local-6989586621679156769"><span class="annot"><span class="annottext">collect :: Maybe (NodeName, OutputIx, OutputIx)
|
|
-> NodeName
|
|
-> State
|
|
(Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)])
|
|
</span><a href="#local-6989586621679156769"><span class="hs-identifier hs-var hs-var">collect</span></a></span></span><span> </span><span id="local-6989586621679156768"><span class="annot"><span class="annottext">outgoingEdge :: Maybe (NodeName, OutputIx, OutputIx)
|
|
</span><a href="#local-6989586621679156768"><span class="hs-identifier hs-var">outgoingEdge</span></a></span></span><span> </span><span id="local-6989586621679156767"><span class="annot"><span class="annottext">nm :: NodeName
|
|
</span><a href="#local-6989586621679156767"><span class="hs-identifier hs-var">nm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
|
|
</span><span id="line-393"></span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679156766"><span class="annot"><span class="annottext">nextLookup :: Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
</span><a href="#local-6989586621679156766"><span class="hs-identifier hs-var hs-var">nextLookup</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
-> [(NodeName, OutputIx, OutputIx)]
|
|
-> Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
forall k a. k -> a -> Map k a
|
|
</span><span class="hs-identifier hs-var">Map.singleton</span></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156767"><span class="hs-identifier hs-var">nm</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (NodeName, OutputIx, OutputIx)
|
|
-> [(NodeName, OutputIx, OutputIx)]
|
|
forall a. Maybe a -> [a]
|
|
</span><span class="hs-identifier hs-var">maybeToList</span></span><span> </span><span class="annot"><span class="annottext">Maybe (NodeName, OutputIx, OutputIx)
|
|
</span><a href="#local-6989586621679156768"><span class="hs-identifier hs-var">outgoingEdge</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-394"></span><span> </span><span id="local-6989586621679156764"><span class="annot"><span class="annottext">Bool
|
|
</span><a href="#local-6989586621679156764"><span class="hs-identifier hs-var">seen</span></a></span></span><span> </span><span class="hs-glyph"><-</span><span> </span><span class="annot"><span class="annottext">(Set NodeName -> Bool) -> StateT (Set NodeName) Identity Bool
|
|
forall s (m :: * -> *) a. MonadState s m => (s -> a) -> m a
|
|
</span><span class="hs-identifier hs-var">gets</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeName -> Set NodeName -> Bool
|
|
forall a. Ord a => a -> Set a -> Bool
|
|
</span><span class="hs-identifier hs-var">Set.member</span></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156767"><span class="hs-identifier hs-var">nm</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-395"></span><span> </span><span class="annot"><span class="annottext">(Set NodeName -> Set NodeName) -> StateT (Set NodeName) Identity ()
|
|
forall s (m :: * -> *). MonadState s m => (s -> s) -> m ()
|
|
</span><span class="hs-identifier hs-var">modify</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeName -> Set NodeName -> Set NodeName
|
|
forall a. Ord a => a -> Set a -> Set a
|
|
</span><span class="hs-identifier hs-var">Set.insert</span></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156767"><span class="hs-identifier hs-var">nm</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-396"></span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><a href="#local-6989586621679156764"><span class="hs-identifier hs-var">seen</span></a></span><span>
|
|
</span><span id="line-397"></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
-> State
|
|
(Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)])
|
|
forall (f :: * -> *) a. Applicative f => a -> f a
|
|
</span><span class="hs-identifier hs-var">pure</span></span><span> </span><span class="annot"><span class="annottext">Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
</span><a href="#local-6989586621679156766"><span class="hs-identifier hs-var">nextLookup</span></a></span><span>
|
|
</span><span id="line-398"></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span>
|
|
</span><span id="line-399"></span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679156761"><span class="annot"><span class="annottext">inputs :: [Text]
|
|
</span><a href="#local-6989586621679156761"><span class="hs-identifier hs-var hs-var">inputs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeName -> NodeDef
|
|
</span><a href="#local-6989586621679156783"><span class="hs-identifier hs-var">nodeDefLookup</span></a></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156767"><span class="hs-identifier hs-var">nm</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef -> FoldLike [Text] NodeDef NodeDef [Text] [Text] -> [Text]
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">FoldLike [Text] NodeDef NodeDef [Text] [Text]
|
|
forall (f :: * -> *) s a.
|
|
(Functor f, HasField s "input" a) =>
|
|
LensLike' f s a
|
|
</span><span class="hs-identifier hs-var">input</span></span><span>
|
|
</span><span id="line-400"></span><span> </span><span id="local-6989586621679156760"><span class="annot"><span class="annottext">recurse :: OutputIx
|
|
-> (NodeName, OutputIx)
|
|
-> State
|
|
(Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)])
|
|
</span><a href="#local-6989586621679156760"><span class="hs-identifier hs-var hs-var">recurse</span></a></span></span><span> </span><span id="local-6989586621679156759"><span class="annot"><span class="annottext">inIndex :: OutputIx
|
|
</span><a href="#local-6989586621679156759"><span class="hs-identifier hs-var">inIndex</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156758"><span class="annot"><span class="annottext">parentName :: NodeName
|
|
</span><a href="#local-6989586621679156758"><span class="hs-identifier hs-var">parentName</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156757"><span class="annot"><span class="annottext">outIndex :: OutputIx
|
|
</span><a href="#local-6989586621679156757"><span class="hs-identifier hs-var">outIndex</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-401"></span><span> </span><span class="annot"><span class="annottext">Maybe (NodeName, OutputIx, OutputIx)
|
|
-> NodeName
|
|
-> State
|
|
(Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)])
|
|
</span><a href="#local-6989586621679156769"><span class="hs-identifier hs-var">collect</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(NodeName, OutputIx, OutputIx)
|
|
-> Maybe (NodeName, OutputIx, OutputIx)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156767"><span class="hs-identifier hs-var">nm</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">OutputIx
|
|
</span><a href="#local-6989586621679156757"><span class="hs-identifier hs-var">outIndex</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">OutputIx
|
|
</span><a href="#local-6989586621679156759"><span class="hs-identifier hs-var">inIndex</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156758"><span class="hs-identifier hs-var">parentName</span></a></span><span>
|
|
</span><span id="line-402"></span><span> </span><span id="local-6989586621679156756"><span class="annot"><span class="annottext">[Map NodeName [(NodeName, OutputIx, OutputIx)]]
|
|
</span><a href="#local-6989586621679156756"><span class="hs-identifier hs-var">subEdgeLookups</span></a></span></span><span> </span><span class="hs-glyph"><-</span><span>
|
|
</span><span id="line-403"></span><span> </span><span class="annot"><span class="annottext">(OutputIx
|
|
-> (NodeName, OutputIx)
|
|
-> State
|
|
(Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)]))
|
|
-> [OutputIx]
|
|
-> [(NodeName, OutputIx)]
|
|
-> StateT
|
|
(Set NodeName)
|
|
Identity
|
|
[Map NodeName [(NodeName, OutputIx, OutputIx)]]
|
|
forall (m :: * -> *) a b c.
|
|
Applicative m =>
|
|
(a -> b -> m c) -> [a] -> [b] -> m [c]
|
|
</span><span class="hs-identifier hs-var">zipWithM</span></span><span> </span><span class="annot"><span class="annottext">OutputIx
|
|
-> (NodeName, OutputIx)
|
|
-> State
|
|
(Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)])
|
|
</span><a href="#local-6989586621679156760"><span class="hs-identifier hs-var">recurse</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-number">0</span></span><span class="hs-glyph">..</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">([(NodeName, OutputIx)]
|
|
-> StateT
|
|
(Set NodeName)
|
|
Identity
|
|
[Map NodeName [(NodeName, OutputIx, OutputIx)]])
|
|
-> [(NodeName, OutputIx)]
|
|
-> StateT
|
|
(Set NodeName)
|
|
Identity
|
|
[Map NodeName [(NodeName, OutputIx, OutputIx)]]
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(Text -> Maybe (NodeName, OutputIx))
|
|
-> [Text] -> [(NodeName, OutputIx)]
|
|
forall a b. (a -> Maybe b) -> [a] -> [b]
|
|
</span><span class="hs-identifier hs-var">mapMaybe</span></span><span> </span><span class="annot"><span class="annottext">Text -> Maybe (NodeName, OutputIx)
|
|
</span><a href="#local-6989586621679156779"><span class="hs-identifier hs-var">parseTensorName</span></a></span><span> </span><span class="annot"><span class="annottext">[Text]
|
|
</span><a href="#local-6989586621679156761"><span class="hs-identifier hs-var">inputs</span></a></span><span>
|
|
</span><span id="line-404"></span><span> </span><span class="annot"><span class="annottext">Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
-> State
|
|
(Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)])
|
|
forall (f :: * -> *) a. Applicative f => a -> f a
|
|
</span><span class="hs-identifier hs-var">pure</span></span><span> </span><span class="annot"><span class="annottext">(Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
-> State
|
|
(Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)]))
|
|
-> Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
-> State
|
|
(Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)])
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">([(NodeName, OutputIx, OutputIx)]
|
|
-> [(NodeName, OutputIx, OutputIx)]
|
|
-> [(NodeName, OutputIx, OutputIx)])
|
|
-> [Map NodeName [(NodeName, OutputIx, OutputIx)]]
|
|
-> Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
forall (f :: * -> *) k a.
|
|
(Foldable f, Ord k) =>
|
|
(a -> a -> a) -> f (Map k a) -> Map k a
|
|
</span><span class="hs-identifier hs-var">Map.unionsWith</span></span><span> </span><span class="annot"><span class="annottext">[(NodeName, OutputIx, OutputIx)]
|
|
-> [(NodeName, OutputIx, OutputIx)]
|
|
-> [(NodeName, OutputIx, OutputIx)]
|
|
forall a. [a] -> [a] -> [a]
|
|
</span><span class="hs-operator hs-var">(++)</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
</span><a href="#local-6989586621679156766"><span class="hs-identifier hs-var">nextLookup</span></a></span><span class="annot"><span class="annottext">Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
-> [Map NodeName [(NodeName, OutputIx, OutputIx)]]
|
|
-> [Map NodeName [(NodeName, OutputIx, OutputIx)]]
|
|
forall a. a -> [a] -> [a]
|
|
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[Map NodeName [(NodeName, OutputIx, OutputIx)]]
|
|
</span><a href="#local-6989586621679156756"><span class="hs-identifier hs-var">subEdgeLookups</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-405"></span><span>
|
|
</span><span id="line-406"></span><span> </span><span id="local-6989586621679156754"><span class="annot"><span class="annottext">edgeLookup :: Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
</span><a href="#local-6989586621679156754"><span class="hs-identifier hs-var hs-var">edgeLookup</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">State
|
|
(Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)])
|
|
-> Set NodeName -> Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
forall s a. State s a -> s -> a
|
|
</span><span class="hs-identifier hs-var">evalState</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (NodeName, OutputIx, OutputIx)
|
|
-> NodeName
|
|
-> State
|
|
(Set NodeName) (Map NodeName [(NodeName, OutputIx, OutputIx)])
|
|
</span><a href="#local-6989586621679156769"><span class="hs-identifier hs-var">collect</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (NodeName, OutputIx, OutputIx)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156784"><span class="hs-identifier hs-var">nodeName</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Set NodeName
|
|
forall a. Set a
|
|
</span><span class="hs-identifier hs-var">Set.empty</span></span><span>
|
|
</span><span id="line-407"></span><span> </span><span class="hs-comment">-- Associate an ID with each node name.</span><span>
|
|
</span><span id="line-408"></span><span> </span><span id="local-6989586621679156780"><span class="annot"><span class="annottext">nodeMap :: Map NodeName Node
|
|
</span><a href="#local-6989586621679156780"><span class="hs-identifier hs-var hs-var">nodeMap</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(NodeName, Node)] -> Map NodeName Node
|
|
forall k a. Ord k => [(k, a)] -> Map k a
|
|
</span><span class="hs-identifier hs-var">Map.fromList</span></span><span> </span><span class="annot"><span class="annottext">([(NodeName, Node)] -> Map NodeName Node)
|
|
-> [(NodeName, Node)] -> Map NodeName Node
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">[NodeName] -> [Node] -> [(NodeName, Node)]
|
|
forall a b. [a] -> [b] -> [(a, b)]
|
|
</span><span class="hs-identifier hs-var">zip</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map NodeName [(NodeName, OutputIx, OutputIx)] -> [NodeName]
|
|
forall k a. Map k a -> [k]
|
|
</span><span class="hs-identifier hs-var">Map.keys</span></span><span> </span><span class="annot"><span class="annottext">Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
</span><a href="#local-6989586621679156754"><span class="hs-identifier hs-var">edgeLookup</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-number">0</span></span><span class="hs-glyph">..</span><span class="hs-special">]</span><span>
|
|
</span><span id="line-409"></span><span> </span><span class="hs-comment">-- Create the graph.</span><span>
|
|
</span><span id="line-410"></span><span> </span><span id="local-6989586621679156781"><span class="annot"><span class="annottext">graph :: Gr NodeName EdgeLabel
|
|
</span><a href="#local-6989586621679156781"><span class="hs-identifier hs-var hs-var">graph</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[LNode NodeName] -> [LEdge EdgeLabel] -> Gr NodeName EdgeLabel
|
|
forall (gr :: * -> * -> *) a b.
|
|
Graph gr =>
|
|
[LNode a] -> [LEdge b] -> gr a b
|
|
</span><span class="hs-identifier hs-var">FGL.mkGraph</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(NodeName, Node) -> LNode NodeName
|
|
forall a b. (a, b) -> (b, a)
|
|
</span><span class="hs-identifier hs-var">swap</span></span><span> </span><span class="annot"><span class="annottext">((NodeName, Node) -> LNode NodeName)
|
|
-> [(NodeName, Node)] -> [LNode NodeName]
|
|
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
|
|
</span><span class="hs-operator hs-var"><$></span></span><span> </span><span class="annot"><span class="annottext">Map NodeName Node -> [(NodeName, Node)]
|
|
forall k a. Map k a -> [(k, a)]
|
|
</span><span class="hs-identifier hs-var">Map.toList</span></span><span> </span><span class="annot"><span class="annottext">Map NodeName Node
|
|
</span><a href="#local-6989586621679156780"><span class="hs-identifier hs-var">nodeMap</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-411"></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map NodeName Node
|
|
</span><a href="#local-6989586621679156780"><span class="hs-identifier hs-var">nodeMap</span></a></span><span> </span><span class="annot"><span class="annottext">Map NodeName Node -> NodeName -> Node
|
|
forall k a. Ord k => Map k a -> k -> a
|
|
</span><span class="hs-operator hs-var">Map.!</span></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156748"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Map NodeName Node
|
|
</span><a href="#local-6989586621679156780"><span class="hs-identifier hs-var">nodeMap</span></a></span><span> </span><span class="annot"><span class="annottext">Map NodeName Node -> NodeName -> Node
|
|
forall k a. Ord k => Map k a -> k -> a
|
|
</span><span class="hs-operator hs-var">Map.!</span></span><span> </span><span class="annot"><span class="annottext">NodeName
|
|
</span><a href="#local-6989586621679156747"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OutputIx
|
|
</span><a href="#local-6989586621679156746"><span class="hs-identifier hs-var">i</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">OutputIx
|
|
</span><a href="#local-6989586621679156745"><span class="hs-identifier hs-var">j</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-412"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156748"><span class="annot"><span class="annottext">n :: NodeName
|
|
</span><a href="#local-6989586621679156748"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156744"><span class="annot"><span class="annottext">edges :: [(NodeName, OutputIx, OutputIx)]
|
|
</span><a href="#local-6989586621679156744"><span class="hs-identifier hs-var">edges</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph"><-</span><span> </span><span class="annot"><span class="annottext">Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
-> [(NodeName, [(NodeName, OutputIx, OutputIx)])]
|
|
forall k a. Map k a -> [(k, a)]
|
|
</span><span class="hs-identifier hs-var">Map.toList</span></span><span> </span><span class="annot"><span class="annottext">Map NodeName [(NodeName, OutputIx, OutputIx)]
|
|
</span><a href="#local-6989586621679156754"><span class="hs-identifier hs-var">edgeLookup</span></a></span><span>
|
|
</span><span id="line-413"></span><span> </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156747"><span class="annot"><span class="annottext">m :: NodeName
|
|
</span><a href="#local-6989586621679156747"><span class="hs-identifier hs-var">m</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156746"><span class="annot"><span class="annottext">i :: OutputIx
|
|
</span><a href="#local-6989586621679156746"><span class="hs-identifier hs-var">i</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156745"><span class="annot"><span class="annottext">j :: OutputIx
|
|
</span><a href="#local-6989586621679156745"><span class="hs-identifier hs-var">j</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph"><-</span><span> </span><span class="annot"><span class="annottext">[(NodeName, OutputIx, OutputIx)]
|
|
</span><a href="#local-6989586621679156744"><span class="hs-identifier hs-var">edges</span></a></span><span>
|
|
</span><span id="line-414"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-415"></span><span>
|
|
</span><span id="line-416"></span><span class="hs-comment">-- | Function to compute the gradient of y w.r.t. each input.</span><span>
|
|
</span><span id="line-417"></span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-418"></span><span class="hs-comment">-- Let y be an arbitrary tensor</span><span>
|
|
</span><span id="line-419"></span><span class="hs-comment">-- and [w_0, ..., w_n] be the output tensors of a node</span><span>
|
|
</span><span id="line-420"></span><span class="hs-comment">-- and [v_0, ..., v_n] be the input tensors of the same node.</span><span>
|
|
</span><span id="line-421"></span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-422"></span><span class="hs-comment">-- Given [∂y/∂w_0, ..., ∂y/∂w_n] and [v_0, ..., v_n], a GradientFunc computes</span><span>
|
|
</span><span id="line-423"></span><span class="hs-comment">-- [∂y/∂v_0, ..., ∂y/∂v_n] for a particular op type.</span><span>
|
|
</span><span id="line-424"></span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-425"></span><span class="hs-comment">-- A Nothing gradient is equivalent to zero (but allows for short circuiting</span><span>
|
|
</span><span id="line-426"></span><span class="hs-comment">-- computation when all the gradients for something are Nothing).</span><span>
|
|
</span><span id="line-427"></span><span class="hs-keyword">type</span><span> </span><span id="GradientFunc"><span class="annot"><a href="TensorFlow.Gradient.html#GradientFunc"><span class="hs-identifier hs-var">GradientFunc</span></a></span></span><span> </span><span id="local-6989586621679156743"><span class="annot"><a href="#local-6989586621679156743"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeDef</span></span><span>
|
|
</span><span id="line-428"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Output</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-429"></span><span> </span><span class="hs-comment">-- ^ Input tensors.</span><span>
|
|
</span><span id="line-430"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Value</span></span><span> </span><span class="annot"><a href="#local-6989586621679156743"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-431"></span><span> </span><span class="hs-comment">-- ^ Gradient of y w.r.t. each output tensor.</span><span>
|
|
</span><span id="line-432"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Maybe</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679156743"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
|
|
</span><span id="line-433"></span><span> </span><span class="hs-comment">-- ^ Gradient of y w.r.t. each input tensor.</span><span>
|
|
</span><span id="line-434"></span><span>
|
|
</span><span id="line-435"></span><span>
|
|
</span><span id="line-436"></span><span class="hs-comment">-- TODO(fmayle): Assert the type is correct.</span><span>
|
|
</span><span id="line-437"></span><span class="hs-comment">-- | Create a Tensor from an Output.</span><span>
|
|
</span><span id="line-438"></span><span id="local-6989586621679157241"><span class="annot"><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-type">toT</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Output</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157241"><span class="hs-identifier hs-type">a</span></a></span></span><span>
|
|
</span><span id="line-439"></span><span id="toT"><span class="annot"><span class="annottext">toT :: Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var hs-var">toT</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Build Output -> Tensor Build a
|
|
forall (v :: * -> *) a. TensorKind v => v Output -> Tensor v a
|
|
</span><span class="hs-identifier hs-var">Tensor</span></span><span> </span><span class="annot"><span class="annottext">(Build Output -> Tensor Build a)
|
|
-> (Output -> Build Output) -> Output -> Tensor Build a
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">Output -> Build Output
|
|
forall (f :: * -> *) a. Applicative f => a -> f a
|
|
</span><span class="hs-identifier hs-var">pure</span></span><span>
|
|
</span><span id="line-440"></span><span>
|
|
</span><span id="line-441"></span><span>
|
|
</span><span id="line-442"></span><span class="hs-comment">-- | Wrapper around `TensorFlow.GenOps.Core.slice` that builds vectors from scalars for</span><span>
|
|
</span><span id="line-443"></span><span class="hs-comment">-- simple slicing operations.</span><span>
|
|
</span><span id="line-444"></span><span class="annot"><a href="TensorFlow.Gradient.html#flatSlice"><span class="hs-identifier hs-type">flatSlice</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679157116"><span class="annot"><a href="#local-6989586621679157116"><span class="hs-identifier hs-type">v1</span></a></span></span><span> </span><span id="local-6989586621679157117"><span class="annot"><a href="#local-6989586621679157117"><span class="hs-identifier hs-type">t</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><span class="hs-identifier hs-type">TensorType</span></span><span> </span><span class="annot"><a href="#local-6989586621679157117"><span class="hs-identifier hs-type">t</span></a></span><span>
|
|
</span><span id="line-445"></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><a href="#local-6989586621679157116"><span class="hs-identifier hs-type">v1</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157117"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="hs-comment">-- ^ __input__</span><span>
|
|
</span><span id="line-446"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span> </span><span class="hs-comment">-- ^ __begin__: specifies the offset into the first dimension of</span><span>
|
|
</span><span id="line-447"></span><span> </span><span class="hs-comment">-- 'input' to slice from.</span><span>
|
|
</span><span id="line-448"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span> </span><span class="hs-comment">-- ^ __size__: specifies the number of elements of the first dimension</span><span>
|
|
</span><span id="line-449"></span><span> </span><span class="hs-comment">-- of 'input' to slice. If size is -1, all remaining elements in the dimension</span><span>
|
|
</span><span id="line-450"></span><span> </span><span class="hs-comment">-- are included in the slice (i.e. this is equivalent to setting</span><span>
|
|
</span><span id="line-451"></span><span> </span><span class="hs-comment">-- size = input.dim_size(0) - begin).</span><span>
|
|
</span><span id="line-452"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157117"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="hs-comment">-- ^ __output__</span><span>
|
|
</span><span id="line-453"></span><span id="flatSlice"><span class="annot"><span class="annottext">flatSlice :: Tensor v1 t -> Int32 -> Int32 -> Tensor Build t
|
|
</span><a href="TensorFlow.Gradient.html#flatSlice"><span class="hs-identifier hs-var hs-var">flatSlice</span></a></span></span><span> </span><span id="local-6989586621679156740"><span class="annot"><span class="annottext">t :: Tensor v1 t
|
|
</span><a href="#local-6989586621679156740"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span id="local-6989586621679156739"><span class="annot"><span class="annottext">begin :: Int32
|
|
</span><a href="#local-6989586621679156739"><span class="hs-identifier hs-var">begin</span></a></span></span><span> </span><span id="local-6989586621679156738"><span class="annot"><span class="annottext">size :: Int32
|
|
</span><a href="#local-6989586621679156738"><span class="hs-identifier hs-var">size</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor v1 t
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build t
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t index.
|
|
(TensorType t, OneOf '[Int32, Int64] index) =>
|
|
Tensor v'1 t
|
|
-> Tensor v'2 index -> Tensor v'3 index -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.slice</span></span><span> </span><span class="annot"><span class="annottext">Tensor v1 t
|
|
</span><a href="#local-6989586621679156740"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Int32] -> Tensor Build Int32
|
|
forall a. TensorType a => [a] -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#vector"><span class="hs-identifier hs-var">vector</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int32
|
|
</span><a href="#local-6989586621679156739"><span class="hs-identifier hs-var">begin</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Int32] -> Tensor Build Int32
|
|
forall a. TensorType a => [a] -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#vector"><span class="hs-identifier hs-var">vector</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int32
|
|
</span><a href="#local-6989586621679156738"><span class="hs-identifier hs-var">size</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-454"></span><span>
|
|
</span><span id="line-455"></span><span class="annot"><a href="TensorFlow.Gradient.html#nodeDefName"><span class="hs-identifier hs-type">nodeDefName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeDef</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeName</span></span><span>
|
|
</span><span id="line-456"></span><span id="nodeDefName"><span class="annot"><span class="annottext">nodeDefName :: NodeDef -> NodeName
|
|
</span><a href="TensorFlow.Gradient.html#nodeDefName"><span class="hs-identifier hs-var hs-var">nodeDefName</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Text -> NodeName
|
|
</span><span class="hs-identifier hs-var">NodeName</span></span><span> </span><span class="annot"><span class="annottext">(Text -> NodeName) -> (NodeDef -> Text) -> NodeDef -> NodeName
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">FoldLike Text NodeDef NodeDef Text Text -> NodeDef -> Text
|
|
forall a s t b. FoldLike a s t a b -> s -> a
|
|
</span><span class="hs-identifier hs-var">view</span></span><span> </span><span class="annot"><span class="annottext">FoldLike Text NodeDef NodeDef Text Text
|
|
forall (f :: * -> *) s a.
|
|
(Functor f, HasField s "name" a) =>
|
|
LensLike' f s a
|
|
</span><span class="hs-identifier hs-var">name</span></span><span>
|
|
</span><span id="line-457"></span><span>
|
|
</span><span id="line-458"></span><span class="hs-comment">-- | Gradient helper for binary component wise operations</span><span>
|
|
</span><span id="line-459"></span><span class="hs-comment">-- See https://github.com/tensorflow/tensorflow/blob/e9de087fa7f59c39bbe12ac2c83c5547c83f746c/tensorflow/core/ops/math_grad.cc#L329</span><span>
|
|
</span><span id="line-460"></span><span id="local-6989586621679157104"><span id="local-6989586621679157105"><span class="annot"><a href="TensorFlow.Gradient.html#gradForBinaryCwise"><span class="hs-identifier hs-type">gradForBinaryCwise</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><span class="hs-identifier hs-type">OneOf</span></span><span> </span><span class="hs-special">'</span><span class="hs-special">[</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int64</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Float</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Complex</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Float</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Complex</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Double</span></span><span> </span><span class="hs-special">]</span><span> </span><span class="annot"><a href="#local-6989586621679157105"><span class="hs-identifier hs-type">t</span></a></span><span>
|
|
</span><span id="line-461"></span><span> </span><span class="hs-special">)</span><span>
|
|
</span><span id="line-462"></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><a href="#local-6989586621679157104"><span class="hs-identifier hs-type">v1</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157105"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><a href="#local-6989586621679157104"><span class="hs-identifier hs-type">v1</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157105"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-463"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><a href="#local-6989586621679157104"><span class="hs-identifier hs-type">v1</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157105"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><a href="#local-6989586621679157104"><span class="hs-identifier hs-type">v1</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157105"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-464"></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Maybe</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157105"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span></span></span><span>
|
|
</span><span id="line-465"></span><span id="gradForBinaryCwise"><span class="annot"><span class="annottext">gradForBinaryCwise :: (Tensor v1 t, Tensor v1 t)
|
|
-> (Tensor v1 t, Tensor v1 t) -> [Maybe (Tensor Build t)]
|
|
</span><a href="TensorFlow.Gradient.html#gradForBinaryCwise"><span class="hs-identifier hs-var hs-var">gradForBinaryCwise</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156735"><span class="annot"><span class="annottext">x :: Tensor v1 t
|
|
</span><a href="#local-6989586621679156735"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156734"><span class="annot"><span class="annottext">gx :: Tensor v1 t
|
|
</span><a href="#local-6989586621679156734"><span class="hs-identifier hs-var">gx</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156733"><span class="annot"><span class="annottext">y :: Tensor v1 t
|
|
</span><a href="#local-6989586621679156733"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156732"><span class="annot"><span class="annottext">gy :: Tensor v1 t
|
|
</span><a href="#local-6989586621679156732"><span class="hs-identifier hs-var">gy</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-466"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build t -> Maybe (Tensor Build t)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build t
|
|
</span><a href="#local-6989586621679156731"><span class="hs-identifier hs-var">dx</span></a></span><span>
|
|
</span><span id="line-467"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build t -> Maybe (Tensor Build t)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build t
|
|
</span><a href="#local-6989586621679156730"><span class="hs-identifier hs-var">dy</span></a></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-468"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-469"></span><span> </span><span id="local-6989586621679156731"><span class="annot"><span class="annottext">dx :: Tensor Build t
|
|
</span><a href="#local-6989586621679156731"><span class="hs-identifier hs-var hs-var">dx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build t -> Tensor Build Int32 -> Tensor Build t
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor v1 t -> Tensor Build Int32 -> Tensor Build t
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sum</span></span><span> </span><span class="annot"><span class="annottext">Tensor v1 t
|
|
</span><a href="#local-6989586621679156734"><span class="hs-identifier hs-var">gx</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156729"><span class="hs-identifier hs-var">rx</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156728"><span class="hs-identifier hs-var">sx</span></a></span><span>
|
|
</span><span id="line-470"></span><span> </span><span id="local-6989586621679156730"><span class="annot"><span class="annottext">dy :: Tensor Build t
|
|
</span><a href="#local-6989586621679156730"><span class="hs-identifier hs-var hs-var">dy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build t -> Tensor Build Int32 -> Tensor Build t
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor v1 t -> Tensor Build Int32 -> Tensor Build t
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sum</span></span><span> </span><span class="annot"><span class="annottext">Tensor v1 t
|
|
</span><a href="#local-6989586621679156732"><span class="hs-identifier hs-var">gy</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156727"><span class="hs-identifier hs-var">ry</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156726"><span class="hs-identifier hs-var">sy</span></a></span><span>
|
|
</span><span id="line-471"></span><span> </span><span id="local-6989586621679156728"><span class="annot"><span class="annottext">sx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156728"><span class="hs-identifier hs-var hs-var">sx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor v1 t -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor v1 t
|
|
</span><a href="#local-6989586621679156735"><span class="hs-identifier hs-var">x</span></a></span><span>
|
|
</span><span id="line-472"></span><span> </span><span id="local-6989586621679156726"><span class="annot"><span class="annottext">sy :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156726"><span class="hs-identifier hs-var hs-var">sy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor v1 t -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor v1 t
|
|
</span><a href="#local-6989586621679156733"><span class="hs-identifier hs-var">y</span></a></span><span>
|
|
</span><span id="line-473"></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156729"><span class="annot"><span class="annottext">rx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156729"><span class="hs-identifier hs-var">rx</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156727"><span class="annot"><span class="annottext">ry :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156727"><span class="hs-identifier hs-var">ry</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
-> Tensor Build Int32 -> (Tensor Build Int32, Tensor Build Int32)
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Int32, Int64] t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> (Tensor Build t, Tensor Build t)
|
|
</span><span class="hs-identifier hs-var">broadcastGradientArgs</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156728"><span class="hs-identifier hs-var">sx</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156726"><span class="hs-identifier hs-var">sy</span></a></span><span>
|
|
</span><span id="line-474"></span><span>
|
|
</span><span id="line-475"></span><span class="hs-comment">-- | The gradient function for an op type.</span><span>
|
|
</span><span id="line-476"></span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-477"></span><span class="hs-comment">-- These implementations should match their python counterparts in:</span><span>
|
|
</span><span id="line-478"></span><span class="hs-comment">-- third_party/tensorflow/python/ops/*_grad.py</span><span>
|
|
</span><span id="line-479"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-type">opGrad</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679157265"><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-operator">.</span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientCompatible"><span class="hs-identifier hs-type">GradientCompatible</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Text</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><a href="TensorFlow.Gradient.html#GradientFunc"><span class="hs-identifier hs-type">GradientFunc</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span>
|
|
</span><span id="line-480"></span><span>
|
|
</span><span id="line-481"></span><span id="opGrad"><span class="annot"><span class="annottext">opGrad :: Text -> GradientFunc a
|
|
</span><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var hs-var">opGrad</span></a></span></span><span> </span><span class="hs-string">"Abs"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156725"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156725"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156724"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156724"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a
|
|
forall (v :: * -> *) a.
|
|
TensorKind v =>
|
|
Tensor v a -> Tensor Build a
|
|
</span><span class="hs-identifier hs-var">expr</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156724"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build a
|
|
forall a. Num a => a -> a -> a
|
|
</span><span class="hs-operator hs-var">*</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall a. Num a => a -> a
|
|
</span><span class="hs-identifier hs-var">signum</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156725"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-482"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Neg"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">_</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156721"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156721"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall a. Num a => a -> a
|
|
</span><span class="hs-identifier hs-var">negate</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Tensor Build a)
|
|
-> Tensor Build a -> Tensor Build a
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a
|
|
forall (v :: * -> *) a.
|
|
TensorKind v =>
|
|
Tensor v a -> Tensor Build a
|
|
</span><span class="hs-identifier hs-var">expr</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156721"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-483"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Relu"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156720"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156720"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156719"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156719"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Int16, Int32, Int64, Int8, Word16, Word32, Word64, Word8, Double,
|
|
Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reluGrad</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156719"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156720"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-484"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"ReluGrad"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">_</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156718"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156718"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156717"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156717"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Int16, Int32, Int64, Int8, Word16, Word32, Word64, Word8, Double,
|
|
Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reluGrad</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156717"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156718"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.zerosLike</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156718"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-485"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Tanh"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156716"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156716"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156715"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156715"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Complex Double, Complex Float, Word16, Double, Float] t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">tanhGrad</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
OneOf '[Complex Double, Complex Float, Word16, Double, Float] t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">tanh</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156716"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156715"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-486"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Sigmoid"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156714"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156714"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156713"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156713"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Complex Double, Complex Float, Word16, Double, Float] t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sigmoidGrad</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
OneOf '[Complex Double, Complex Float, Word16, Double, Float] t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sigmoid</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156714"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156713"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-487"></span><span>
|
|
</span><span id="line-488"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Concat"</span><span> </span><span class="hs-identifier">_</span><span> </span><span id="local-6989586621679156712"><span class="annot"><span class="annottext">_ix :: [Output]
|
|
</span><a href="#local-6989586621679156712"><span class="hs-identifier hs-var">_ix</span></a></span></span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156711"><span class="annot"><span class="annottext">dy :: Tensor Value a
|
|
</span><a href="#local-6989586621679156711"><span class="hs-identifier hs-var">dy</span></a></span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-489"></span><span> </span><span class="hs-comment">-- Concat concatenates input tensors</span><span>
|
|
</span><span id="line-490"></span><span> </span><span class="hs-comment">-- x1 of shape s1 = [k1, ..., ki_1, ..., kn]</span><span>
|
|
</span><span id="line-491"></span><span> </span><span class="hs-comment">-- x2 of shape s2 = [k1, ..., ki_2, ..., kn]</span><span>
|
|
</span><span id="line-492"></span><span> </span><span class="hs-comment">-- . . . . .</span><span>
|
|
</span><span id="line-493"></span><span> </span><span class="hs-comment">-- . . . . .</span><span>
|
|
</span><span id="line-494"></span><span> </span><span class="hs-comment">-- . . . . .</span><span>
|
|
</span><span id="line-495"></span><span> </span><span class="hs-comment">-- xm of shape sm = [k1, ..., ki_m, ..., kn]</span><span>
|
|
</span><span id="line-496"></span><span> </span><span class="hs-comment">-- along dimension i to an output tensor</span><span>
|
|
</span><span id="line-497"></span><span> </span><span class="hs-comment">-- y of shape sy = [k1, ..., k, ..., kn]</span><span>
|
|
</span><span id="line-498"></span><span> </span><span class="hs-comment">-- where k = sum ki = sum [ki_1,...,ki_m]</span><span>
|
|
</span><span id="line-499"></span><span> </span><span class="hs-comment">--</span><span>
|
|
</span><span id="line-500"></span><span> </span><span class="hs-comment">-- The incoming gradient dy from backpropagation is</span><span>
|
|
</span><span id="line-501"></span><span> </span><span class="hs-comment">-- simply forwarded split across input tensors yielding dx.</span><span>
|
|
</span><span id="line-502"></span><span> </span><span class="hs-comment">-- Forwarded gradients have shapes s = [s1, ..., sm].</span><span>
|
|
</span><span id="line-503"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156710"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">Node -> Node -> Bool
|
|
forall a. Eq a => a -> a -> Bool
|
|
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
-> [Maybe (Tensor Build a)] -> [Maybe (Tensor Build a)]
|
|
forall a. a -> [a] -> [a]
|
|
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a
|
|
forall (v :: * -> *) a.
|
|
TensorKind v =>
|
|
Tensor v a -> Tensor Build a
|
|
</span><span class="hs-identifier hs-var">expr</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156711"><span class="hs-identifier hs-var">dy</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-504"></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">otherwise</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
-> [Maybe (Tensor Build a)] -> [Maybe (Tensor Build a)]
|
|
forall a. a -> [a] -> [a]
|
|
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> [Tensor Build a] -> [Maybe (Tensor Build a)]
|
|
forall a b. (a -> b) -> [a] -> [b]
|
|
</span><span class="hs-identifier hs-var">map</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Tensor Build a]
|
|
</span><a href="#local-6989586621679156709"><span class="hs-identifier hs-var">dx</span></a></span><span> </span><span class="annot"><span class="annottext">[Tensor Build a] -> [Tensor Build Int32] -> [Tensor Build a]
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *).
|
|
[Tensor v'1 a] -> [Tensor v'2 Int32] -> [Tensor Build a]
|
|
</span><a href="#local-6989586621679156708"><span class="hs-operator hs-var">`reshapeZip`</span></a></span><span> </span><span class="annot"><span class="annottext">[Tensor Build Int32]
|
|
</span><a href="#local-6989586621679156707"><span class="hs-identifier hs-var">s</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-505"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-506"></span><span> </span><span id="local-6989586621679156708"><span class="annot"><span class="annottext">reshapeZip :: [Tensor v'1 a] -> [Tensor v'2 Int32] -> [Tensor Build a]
|
|
</span><a href="#local-6989586621679156708"><span class="hs-identifier hs-var hs-var">reshapeZip</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Tensor v'1 a -> Tensor v'2 Int32 -> Tensor Build a)
|
|
-> [Tensor v'1 a] -> [Tensor v'2 Int32] -> [Tensor Build a]
|
|
forall a b c. (a -> b -> c) -> [a] -> [b] -> [c]
|
|
</span><span class="hs-identifier hs-var">zipWith</span></span><span> </span><span class="annot"><span class="annottext">Tensor v'1 a -> Tensor v'2 Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span>
|
|
</span><span id="line-507"></span><span> </span><span id="local-6989586621679156709"><span class="annot"><span class="annottext">dx :: [Tensor Build a]
|
|
</span><a href="#local-6989586621679156709"><span class="hs-identifier hs-var hs-var">dx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int64
|
|
-> Tensor Value a
|
|
-> Tensor Build Int32
|
|
-> Tensor Build Int32
|
|
-> [Tensor Build a]
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t tlen.
|
|
(TensorType t, OneOf '[Int32, Int64] tlen) =>
|
|
Int64
|
|
-> Tensor v'1 t
|
|
-> Tensor v'2 tlen
|
|
-> Tensor v'3 Int32
|
|
-> [Tensor Build t]
|
|
</span><span class="hs-identifier hs-var">CoreOps.splitV</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node -> Int64
|
|
forall a b. (Integral a, Num b) => a -> b
|
|
</span><span class="hs-identifier hs-var">fromIntegral</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156710"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156711"><span class="hs-identifier hs-var">dy</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156704"><span class="hs-identifier hs-var">ki</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156703"><span class="hs-identifier hs-var">_i</span></a></span><span>
|
|
</span><span id="line-508"></span><span> </span><span class="annot"><a href="#local-6989586621679156707"><span class="hs-identifier hs-type">s</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-509"></span><span> </span><span id="local-6989586621679156707"><span class="annot"><span class="annottext">s :: [Tensor Build Int32]
|
|
</span><a href="#local-6989586621679156707"><span class="hs-identifier hs-var hs-var">s</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Tensor Build Int32)
|
|
-> [Tensor Build a] -> [Tensor Build Int32]
|
|
forall a b. (a -> b) -> [a] -> [b]
|
|
</span><span class="hs-identifier hs-var">map</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">[Tensor Build a]
|
|
</span><a href="#local-6989586621679156702"><span class="hs-identifier hs-var">x</span></a></span><span>
|
|
</span><span id="line-510"></span><span> </span><span class="annot"><a href="#local-6989586621679156702"><span class="hs-identifier hs-type">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-511"></span><span> </span><span id="local-6989586621679156702"><span class="annot"><span class="annottext">x :: [Tensor Build a]
|
|
</span><a href="#local-6989586621679156702"><span class="hs-identifier hs-var hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Output -> Tensor Build a) -> [Output] -> [Tensor Build a]
|
|
forall a b. (a -> b) -> [a] -> [b]
|
|
</span><span class="hs-identifier hs-var">map</span></span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="annot"><span class="annottext">([Output] -> [Tensor Build a]) -> [Output] -> [Tensor Build a]
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">[Output] -> [Output]
|
|
forall a. [a] -> [a]
|
|
</span><span class="hs-identifier hs-var">tail</span></span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156712"><span class="hs-identifier hs-var">_ix</span></a></span><span>
|
|
</span><span id="line-512"></span><span> </span><span class="hs-comment">-- i: concat dimension. Adjusted modulo n to handle negative indices.</span><span>
|
|
</span><span id="line-513"></span><span> </span><span id="local-6989586621679156703"><span class="annot"><span class="annottext">_i :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156703"><span class="hs-identifier hs-var hs-var">_i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Output] -> Output
|
|
forall a. [a] -> a
|
|
</span><span class="hs-identifier hs-var">head</span></span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156712"><span class="hs-identifier hs-var">_ix</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Int32, Int64, Word16, Word64, Double, Float] t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.floorMod`</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156698"><span class="hs-identifier hs-var">n</span></a></span><span>
|
|
</span><span id="line-514"></span><span> </span><span id="local-6989586621679156697"><span class="annot"><span class="annottext">i :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156697"><span class="hs-identifier hs-var hs-var">i</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156703"><span class="hs-identifier hs-var">_i</span></a></span><span> </span><span class="annot"><span class="annottext">(Tensor Build Int32 -> Tensor Build Int32)
|
|
-> Tensor Build Int32 -> Tensor Build Int32
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">[Int32] -> Tensor Build Int32
|
|
forall a. TensorType a => [a] -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#vector"><span class="hs-identifier hs-var">vector</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-number">1</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-515"></span><span> </span><span class="hs-comment">-- sizes along concatenated dimension</span><span>
|
|
</span><span id="line-516"></span><span> </span><span class="annot"><a href="#local-6989586621679156704"><span class="hs-identifier hs-type">ki</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span>
|
|
</span><span id="line-517"></span><span> </span><span id="local-6989586621679156704"><span class="annot"><span class="annottext">ki :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156704"><span class="hs-identifier hs-var hs-var">ki</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> [Tensor Build Int32] -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 Int32 -> [Tensor v'2 t] -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.concat</span></span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="annottext">([Tensor Build Int32] -> Tensor Build Int32)
|
|
-> [Tensor Build Int32] -> Tensor Build Int32
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build Int32 -> Tensor Build Int32)
|
|
-> [Tensor Build Int32] -> [Tensor Build Int32]
|
|
forall a b. (a -> b) -> [a] -> [b]
|
|
</span><span class="hs-identifier hs-var">map</span></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679156695"><span class="annot"><span class="annottext">t :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156695"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t index.
|
|
(TensorType t, OneOf '[Int32, Int64] index) =>
|
|
Tensor v'1 t
|
|
-> Tensor v'2 index -> Tensor v'3 index -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.slice</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156695"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156697"><span class="hs-identifier hs-var">i</span></a></span><span> </span><span class="annot"><span class="annottext">(Tensor Build Int32 -> Tensor Build Int32)
|
|
-> Tensor Build Int32 -> Tensor Build Int32
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">[Int32] -> Tensor Build Int32
|
|
forall a. TensorType a => [a] -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#vector"><span class="hs-identifier hs-var">vector</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-number">1</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Tensor Build Int32]
|
|
</span><a href="#local-6989586621679156707"><span class="hs-identifier hs-var">s</span></a></span><span>
|
|
</span><span id="line-518"></span><span> </span><span id="local-6989586621679156710"><span class="annot"><span class="annottext">m :: Node
|
|
</span><a href="#local-6989586621679156710"><span class="hs-identifier hs-var hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Tensor Build a] -> Node
|
|
forall (t :: * -> *) a. Foldable t => t a -> Node
|
|
</span><span class="hs-identifier hs-var">length</span></span><span> </span><span class="annot"><span class="annottext">[Tensor Build a]
|
|
</span><a href="#local-6989586621679156702"><span class="hs-identifier hs-var">x</span></a></span><span>
|
|
</span><span id="line-519"></span><span> </span><span id="local-6989586621679156698"><span class="annot"><span class="annottext">n :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156698"><span class="hs-identifier hs-var hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build Int32
|
|
</span><span class="hs-identifier hs-var">CoreOps.rank</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Tensor Build a] -> Tensor Build a
|
|
forall a. [a] -> a
|
|
</span><span class="hs-identifier hs-var">head</span></span><span> </span><span class="annot"><span class="annottext">[Tensor Build a]
|
|
</span><a href="#local-6989586621679156702"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-520"></span><span>
|
|
</span><span id="line-521"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Square"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156693"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156693"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156692"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156692"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-522"></span><span> </span><span class="hs-comment">-- TODO(fmayle): Handle complex numbers.</span><span>
|
|
</span><span id="line-523"></span><span> </span><span class="hs-comment">-- TODO(fmayle): The python code makes dz a control dependency of the 2*x</span><span>
|
|
</span><span id="line-524"></span><span> </span><span class="hs-comment">-- (for performance reasons?). Will need to put these functions in the Build</span><span>
|
|
</span><span id="line-525"></span><span> </span><span class="hs-comment">-- monad to replicate that.</span><span>
|
|
</span><span id="line-526"></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156692"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.mul`</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build a
|
|
forall a. Num a => a -> a -> a
|
|
</span><span class="hs-operator hs-var">*</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156693"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
|
|
</span><span id="line-527"></span><span>
|
|
</span><span id="line-528"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Gather"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156690"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156690"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156689"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156689"><span class="hs-identifier hs-var">indices</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156688"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156688"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-529"></span><span> </span><span class="hs-comment">-- TODO(fmayle): The python version uses a better performance implementation</span><span>
|
|
</span><span id="line-530"></span><span> </span><span class="hs-comment">-- when the shape is known without having to run the graph.</span><span>
|
|
</span><span id="line-531"></span><span> </span><span class="hs-comment">-- TODO(fmayle): We shouldn't convert the result to a dense tensor. Sparse</span><span>
|
|
</span><span id="line-532"></span><span> </span><span class="hs-comment">-- tensor support will require some thinking.</span><span>
|
|
</span><span id="line-533"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t tindices
|
|
tnumsegments.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tindices,
|
|
OneOf '[Int32, Int64] tnumsegments) =>
|
|
Tensor v'1 t
|
|
-> Tensor v'2 tindices -> Tensor v'3 tnumsegments -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.unsortedSegmentSum</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156686"><span class="hs-identifier hs-var">values</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156685"><span class="hs-identifier hs-var">indices'</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156684"><span class="hs-identifier hs-var">numRows</span></a></span><span>
|
|
</span><span id="line-534"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-535"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-536"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-537"></span><span> </span><span class="hs-comment">-- TODO(gnezdo): Use colocateWith but it requires Build monad.</span><span>
|
|
</span><span id="line-538"></span><span> </span><span id="local-6989586621679156683"><span class="annot"><span class="annottext">denseShape :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156683"><span class="hs-identifier hs-var hs-var">denseShape</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156690"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-539"></span><span> </span><span id="local-6989586621679156684"><span class="annot"><span class="annottext">numRows :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156684"><span class="hs-identifier hs-var hs-var">numRows</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32
|
|
forall a (v :: * -> *).
|
|
TensorType a =>
|
|
Tensor v a -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#scalarize"><span class="hs-identifier hs-var">scalarize</span></a></span><span> </span><span class="annot"><span class="annottext">(Tensor Build Int32 -> Tensor Build Int32)
|
|
-> Tensor Build Int32 -> Tensor Build Int32
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Int32 -> Int32 -> Tensor Build Int32
|
|
forall (v1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v1 t -> Int32 -> Int32 -> Tensor Build t
|
|
</span><a href="TensorFlow.Gradient.html#flatSlice"><span class="hs-identifier hs-var">flatSlice</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156683"><span class="hs-identifier hs-var">denseShape</span></a></span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-540"></span><span> </span><span id="local-6989586621679156682"><span class="annot"><span class="annottext">valuesShape :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156682"><span class="hs-identifier hs-var hs-var">valuesShape</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> [Tensor Build Int32] -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 Int32 -> [Tensor v'2 t] -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.concat</span></span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="TensorFlow.Gradient.html#allDimensions"><span class="hs-identifier hs-var">allDimensions</span></a></span><span>
|
|
</span><span id="line-541"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Int32 -> Int32 -> Tensor Build Int32
|
|
forall (v1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v1 t -> Int32 -> Int32 -> Tensor Build t
|
|
</span><a href="TensorFlow.Gradient.html#flatSlice"><span class="hs-identifier hs-var">flatSlice</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156683"><span class="hs-identifier hs-var">denseShape</span></a></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="annot"><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-542"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-543"></span><span> </span><span id="local-6989586621679156686"><span class="annot"><span class="annottext">values :: Tensor Build a
|
|
</span><a href="#local-6989586621679156686"><span class="hs-identifier hs-var hs-var">values</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156688"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156682"><span class="hs-identifier hs-var">valuesShape</span></a></span><span>
|
|
</span><span id="line-544"></span><span> </span><span class="hs-comment">-- TODO(fmayle): This could be either Int32 or Int64.</span><span>
|
|
</span><span id="line-545"></span><span> </span><span id="local-6989586621679156685"><span class="annot"><span class="annottext">indices' :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156685"><span class="hs-identifier hs-var hs-var">indices'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156689"><span class="hs-identifier hs-var">indices</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="TensorFlow.Gradient.html#allDimensions"><span class="hs-identifier hs-var">allDimensions</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span>
|
|
</span><span id="line-546"></span><span>
|
|
</span><span id="line-547"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Max"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156680"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156680"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156679"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156679"><span class="hs-identifier hs-var">indices</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156678"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156678"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-548"></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156677"><span class="hs-identifier hs-var">indicators</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.div`</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156675"><span class="hs-identifier hs-var">numSelected</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build a
|
|
forall a. Num a => a -> a -> a
|
|
</span><span class="hs-operator hs-var">*</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156674"><span class="hs-identifier hs-var">dz'</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-549"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-550"></span><span> </span><span id="local-6989586621679156673"><span class="annot"><span class="annottext">sx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156673"><span class="hs-identifier hs-var hs-var">sx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156680"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-551"></span><span> </span><span id="local-6989586621679156672"><span class="annot"><span class="annottext">outputShapeKeptDims :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156672"><span class="hs-identifier hs-var hs-var">outputShapeKeptDims</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall t1 t2 (v1 :: * -> *) (v2 :: * -> *).
|
|
(OneOf '[Int32, Int64] t1, OneOf '[Int32, Int64] t2) =>
|
|
Tensor v1 t1 -> Tensor v2 t2 -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#reducedShape"><span class="hs-identifier hs-var">reducedShape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156673"><span class="hs-identifier hs-var">sx</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156679"><span class="hs-identifier hs-var">indices</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-552"></span><span> </span><span id="local-6989586621679156671"><span class="annot"><span class="annottext">y :: Tensor Build a
|
|
</span><a href="#local-6989586621679156671"><span class="hs-identifier hs-var hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.max</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156680"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156679"><span class="hs-identifier hs-var">indices</span></a></span><span>
|
|
</span><span id="line-553"></span><span> </span><span id="local-6989586621679156669"><span class="annot"><span class="annottext">y' :: Tensor Build a
|
|
</span><a href="#local-6989586621679156669"><span class="hs-identifier hs-var hs-var">y'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156671"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156672"><span class="hs-identifier hs-var">outputShapeKeptDims</span></a></span><span>
|
|
</span><span id="line-554"></span><span> </span><span id="local-6989586621679156674"><span class="annot"><span class="annottext">dz' :: Tensor Build a
|
|
</span><a href="#local-6989586621679156674"><span class="hs-identifier hs-var hs-var">dz'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156678"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156672"><span class="hs-identifier hs-var">outputShapeKeptDims</span></a></span><span>
|
|
</span><span id="line-555"></span><span> </span><span id="local-6989586621679156677"><span class="annot"><span class="annottext">indicators :: Tensor Build a
|
|
</span><a href="#local-6989586621679156677"><span class="hs-identifier hs-var hs-var">indicators</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Bool -> Tensor Build a
|
|
forall (v'1 :: * -> *) srcT dstT.
|
|
(TensorType srcT, TensorType dstT) =>
|
|
Tensor v'1 srcT -> Tensor Build dstT
|
|
</span><span class="hs-identifier hs-var">CoreOps.cast</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build Bool -> Tensor Build a)
|
|
-> Tensor Build Bool -> Tensor Build a
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build Bool
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Bool, ByteString, Int16, Int32,
|
|
Int64, Int8, Word16, Word32, Word64, Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build Bool
|
|
</span><span class="hs-identifier hs-var">CoreOps.equal</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156669"><span class="hs-identifier hs-var">y'</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156680"><span class="hs-identifier hs-var">x</span></a></span><span>
|
|
</span><span id="line-556"></span><span> </span><span id="local-6989586621679156675"><span class="annot"><span class="annottext">numSelected :: Tensor Build a
|
|
</span><a href="#local-6989586621679156675"><span class="hs-identifier hs-var hs-var">numSelected</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sum</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156677"><span class="hs-identifier hs-var">indicators</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156679"><span class="hs-identifier hs-var">indices</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156672"><span class="hs-identifier hs-var">outputShapeKeptDims</span></a></span><span>
|
|
</span><span id="line-557"></span><span>
|
|
</span><span id="line-558"></span><span class="hs-comment">-- Min and Max have identical gradient implementations.</span><span>
|
|
</span><span id="line-559"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Min"</span><span> </span><span id="local-6989586621679156666"><span class="annot"><span class="annottext">u :: NodeDef
|
|
</span><a href="#local-6989586621679156666"><span class="hs-identifier hs-var">u</span></a></span></span><span> </span><span id="local-6989586621679156665"><span class="annot"><span class="annottext">v :: [Output]
|
|
</span><a href="#local-6989586621679156665"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621679156664"><span class="annot"><span class="annottext">w :: [Tensor Value a]
|
|
</span><a href="#local-6989586621679156664"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Text -> GradientFunc a
|
|
forall a. GradientCompatible a => Text -> GradientFunc a
|
|
</span><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="annot"><span class="hs-string">"Max"</span></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156666"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156665"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">[Tensor Value a]
|
|
</span><a href="#local-6989586621679156664"><span class="hs-identifier hs-var">w</span></a></span><span>
|
|
</span><span id="line-560"></span><span>
|
|
</span><span id="line-561"></span><span class="hs-comment">-- Element wise maximum gradient</span><span>
|
|
</span><span id="line-562"></span><span class="hs-comment">-- See https://github.com/tensorflow/tensorflow/blob/e9de087fa7f59c39bbe12ac2c83c5547c83f746c/tensorflow/core/ops/math_grad.cc#L473</span><span>
|
|
</span><span id="line-563"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Maximum"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156663"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156663"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156662"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156662"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156661"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156661"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-564"></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a, Tensor Build a)
|
|
-> (Tensor Build a, Tensor Build a) -> [Maybe (Tensor Build a)]
|
|
forall t (v1 :: * -> *).
|
|
OneOf
|
|
'[Int32, Int64, Float, Double, Complex Float, Complex Double] t =>
|
|
(Tensor v1 t, Tensor v1 t)
|
|
-> (Tensor v1 t, Tensor v1 t) -> [Maybe (Tensor Build t)]
|
|
</span><a href="TensorFlow.Gradient.html#gradForBinaryCwise"><span class="hs-identifier hs-var">gradForBinaryCwise</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156663"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156660"><span class="hs-identifier hs-var">gx</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156662"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156659"><span class="hs-identifier hs-var">gy</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-565"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-566"></span><span> </span><span id="local-6989586621679156658"><span class="annot"><span class="annottext">xmask :: Tensor Build Bool
|
|
</span><a href="#local-6989586621679156658"><span class="hs-identifier hs-var hs-var">xmask</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build Bool
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Int16, Int32, Int64, Int8, Word16, Word32, Word64, Word8, Double,
|
|
Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build Bool
|
|
</span><span class="hs-identifier hs-var">CoreOps.greaterEqual</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156663"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156662"><span class="hs-identifier hs-var">y</span></a></span><span>
|
|
</span><span id="line-567"></span><span> </span><span id="local-6989586621679156660"><span class="annot"><span class="annottext">gx :: Tensor Build a
|
|
</span><a href="#local-6989586621679156660"><span class="hs-identifier hs-var hs-var">gx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Bool
|
|
-> Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 Bool -> Tensor v'2 t -> Tensor v'3 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.select</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Bool
|
|
</span><a href="#local-6989586621679156658"><span class="hs-identifier hs-var">xmask</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156661"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.zerosLike</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156661"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-568"></span><span> </span><span id="local-6989586621679156659"><span class="annot"><span class="annottext">gy :: Tensor Build a
|
|
</span><a href="#local-6989586621679156659"><span class="hs-identifier hs-var hs-var">gy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Bool
|
|
-> Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 Bool -> Tensor v'2 t -> Tensor v'3 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.select</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Bool -> Tensor Build Bool
|
|
forall (v'1 :: * -> *). Tensor v'1 Bool -> Tensor Build Bool
|
|
</span><span class="hs-identifier hs-var">CoreOps.logicalNot</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Bool
|
|
</span><a href="#local-6989586621679156658"><span class="hs-identifier hs-var">xmask</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156661"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.zerosLike</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156661"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-569"></span><span>
|
|
</span><span id="line-570"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Sum"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156654"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156654"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156653"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156653"><span class="hs-identifier hs-var">indices</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156652"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156652"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-571"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.tile</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156650"><span class="hs-identifier hs-var">grad</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156649"><span class="hs-identifier hs-var">tileScaling</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-572"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-573"></span><span> </span><span class="hs-comment">-- TODO(gnezdo): Implement the fast-path from math_grad._SumGrad.</span><span>
|
|
</span><span id="line-574"></span><span> </span><span id="local-6989586621679156648"><span class="annot"><span class="annottext">sx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156648"><span class="hs-identifier hs-var hs-var">sx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156654"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-575"></span><span> </span><span id="local-6989586621679156647"><span class="annot"><span class="annottext">outputShapeKeptDims :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156647"><span class="hs-identifier hs-var hs-var">outputShapeKeptDims</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall t1 t2 (v1 :: * -> *) (v2 :: * -> *).
|
|
(OneOf '[Int32, Int64] t1, OneOf '[Int32, Int64] t2) =>
|
|
Tensor v1 t1 -> Tensor v2 t2 -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#reducedShape"><span class="hs-identifier hs-var">reducedShape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156648"><span class="hs-identifier hs-var">sx</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156653"><span class="hs-identifier hs-var">indices</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-576"></span><span> </span><span id="local-6989586621679156649"><span class="annot"><span class="annottext">tileScaling :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156649"><span class="hs-identifier hs-var hs-var">tileScaling</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v1 :: * -> *) (v2 :: * -> *).
|
|
Tensor v1 Int32 -> Tensor v2 Int32 -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Gradient.html#safeShapeDiv"><span class="hs-identifier hs-var">safeShapeDiv</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156648"><span class="hs-identifier hs-var">sx</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156647"><span class="hs-identifier hs-var">outputShapeKeptDims</span></a></span><span>
|
|
</span><span id="line-577"></span><span> </span><span id="local-6989586621679156650"><span class="annot"><span class="annottext">grad :: Tensor Build a
|
|
</span><a href="#local-6989586621679156650"><span class="hs-identifier hs-var hs-var">grad</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156652"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156647"><span class="hs-identifier hs-var">outputShapeKeptDims</span></a></span><span>
|
|
</span><span id="line-578"></span><span>
|
|
</span><span id="line-579"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Mean"</span><span> </span><span id="local-6989586621679156645"><span class="annot"><span class="annottext">u :: NodeDef
|
|
</span><a href="#local-6989586621679156645"><span class="hs-identifier hs-var">u</span></a></span></span><span> </span><span id="local-6989586621679156644"><span class="annot"><span class="annottext">v :: [Output]
|
|
</span><a href="#local-6989586621679156644"><span class="hs-identifier hs-var">v</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156643"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156643"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">]</span><span> </span><span id="local-6989586621679156642"><span class="annot"><span class="annottext">w :: [Tensor Value a]
|
|
</span><a href="#local-6989586621679156642"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-580"></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156641"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.div`</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.stopGradient</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Tensor Build a)
|
|
-> Tensor Build a -> Tensor Build a
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) srcT dstT.
|
|
(TensorType srcT, TensorType dstT) =>
|
|
Tensor v'1 srcT -> Tensor Build dstT
|
|
</span><span class="hs-identifier hs-var">CoreOps.cast</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build Int32 -> Tensor Build a)
|
|
-> Tensor Build Int32 -> Tensor Build a
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156639"><span class="hs-identifier hs-var">factor</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-581"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-582"></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Just</span></span><span> </span><span id="local-6989586621679156641"><span class="annot"><span class="annottext">dz :: Tensor Build a
|
|
</span><a href="#local-6989586621679156641"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Nothing</span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Text -> GradientFunc a
|
|
forall a. GradientCompatible a => Text -> GradientFunc a
|
|
</span><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="annot"><span class="hs-string">"Sum"</span></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156645"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156644"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">[Tensor Value a]
|
|
</span><a href="#local-6989586621679156642"><span class="hs-identifier hs-var">w</span></a></span><span>
|
|
</span><span id="line-583"></span><span> </span><span id="local-6989586621679156638"><span class="annot"><span class="annottext">inputShape :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156638"><span class="hs-identifier hs-var hs-var">inputShape</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156643"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-584"></span><span> </span><span id="local-6989586621679156637"><span class="annot"><span class="annottext">outputShape :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156637"><span class="hs-identifier hs-var hs-var">outputShape</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156641"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-585"></span><span> </span><span class="hs-comment">-- TODO(fmayle): Add fast path when shape is known.</span><span>
|
|
</span><span id="line-586"></span><span> </span><span id="local-6989586621679156636"><span class="annot"><span class="annottext">inputSize :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156636"><span class="hs-identifier hs-var hs-var">inputSize</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.prod</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156638"><span class="hs-identifier hs-var">inputShape</span></a></span><span> </span><span class="annot"><span class="annottext">(Tensor Build Int32 -> Tensor Build Int32)
|
|
-> Tensor Build Int32 -> Tensor Build Int32
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Gradient.html#rangeOfRank"><span class="hs-identifier hs-var">rangeOfRank</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156638"><span class="hs-identifier hs-var">inputShape</span></a></span><span>
|
|
</span><span id="line-587"></span><span> </span><span id="local-6989586621679156633"><span class="annot"><span class="annottext">outputSize :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156633"><span class="hs-identifier hs-var hs-var">outputSize</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.prod</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156637"><span class="hs-identifier hs-var">outputShape</span></a></span><span> </span><span class="annot"><span class="annottext">(Tensor Build Int32 -> Tensor Build Int32)
|
|
-> Tensor Build Int32 -> Tensor Build Int32
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Gradient.html#rangeOfRank"><span class="hs-identifier hs-var">rangeOfRank</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156637"><span class="hs-identifier hs-var">outputShape</span></a></span><span>
|
|
</span><span id="line-588"></span><span> </span><span id="local-6989586621679156639"><span class="annot"><span class="annottext">factor :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156639"><span class="hs-identifier hs-var hs-var">factor</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v1 :: * -> *) (v2 :: * -> *).
|
|
Tensor v1 Int32 -> Tensor v2 Int32 -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Gradient.html#safeShapeDiv"><span class="hs-identifier hs-var">safeShapeDiv</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156636"><span class="hs-identifier hs-var">inputSize</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156633"><span class="hs-identifier hs-var">outputSize</span></a></span><span>
|
|
</span><span id="line-589"></span><span>
|
|
</span><span id="line-590"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Add"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156632"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156632"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156631"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156631"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156630"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156630"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-591"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sum</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156630"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156629"><span class="hs-identifier hs-var">rx</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156628"><span class="hs-identifier hs-var">sx</span></a></span><span>
|
|
</span><span id="line-592"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sum</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156630"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156627"><span class="hs-identifier hs-var">ry</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156626"><span class="hs-identifier hs-var">sy</span></a></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-593"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-594"></span><span> </span><span id="local-6989586621679156628"><span class="annot"><span class="annottext">sx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156628"><span class="hs-identifier hs-var hs-var">sx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156632"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-595"></span><span> </span><span id="local-6989586621679156626"><span class="annot"><span class="annottext">sy :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156626"><span class="hs-identifier hs-var hs-var">sy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156631"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-596"></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156629"><span class="annot"><span class="annottext">rx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156629"><span class="hs-identifier hs-var">rx</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156627"><span class="annot"><span class="annottext">ry :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156627"><span class="hs-identifier hs-var">ry</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
-> Tensor Build Int32 -> (Tensor Build Int32, Tensor Build Int32)
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Int32, Int64] t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> (Tensor Build t, Tensor Build t)
|
|
</span><span class="hs-identifier hs-var">broadcastGradientArgs</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156628"><span class="hs-identifier hs-var">sx</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156626"><span class="hs-identifier hs-var">sy</span></a></span><span>
|
|
</span><span id="line-597"></span><span>
|
|
</span><span id="line-598"></span><span class="hs-comment">-- Copies the gradients to all inputs</span><span>
|
|
</span><span id="line-599"></span><span class="hs-comment">-- Not broadcasting</span><span>
|
|
</span><span id="line-600"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"AddN"</span><span> </span><span class="hs-identifier">_</span><span> </span><span id="local-6989586621679156625"><span class="annot"><span class="annottext">inputs :: [Output]
|
|
</span><a href="#local-6989586621679156625"><span class="hs-identifier hs-var">inputs</span></a></span></span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156624"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156624"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-601"></span><span> </span><span class="annot"><span class="annottext">(Output -> Maybe (Tensor Build a))
|
|
-> [Output] -> [Maybe (Tensor Build a)]
|
|
forall a b. (a -> b) -> [a] -> [b]
|
|
</span><span class="hs-identifier hs-var">map</span></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe (Tensor Build a) -> Output -> Maybe (Tensor Build a)
|
|
forall a b. a -> b -> a
|
|
</span><span class="hs-identifier hs-var">const</span></span><span> </span><span class="annot"><span class="annottext">(Maybe (Tensor Build a) -> Output -> Maybe (Tensor Build a))
|
|
-> (Tensor Value a -> Maybe (Tensor Build a))
|
|
-> Tensor Value a
|
|
-> Output
|
|
-> Maybe (Tensor Build a)
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> (Tensor Value a -> Tensor Build a)
|
|
-> Tensor Value a
|
|
-> Maybe (Tensor Build a)
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a
|
|
forall (v :: * -> *) a.
|
|
TensorKind v =>
|
|
Tensor v a -> Tensor Build a
|
|
</span><span class="hs-identifier hs-var">expr</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156624"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156625"><span class="hs-identifier hs-var">inputs</span></a></span><span>
|
|
</span><span id="line-602"></span><span>
|
|
</span><span id="line-603"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Sub"</span><span> </span><span id="local-6989586621679156622"><span class="annot"><span class="annottext">u :: NodeDef
|
|
</span><a href="#local-6989586621679156622"><span class="hs-identifier hs-var">u</span></a></span></span><span> </span><span id="local-6989586621679156621"><span class="annot"><span class="annottext">v :: [Output]
|
|
</span><a href="#local-6989586621679156621"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span id="local-6989586621679156620"><span class="annot"><span class="annottext">w :: [Tensor Value a]
|
|
</span><a href="#local-6989586621679156620"><span class="hs-identifier hs-var">w</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-604"></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156619"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156618"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
|
|
</span><span id="line-605"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-606"></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Just</span></span><span> </span><span id="local-6989586621679156619"><span class="annot"><span class="annottext">x :: Tensor Build a
|
|
</span><a href="#local-6989586621679156619"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Just</span></span><span> </span><span id="local-6989586621679156618"><span class="annot"><span class="annottext">y :: Tensor Build a
|
|
</span><a href="#local-6989586621679156618"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Text -> GradientFunc a
|
|
forall a. GradientCompatible a => Text -> GradientFunc a
|
|
</span><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="annot"><span class="hs-string">"Add"</span></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156622"><span class="hs-identifier hs-var">u</span></a></span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156621"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="annot"><span class="annottext">[Tensor Value a]
|
|
</span><a href="#local-6989586621679156620"><span class="hs-identifier hs-var">w</span></a></span><span>
|
|
</span><span id="line-607"></span><span>
|
|
</span><span id="line-608"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"SoftmaxCrossEntropyWithLogits"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156617"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156617"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156616"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156616"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156615"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156615"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-609"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall t (v1 :: * -> *) (v2 :: * -> *).
|
|
TensorType t =>
|
|
Tensor v1 t -> Tensor v2 Int32 -> Tensor Build t
|
|
</span><a href="TensorFlow.Ops.html#expandDims"><span class="hs-identifier hs-var">expandDims</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156615"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">-</span><span class="annot"><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build a
|
|
forall a. Num a => a -> a -> a
|
|
</span><span class="hs-operator hs-var">*</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a, Tensor Build a) -> Tensor Build a
|
|
forall a b. (a, b) -> b
|
|
</span><span class="hs-identifier hs-var">snd</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
-> Tensor Build a -> (Tensor Build a, Tensor Build a)
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Word16, Double, Float] t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> (Tensor Build t, Tensor Build t)
|
|
</span><span class="hs-identifier hs-var">softmaxCrossEntropyWithLogits</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156617"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156616"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-610"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-611"></span><span>
|
|
</span><span id="line-612"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Mul"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156614"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156614"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156613"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156613"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156612"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156612"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-613"></span><span> </span><span class="hs-comment">-- TODO(fmayle): Handle complex numbers.</span><span>
|
|
</span><span id="line-614"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sum</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156612"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.mul`</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156613"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156611"><span class="hs-identifier hs-var">rx</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156610"><span class="hs-identifier hs-var">sx</span></a></span><span>
|
|
</span><span id="line-615"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sum</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156614"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.mul`</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156612"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156609"><span class="hs-identifier hs-var">ry</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156608"><span class="hs-identifier hs-var">sy</span></a></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-616"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-617"></span><span> </span><span id="local-6989586621679156610"><span class="annot"><span class="annottext">sx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156610"><span class="hs-identifier hs-var hs-var">sx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156614"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-618"></span><span> </span><span id="local-6989586621679156608"><span class="annot"><span class="annottext">sy :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156608"><span class="hs-identifier hs-var hs-var">sy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156613"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-619"></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156611"><span class="annot"><span class="annottext">rx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156611"><span class="hs-identifier hs-var">rx</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156609"><span class="annot"><span class="annottext">ry :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156609"><span class="hs-identifier hs-var">ry</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
-> Tensor Build Int32 -> (Tensor Build Int32, Tensor Build Int32)
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Int32, Int64] t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> (Tensor Build t, Tensor Build t)
|
|
</span><span class="hs-identifier hs-var">broadcastGradientArgs</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156610"><span class="hs-identifier hs-var">sx</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156608"><span class="hs-identifier hs-var">sy</span></a></span><span>
|
|
</span><span id="line-620"></span><span>
|
|
</span><span id="line-621"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Div"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156607"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156607"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156606"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156606"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156605"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156605"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-622"></span><span> </span><span class="hs-comment">-- TODO(fmayle): Handle complex numbers.</span><span>
|
|
</span><span id="line-623"></span><span> </span><span class="hs-comment">-- TODO(gnezdo): Provide Fractional instance and use '/' instead of div.</span><span>
|
|
</span><span id="line-624"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sum</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156605"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.div`</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156606"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156604"><span class="hs-identifier hs-var">rx</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156603"><span class="hs-identifier hs-var">sx</span></a></span><span>
|
|
</span><span id="line-625"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sum</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156605"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.mul`</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall a. Num a => a -> a
|
|
</span><span class="hs-identifier hs-var">negate</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156607"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.div`</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156606"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build a
|
|
forall a. Num a => a -> a -> a
|
|
</span><span class="hs-operator hs-var">*</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156606"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-626"></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156602"><span class="hs-identifier hs-var">ry</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-627"></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156601"><span class="hs-identifier hs-var">sy</span></a></span><span>
|
|
</span><span id="line-628"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-629"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-630"></span><span> </span><span id="local-6989586621679156603"><span class="annot"><span class="annottext">sx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156603"><span class="hs-identifier hs-var hs-var">sx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156607"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-631"></span><span> </span><span id="local-6989586621679156601"><span class="annot"><span class="annottext">sy :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156601"><span class="hs-identifier hs-var hs-var">sy</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156606"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-632"></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679156604"><span class="annot"><span class="annottext">rx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156604"><span class="hs-identifier hs-var">rx</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679156602"><span class="annot"><span class="annottext">ry :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156602"><span class="hs-identifier hs-var">ry</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
-> Tensor Build Int32 -> (Tensor Build Int32, Tensor Build Int32)
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Int32, Int64] t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> (Tensor Build t, Tensor Build t)
|
|
</span><span class="hs-identifier hs-var">broadcastGradientArgs</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156603"><span class="hs-identifier hs-var">sx</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156601"><span class="hs-identifier hs-var">sy</span></a></span><span>
|
|
</span><span id="line-633"></span><span>
|
|
</span><span id="line-634"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"MatMul"</span><span> </span><span id="local-6989586621679156600"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156600"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156599"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156599"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156598"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156598"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156597"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156597"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-635"></span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679156596"><span class="annot"><span class="annottext">transposeA :: Bool
|
|
</span><a href="#local-6989586621679156596"><span class="hs-identifier hs-var hs-var">transposeA</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> Bool
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156600"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"transpose_a"</span></span><span>
|
|
</span><span id="line-636"></span><span> </span><span id="local-6989586621679156594"><span class="annot"><span class="annottext">transposeB :: Bool
|
|
</span><a href="#local-6989586621679156594"><span class="hs-identifier hs-var hs-var">transposeB</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> Bool
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156600"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"transpose_b"</span></span><span>
|
|
</span><span id="line-637"></span><span> </span><span id="local-6989586621679156593"><span class="annot"><span class="annottext">transAttrs :: a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156593"><span class="hs-identifier hs-var hs-var">transAttrs</span></a></span></span><span> </span><span id="local-6989586621679156592"><span class="annot"><span class="annottext">a :: a
|
|
</span><a href="#local-6989586621679156592"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621679156591"><span class="annot"><span class="annottext">b :: a
|
|
</span><a href="#local-6989586621679156591"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-638"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef a
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"transpose_a"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef a)
|
|
-> a -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">a
|
|
</span><a href="#local-6989586621679156592"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef a
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"transpose_b"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef a)
|
|
-> a -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">a
|
|
</span><a href="#local-6989586621679156591"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-639"></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
|
|
</span><a href="#local-6989586621679156596"><span class="hs-identifier hs-var">transposeA</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><a href="#local-6989586621679156594"><span class="hs-identifier hs-var">transposeB</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
|
|
</span><span id="line-640"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">False</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">False</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-></span><span>
|
|
</span><span id="line-641"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">matMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156593"><span class="hs-identifier hs-var">transAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156597"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156598"><span class="hs-identifier hs-var">y</span></a></span><span>
|
|
</span><span id="line-642"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">matMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156593"><span class="hs-identifier hs-var">transAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156599"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156597"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-643"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">False</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">True</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-></span><span>
|
|
</span><span id="line-644"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">matMul</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156597"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156598"><span class="hs-identifier hs-var">y</span></a></span><span>
|
|
</span><span id="line-645"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">matMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156593"><span class="hs-identifier hs-var">transAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156597"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156599"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-646"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">True</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">False</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-></span><span>
|
|
</span><span id="line-647"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">matMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156593"><span class="hs-identifier hs-var">transAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156598"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156597"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-648"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">matMul</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156599"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156597"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-649"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">True</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">True</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-></span><span>
|
|
</span><span id="line-650"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">matMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156593"><span class="hs-identifier hs-var">transAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156598"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156597"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-651"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">matMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156593"><span class="hs-identifier hs-var">transAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156597"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156599"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-652"></span><span>
|
|
</span><span id="line-653"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"BatchMatMul"</span><span> </span><span id="local-6989586621679156590"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156590"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156589"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156589"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156588"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156588"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156587"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156587"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-654"></span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679156586"><span class="annot"><span class="annottext">adjX :: Bool
|
|
</span><a href="#local-6989586621679156586"><span class="hs-identifier hs-var hs-var">adjX</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> Bool
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156590"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"adj_x"</span></span><span>
|
|
</span><span id="line-655"></span><span> </span><span id="local-6989586621679156585"><span class="annot"><span class="annottext">adjY :: Bool
|
|
</span><a href="#local-6989586621679156585"><span class="hs-identifier hs-var hs-var">adjY</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> Bool
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156590"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"adj_y"</span></span><span>
|
|
</span><span id="line-656"></span><span> </span><span id="local-6989586621679156584"><span class="annot"><span class="annottext">adjAttrs :: a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156584"><span class="hs-identifier hs-var hs-var">adjAttrs</span></a></span></span><span> </span><span id="local-6989586621679156583"><span class="annot"><span class="annottext">a :: a
|
|
</span><a href="#local-6989586621679156583"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span id="local-6989586621679156582"><span class="annot"><span class="annottext">b :: a
|
|
</span><a href="#local-6989586621679156582"><span class="hs-identifier hs-var">b</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-657"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef a
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"adj_x"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef a)
|
|
-> a -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">a
|
|
</span><a href="#local-6989586621679156583"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef a
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"adj_y"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef a)
|
|
-> a -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">a
|
|
</span><a href="#local-6989586621679156582"><span class="hs-identifier hs-var">b</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-658"></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
|
|
</span><a href="#local-6989586621679156586"><span class="hs-identifier hs-var">adjX</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><a href="#local-6989586621679156585"><span class="hs-identifier hs-var">adjY</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
|
|
</span><span id="line-659"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">False</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">False</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-></span><span>
|
|
</span><span id="line-660"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.batchMatMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156584"><span class="hs-identifier hs-var">adjAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156587"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156588"><span class="hs-identifier hs-var">y</span></a></span><span>
|
|
</span><span id="line-661"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.batchMatMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156584"><span class="hs-identifier hs-var">adjAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156589"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156587"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-662"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">False</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">True</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-></span><span>
|
|
</span><span id="line-663"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.batchMatMul</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156587"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156588"><span class="hs-identifier hs-var">y</span></a></span><span>
|
|
</span><span id="line-664"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.batchMatMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156584"><span class="hs-identifier hs-var">adjAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156587"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156589"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-665"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">True</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">False</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-></span><span>
|
|
</span><span id="line-666"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.batchMatMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156584"><span class="hs-identifier hs-var">adjAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156588"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156587"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-667"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.batchMatMul</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156589"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156587"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-668"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-identifier hs-type">True</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-identifier hs-type">True</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-></span><span>
|
|
</span><span id="line-669"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.batchMatMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156584"><span class="hs-identifier hs-var">adjAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156588"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156587"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-670"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int32, Int64, Word16, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef) -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.batchMatMul'</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool -> Bool -> OpDef -> OpDef
|
|
forall a a. (Attribute a, Attribute a) => a -> a -> OpDef -> OpDef
|
|
</span><a href="#local-6989586621679156584"><span class="hs-identifier hs-var">adjAttrs</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156587"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156589"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-671"></span><span>
|
|
</span><span id="line-672"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Transpose"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">_</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156579"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156579"><span class="hs-identifier hs-var">p</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156578"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156578"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-673"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.transpose</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156578"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-674"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t.
|
|
OneOf '[Int32, Int64] t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.invertPermutation</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156579"><span class="hs-identifier hs-var">p</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-675"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-676"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-677"></span><span>
|
|
</span><span id="line-678"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Conv2D"</span><span> </span><span id="local-6989586621679156575"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156575"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156574"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156574"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156573"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156573"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156572"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156572"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-679"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor Build Int32
|
|
-> Tensor Build a
|
|
-> Tensor Value a
|
|
-> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t.
|
|
OneOf '[Int32, Word16, Double, Float] t =>
|
|
(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor v'1 Int32
|
|
-> Tensor v'2 t
|
|
-> Tensor v'3 t
|
|
-> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.conv2DBackpropInput'</span></span><span>
|
|
</span><span id="line-680"></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef [Int64]
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef [Int64])
|
|
-> [Int64] -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">[Int64]
|
|
</span><a href="#local-6989586621679156570"><span class="hs-identifier hs-var">strides</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-681"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef Bool
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"use_cudnn_on_gpu"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef Bool)
|
|
-> Bool -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><a href="#local-6989586621679156569"><span class="hs-identifier hs-var">useCudnnOnGpu</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-682"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef ByteString
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef ByteString)
|
|
-> ByteString -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156568"><span class="hs-identifier hs-var">dataFormat</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-683"></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156567"><span class="hs-identifier hs-var">padding</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156574"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156573"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156572"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-684"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor Build a
|
|
-> Tensor Build Int32
|
|
-> Tensor Value a
|
|
-> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t.
|
|
OneOf '[Word16, Double, Float] t =>
|
|
(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor v'1 t
|
|
-> Tensor v'2 Int32
|
|
-> Tensor v'3 t
|
|
-> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.conv2DBackpropFilter'</span></span><span>
|
|
</span><span id="line-685"></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef [Int64]
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef [Int64])
|
|
-> [Int64] -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">[Int64]
|
|
</span><a href="#local-6989586621679156570"><span class="hs-identifier hs-var">strides</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-686"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef Bool
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"use_cudnn_on_gpu"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef Bool)
|
|
-> Bool -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><a href="#local-6989586621679156569"><span class="hs-identifier hs-var">useCudnnOnGpu</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-687"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef ByteString
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef ByteString)
|
|
-> ByteString -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156568"><span class="hs-identifier hs-var">dataFormat</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-688"></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156567"><span class="hs-identifier hs-var">padding</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156574"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156573"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156572"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-689"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-690"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-691"></span><span> </span><span id="local-6989586621679156570"><span class="annot"><span class="annottext">strides :: [Int64]
|
|
</span><a href="#local-6989586621679156570"><span class="hs-identifier hs-var hs-var">strides</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> [Int64]
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156575"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Int64</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-692"></span><span> </span><span id="local-6989586621679156567"><span class="annot"><span class="annottext">padding :: ByteString
|
|
</span><a href="#local-6989586621679156567"><span class="hs-identifier hs-var hs-var">padding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156575"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"padding"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span>
|
|
</span><span id="line-693"></span><span> </span><span id="local-6989586621679156569"><span class="annot"><span class="annottext">useCudnnOnGpu :: Bool
|
|
</span><a href="#local-6989586621679156569"><span class="hs-identifier hs-var hs-var">useCudnnOnGpu</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> Bool
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156575"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"use_cudnn_on_gpu"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
|
|
</span><span id="line-694"></span><span> </span><span id="local-6989586621679156568"><span class="annot"><span class="annottext">dataFormat :: ByteString
|
|
</span><a href="#local-6989586621679156568"><span class="hs-identifier hs-var hs-var">dataFormat</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156575"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span>
|
|
</span><span id="line-695"></span><span>
|
|
</span><span id="line-696"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Conv2DBackpropInput"</span><span> </span><span id="local-6989586621679156565"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156565"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-identifier">_</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156564"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156564"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156563"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156563"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156562"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156562"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-697"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-698"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor Value a
|
|
-> Tensor Build Int32
|
|
-> Tensor Build a
|
|
-> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t.
|
|
OneOf '[Word16, Double, Float] t =>
|
|
(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor v'1 t
|
|
-> Tensor v'2 Int32
|
|
-> Tensor v'3 t
|
|
-> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.conv2DBackpropFilter'</span></span><span>
|
|
</span><span id="line-699"></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef [Int64]
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef [Int64])
|
|
-> [Int64] -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">[Int64]
|
|
</span><a href="#local-6989586621679156561"><span class="hs-identifier hs-var">strides</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-700"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef Bool
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"use_cudnn_on_gpu"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef Bool)
|
|
-> Bool -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><a href="#local-6989586621679156560"><span class="hs-identifier hs-var">useCudnnOnGpu</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-701"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef ByteString
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef ByteString)
|
|
-> ByteString -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156559"><span class="hs-identifier hs-var">dataFormat</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-702"></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156558"><span class="hs-identifier hs-var">padding</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156562"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156564"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156563"><span class="hs-identifier hs-var">y</span></a></span><span>
|
|
</span><span id="line-703"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> ByteString -> Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Int32, Word16, Double, Float] t =>
|
|
(OpDef -> OpDef)
|
|
-> ByteString -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.conv2D'</span></span><span>
|
|
</span><span id="line-704"></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef [Int64]
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef [Int64])
|
|
-> [Int64] -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">[Int64]
|
|
</span><a href="#local-6989586621679156561"><span class="hs-identifier hs-var">strides</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-705"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef Bool
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"use_cudnn_on_gpu"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef Bool)
|
|
-> Bool -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><a href="#local-6989586621679156560"><span class="hs-identifier hs-var">useCudnnOnGpu</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-706"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef ByteString
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef ByteString)
|
|
-> ByteString -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156559"><span class="hs-identifier hs-var">dataFormat</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-707"></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156558"><span class="hs-identifier hs-var">padding</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156562"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156564"><span class="hs-identifier hs-var">x</span></a></span><span>
|
|
</span><span id="line-708"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-709"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-710"></span><span> </span><span id="local-6989586621679156561"><span class="annot"><span class="annottext">strides :: [Int64]
|
|
</span><a href="#local-6989586621679156561"><span class="hs-identifier hs-var hs-var">strides</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> [Int64]
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156565"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Int64</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-711"></span><span> </span><span id="local-6989586621679156558"><span class="annot"><span class="annottext">padding :: ByteString
|
|
</span><a href="#local-6989586621679156558"><span class="hs-identifier hs-var hs-var">padding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156565"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"padding"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span>
|
|
</span><span id="line-712"></span><span> </span><span id="local-6989586621679156560"><span class="annot"><span class="annottext">useCudnnOnGpu :: Bool
|
|
</span><a href="#local-6989586621679156560"><span class="hs-identifier hs-var hs-var">useCudnnOnGpu</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> Bool
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156565"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"use_cudnn_on_gpu"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
|
|
</span><span id="line-713"></span><span> </span><span id="local-6989586621679156559"><span class="annot"><span class="annottext">dataFormat :: ByteString
|
|
</span><a href="#local-6989586621679156559"><span class="hs-identifier hs-var hs-var">dataFormat</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156565"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span>
|
|
</span><span id="line-714"></span><span>
|
|
</span><span id="line-715"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"DepthwiseConv2dNative"</span><span> </span><span id="local-6989586621679156556"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156556"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156555"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156555"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156554"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156554"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156553"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156553"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-716"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor Build Int32
|
|
-> Tensor Build a
|
|
-> Tensor Value a
|
|
-> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t.
|
|
OneOf '[Word16, Double, Float] t =>
|
|
(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor v'1 Int32
|
|
-> Tensor v'2 t
|
|
-> Tensor v'3 t
|
|
-> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.depthwiseConv2dNativeBackpropInput'</span></span><span>
|
|
</span><span id="line-717"></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef [Int64]
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef [Int64])
|
|
-> [Int64] -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">[Int64]
|
|
</span><a href="#local-6989586621679156551"><span class="hs-identifier hs-var">strides</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-718"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef ByteString
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef ByteString)
|
|
-> ByteString -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156550"><span class="hs-identifier hs-var">dataFormat</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-719"></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156549"><span class="hs-identifier hs-var">padding</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156555"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156554"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156553"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-720"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor Build a
|
|
-> Tensor Build Int32
|
|
-> Tensor Value a
|
|
-> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t.
|
|
OneOf '[Word16, Double, Float] t =>
|
|
(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor v'1 t
|
|
-> Tensor v'2 Int32
|
|
-> Tensor v'3 t
|
|
-> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.depthwiseConv2dNativeBackpropFilter'</span></span><span>
|
|
</span><span id="line-721"></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef [Int64]
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef [Int64])
|
|
-> [Int64] -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">[Int64]
|
|
</span><a href="#local-6989586621679156551"><span class="hs-identifier hs-var">strides</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-722"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef ByteString
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef ByteString)
|
|
-> ByteString -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156550"><span class="hs-identifier hs-var">dataFormat</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-723"></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156549"><span class="hs-identifier hs-var">padding</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156555"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156554"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156553"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-724"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-725"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-726"></span><span> </span><span id="local-6989586621679156551"><span class="annot"><span class="annottext">strides :: [Int64]
|
|
</span><a href="#local-6989586621679156551"><span class="hs-identifier hs-var hs-var">strides</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> [Int64]
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156556"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Int64</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-727"></span><span> </span><span id="local-6989586621679156549"><span class="annot"><span class="annottext">padding :: ByteString
|
|
</span><a href="#local-6989586621679156549"><span class="hs-identifier hs-var hs-var">padding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156556"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"padding"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span>
|
|
</span><span id="line-728"></span><span> </span><span id="local-6989586621679156550"><span class="annot"><span class="annottext">dataFormat :: ByteString
|
|
</span><a href="#local-6989586621679156550"><span class="hs-identifier hs-var hs-var">dataFormat</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156556"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span>
|
|
</span><span id="line-729"></span><span>
|
|
</span><span id="line-730"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"DepthwiseConv2dNativeBackpropInput"</span><span> </span><span id="local-6989586621679156547"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156547"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-identifier">_</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156546"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156546"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156545"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156545"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156544"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156544"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-731"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-732"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor Value a
|
|
-> Tensor Build Int32
|
|
-> Tensor Build a
|
|
-> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t.
|
|
OneOf '[Word16, Double, Float] t =>
|
|
(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor v'1 t
|
|
-> Tensor v'2 Int32
|
|
-> Tensor v'3 t
|
|
-> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.depthwiseConv2dNativeBackpropFilter'</span></span><span>
|
|
</span><span id="line-733"></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef [Int64]
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef [Int64])
|
|
-> [Int64] -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">[Int64]
|
|
</span><a href="#local-6989586621679156543"><span class="hs-identifier hs-var">strides</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-734"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef ByteString
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef ByteString)
|
|
-> ByteString -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156542"><span class="hs-identifier hs-var">dataFormat</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-735"></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156541"><span class="hs-identifier hs-var">padding</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156544"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156546"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156545"><span class="hs-identifier hs-var">y</span></a></span><span>
|
|
</span><span id="line-736"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> ByteString -> Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Word16, Double, Float] t =>
|
|
(OpDef -> OpDef)
|
|
-> ByteString -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.depthwiseConv2dNative'</span></span><span>
|
|
</span><span id="line-737"></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef [Int64]
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef [Int64])
|
|
-> [Int64] -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">[Int64]
|
|
</span><a href="#local-6989586621679156543"><span class="hs-identifier hs-var">strides</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-738"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef ByteString
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef ByteString)
|
|
-> ByteString -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156542"><span class="hs-identifier hs-var">dataFormat</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-739"></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156541"><span class="hs-identifier hs-var">padding</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156544"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156546"><span class="hs-identifier hs-var">x</span></a></span><span>
|
|
</span><span id="line-740"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-741"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-742"></span><span> </span><span id="local-6989586621679156543"><span class="annot"><span class="annottext">strides :: [Int64]
|
|
</span><a href="#local-6989586621679156543"><span class="hs-identifier hs-var hs-var">strides</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> [Int64]
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156547"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Int64</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-743"></span><span> </span><span id="local-6989586621679156541"><span class="annot"><span class="annottext">padding :: ByteString
|
|
</span><a href="#local-6989586621679156541"><span class="hs-identifier hs-var hs-var">padding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156547"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"padding"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span>
|
|
</span><span id="line-744"></span><span> </span><span id="local-6989586621679156542"><span class="annot"><span class="annottext">dataFormat :: ByteString
|
|
</span><a href="#local-6989586621679156542"><span class="hs-identifier hs-var hs-var">dataFormat</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156547"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span>
|
|
</span><span id="line-745"></span><span>
|
|
</span><span id="line-746"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"MaxPool"</span><span> </span><span id="local-6989586621679156539"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156539"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156538"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156538"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156537"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156537"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-747"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor Build a
|
|
-> Tensor Build a
|
|
-> Tensor Value a
|
|
-> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t.
|
|
OneOf
|
|
'[Int16, Int32, Int64, Int8, Word16, Word32, Word64, Word8, Double,
|
|
Float]
|
|
t =>
|
|
(OpDef -> OpDef)
|
|
-> ByteString
|
|
-> Tensor v'1 t
|
|
-> Tensor v'2 t
|
|
-> Tensor v'3 t
|
|
-> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.maxPoolGrad'</span></span><span>
|
|
</span><span id="line-748"></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef [Int64]
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"ksize"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef [Int64])
|
|
-> [Int64] -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">[Int64]
|
|
</span><a href="#local-6989586621679156535"><span class="hs-identifier hs-var">ksize</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-749"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef [Int64]
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef [Int64])
|
|
-> [Int64] -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">[Int64]
|
|
</span><a href="#local-6989586621679156534"><span class="hs-identifier hs-var">strides</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-750"></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef) -> (OpDef -> OpDef) -> OpDef -> OpDef
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef ByteString
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef ByteString)
|
|
-> ByteString -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156533"><span class="hs-identifier hs-var">dataFormat</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-751"></span><span> </span><span class="annot"><span class="annottext">ByteString
|
|
</span><a href="#local-6989586621679156532"><span class="hs-identifier hs-var">padding</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156538"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156531"><span class="hs-identifier hs-var">output</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156537"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-752"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-753"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-754"></span><span> </span><span class="annot"><a href="#local-6989586621679156531"><span class="hs-identifier hs-type">output</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span>
|
|
</span><span id="line-755"></span><span> </span><span id="local-6989586621679156531"><span class="annot"><span class="annottext">output :: Tensor Build a
|
|
</span><a href="#local-6989586621679156531"><span class="hs-identifier hs-var hs-var">output</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="annot"><span class="annottext">(Output -> Tensor Build a) -> Output -> Tensor Build a
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">OutputIx -> NodeName -> Output
|
|
</span><span class="hs-identifier hs-var">Output</span></span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeDef -> NodeName
|
|
</span><a href="TensorFlow.Gradient.html#nodeDefName"><span class="hs-identifier hs-var">nodeDefName</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156539"><span class="hs-identifier hs-var">nodeDef</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-756"></span><span> </span><span id="local-6989586621679156535"><span class="annot"><span class="annottext">ksize :: [Int64]
|
|
</span><a href="#local-6989586621679156535"><span class="hs-identifier hs-var hs-var">ksize</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> [Int64]
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156539"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"ksize"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Int64</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-757"></span><span> </span><span id="local-6989586621679156534"><span class="annot"><span class="annottext">strides :: [Int64]
|
|
</span><a href="#local-6989586621679156534"><span class="hs-identifier hs-var hs-var">strides</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> [Int64]
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156539"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"strides"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-identifier hs-type">Int64</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-758"></span><span> </span><span id="local-6989586621679156532"><span class="annot"><span class="annottext">padding :: ByteString
|
|
</span><a href="#local-6989586621679156532"><span class="hs-identifier hs-var hs-var">padding</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156539"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"padding"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span>
|
|
</span><span id="line-759"></span><span> </span><span id="local-6989586621679156533"><span class="annot"><span class="annottext">dataFormat :: ByteString
|
|
</span><a href="#local-6989586621679156533"><span class="hs-identifier hs-var hs-var">dataFormat</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156539"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"data_format"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span>
|
|
</span><span id="line-760"></span><span>
|
|
</span><span id="line-761"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Reshape"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156530"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156530"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156529"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156529"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156529"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">(Tensor Build Int32 -> Tensor Build a)
|
|
-> Tensor Build Int32 -> Tensor Build a
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156530"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-762"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"ExpandDims"</span><span> </span><span id="local-6989586621679156528"><span class="annot"><span class="annottext">n :: NodeDef
|
|
</span><a href="#local-6989586621679156528"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621679156527"><span class="annot"><span class="annottext">xs :: [Output]
|
|
</span><a href="#local-6989586621679156527"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build Any
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="annottext">Tensor Build Any
|
|
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">]</span><span> </span><span id="local-6989586621679156526"><span class="annot"><span class="annottext">dzs :: [Tensor Value a]
|
|
</span><a href="#local-6989586621679156526"><span class="hs-identifier hs-var">dzs</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">[</span><span class="hs-identifier">_</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Text -> GradientFunc a
|
|
forall a. GradientCompatible a => Text -> GradientFunc a
|
|
</span><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="annot"><span class="hs-string">"Reshape"</span></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156528"><span class="hs-identifier hs-var">n</span></a></span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156527"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">[Tensor Value a]
|
|
</span><a href="#local-6989586621679156526"><span class="hs-identifier hs-var">dzs</span></a></span><span>
|
|
</span><span id="line-763"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Squeeze"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156525"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156525"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156524"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156524"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156524"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">(Tensor Build Int32 -> Tensor Build a)
|
|
-> Tensor Build Int32 -> Tensor Build a
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156525"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span>
|
|
</span><span id="line-764"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Pad"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build Float
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156523"><span class="annot"><span class="annottext">Tensor Build Float
|
|
</span><a href="#local-6989586621679156523"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156522"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156522"><span class="hs-identifier hs-var">padPattern</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156521"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156521"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-765"></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t index.
|
|
(TensorType t, OneOf '[Int32, Int64] index) =>
|
|
Tensor v'1 t
|
|
-> Tensor v'2 index -> Tensor v'3 index -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.slice</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156521"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156520"><span class="hs-identifier hs-var">gradientSliceBegin</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156519"><span class="hs-identifier hs-var">gradientSliceSize</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-766"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-767"></span><span> </span><span id="local-6989586621679156518"><span class="annot"><span class="annottext">v1 :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156518"><span class="hs-identifier hs-var hs-var">v1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Int32] -> Tensor Build Int32
|
|
forall a. TensorType a => [a] -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#vector"><span class="hs-identifier hs-var">vector</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-number">1</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-768"></span><span> </span><span class="hs-comment">-- For some reason rankx' has an empty shape</span><span>
|
|
</span><span id="line-769"></span><span> </span><span id="local-6989586621679156517"><span class="annot"><span class="annottext">rankx' :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156517"><span class="hs-identifier hs-var hs-var">rankx'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Float -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build Int32
|
|
</span><span class="hs-identifier hs-var">CoreOps.rank</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Float
|
|
</span><a href="#local-6989586621679156523"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Float</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-770"></span><span> </span><span id="local-6989586621679156516"><span class="annot"><span class="annottext">rankx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156516"><span class="hs-identifier hs-var hs-var">rankx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156517"><span class="hs-identifier hs-var">rankx'</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156518"><span class="hs-identifier hs-var">v1</span></a></span><span>
|
|
</span><span id="line-771"></span><span> </span><span class="hs-comment">-- Size of column that is sliced from pad pattern</span><span>
|
|
</span><span id="line-772"></span><span> </span><span id="local-6989586621679156515"><span class="annot"><span class="annottext">padPatternSliceSize :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156515"><span class="hs-identifier hs-var hs-var">padPatternSliceSize</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> [Tensor Build Int32] -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 Int32 -> [Tensor v'2 t] -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.concat</span></span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156516"><span class="hs-identifier hs-var">rankx</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156518"><span class="hs-identifier hs-var">v1</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-773"></span><span> </span><span id="local-6989586621679156514"><span class="annot"><span class="annottext">padPatternSliceBegin :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156514"><span class="hs-identifier hs-var hs-var">padPatternSliceBegin</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Int32] -> Tensor Build Int32
|
|
forall a. TensorType a => [a] -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#vector"><span class="hs-identifier hs-var">vector</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-number">0</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-774"></span><span> </span><span id="local-6989586621679156513"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156513"><span class="hs-identifier hs-var">padPatternSliced</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t index.
|
|
(TensorType t, OneOf '[Int32, Int64] index) =>
|
|
Tensor v'1 t
|
|
-> Tensor v'2 index -> Tensor v'3 index -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.slice</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156522"><span class="hs-identifier hs-var">padPattern</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156514"><span class="hs-identifier hs-var">padPatternSliceBegin</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156515"><span class="hs-identifier hs-var">padPatternSliceSize</span></a></span><span>
|
|
</span><span id="line-775"></span><span> </span><span class="hs-comment">-- The slice of the pad pattern has the same rank as the pad pattern itself</span><span>
|
|
</span><span id="line-776"></span><span> </span><span id="local-6989586621679156520"><span class="annot"><span class="annottext">gradientSliceBegin :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156520"><span class="hs-identifier hs-var hs-var">gradientSliceBegin</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156513"><span class="hs-identifier hs-var">padPatternSliced</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156516"><span class="hs-identifier hs-var">rankx</span></a></span><span>
|
|
</span><span id="line-777"></span><span> </span><span id="local-6989586621679156519"><span class="annot"><span class="annottext">gradientSliceSize :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156519"><span class="hs-identifier hs-var hs-var">gradientSliceSize</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Float -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Float
|
|
</span><a href="#local-6989586621679156523"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Float</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-778"></span><span>
|
|
</span><span id="line-779"></span><span class="hs-comment">-- Gradient for Slice</span><span>
|
|
</span><span id="line-780"></span><span class="hs-comment">-- Create an Nx2 padding where N is the rank of (grad of) Slice and the first</span><span>
|
|
</span><span id="line-781"></span><span class="hs-comment">-- column represents how many zeros are to be prepended for each dimension, and the second</span><span>
|
|
</span><span id="line-782"></span><span class="hs-comment">-- column indicates how many zeros are appended.</span><span>
|
|
</span><span id="line-783"></span><span class="hs-comment">-- The number of zeros to prepend is the shape of the beginvec.</span><span>
|
|
</span><span id="line-784"></span><span class="hs-comment">-- The number of zeros to append is the shape of the inputvec</span><span>
|
|
</span><span id="line-785"></span><span class="hs-comment">-- elementwise-subtracted by both the beginvec and sizevec.</span><span>
|
|
</span><span id="line-786"></span><span class="hs-comment">-- Some more reshaping is needed to assemble this tensor with the</span><span>
|
|
</span><span id="line-787"></span><span class="hs-comment">-- right dimensions.</span><span>
|
|
</span><span id="line-788"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Slice"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build Float
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156512"><span class="annot"><span class="annottext">Tensor Build Float
|
|
</span><a href="#local-6989586621679156512"><span class="hs-identifier hs-var">inputvec</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156511"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156511"><span class="hs-identifier hs-var">beginvec</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156510"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156510"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-789"></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.pad</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156510"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156508"><span class="hs-identifier hs-var">paddings</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-790"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-791"></span><span> </span><span id="local-6989586621679156507"><span class="annot"><span class="annottext">v1 :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156507"><span class="hs-identifier hs-var hs-var">v1</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Int32] -> Tensor Build Int32
|
|
forall a. TensorType a => [a] -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#vector"><span class="hs-identifier hs-var">vector</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-number">1</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-792"></span><span> </span><span id="local-6989586621679156506"><span class="annot"><span class="annottext">inputRank' :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156506"><span class="hs-identifier hs-var hs-var">inputRank'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Float -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build Int32
|
|
</span><span class="hs-identifier hs-var">CoreOps.rank</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Float
|
|
</span><a href="#local-6989586621679156512"><span class="hs-identifier hs-var">inputvec</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Float</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-793"></span><span> </span><span class="hs-comment">-- For some reason inputRank' has an empty shape</span><span>
|
|
</span><span id="line-794"></span><span> </span><span id="local-6989586621679156505"><span class="annot"><span class="annottext">inputRank :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156505"><span class="hs-identifier hs-var hs-var">inputRank</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156506"><span class="hs-identifier hs-var">inputRank'</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156507"><span class="hs-identifier hs-var">v1</span></a></span><span>
|
|
</span><span id="line-795"></span><span> </span><span id="local-6989586621679156504"><span class="annot"><span class="annottext">padShape :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156504"><span class="hs-identifier hs-var hs-var">padShape</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> [Tensor Build Int32] -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 Int32 -> [Tensor v'2 t] -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.concat</span></span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156505"><span class="hs-identifier hs-var">inputRank</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156507"><span class="hs-identifier hs-var">v1</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-796"></span><span> </span><span id="local-6989586621679156503"><span class="annot"><span class="annottext">beforePad :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156503"><span class="hs-identifier hs-var hs-var">beforePad</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156511"><span class="hs-identifier hs-var">beginvec</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156504"><span class="hs-identifier hs-var">padShape</span></a></span><span>
|
|
</span><span id="line-797"></span><span> </span><span id="local-6989586621679156502"><span class="annot"><span class="annottext">afterPad :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156502"><span class="hs-identifier hs-var hs-var">afterPad</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Float -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Float
|
|
</span><a href="#local-6989586621679156512"><span class="hs-identifier hs-var">inputvec</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall a. Num a => a -> a -> a
|
|
</span><span class="hs-glyph hs-var">-</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156510"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall a. Num a => a -> a -> a
|
|
</span><span class="hs-glyph hs-var">-</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156511"><span class="hs-identifier hs-var">beginvec</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156504"><span class="hs-identifier hs-var">padShape</span></a></span><span>
|
|
</span><span id="line-798"></span><span> </span><span id="local-6989586621679156508"><span class="annot"><span class="annottext">paddings :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156508"><span class="hs-identifier hs-var hs-var">paddings</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> [Tensor Build Int32] -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 Int32 -> [Tensor v'2 t] -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.concat</span></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156503"><span class="hs-identifier hs-var">beforePad</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156502"><span class="hs-identifier hs-var">afterPad</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-799"></span><span>
|
|
</span><span id="line-800"></span><span class="hs-comment">-- TODO: This could be either Int32 or Int64.</span><span>
|
|
</span><span id="line-801"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"BatchToSpaceND"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">_</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156501"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156501"><span class="hs-identifier hs-var">blockShape</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156500"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156500"><span class="hs-identifier hs-var">crops</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156499"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156499"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-802"></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t
|
|
tblock_shape tpaddings.
|
|
(TensorType t, OneOf '[Int32, Int64] tblock_shape,
|
|
OneOf '[Int32, Int64] tpaddings) =>
|
|
Tensor v'1 t
|
|
-> Tensor v'2 tblock_shape
|
|
-> Tensor v'3 tpaddings
|
|
-> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.spaceToBatchND</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156499"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156501"><span class="hs-identifier hs-var">blockShape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156500"><span class="hs-identifier hs-var">crops</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-803"></span><span>
|
|
</span><span id="line-804"></span><span class="hs-comment">-- TODO: This could be either Int32 or Int64.</span><span>
|
|
</span><span id="line-805"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"SpaceToBatchND"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="hs-identifier">_</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156497"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156497"><span class="hs-identifier hs-var">blockShape</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">@</span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156496"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156496"><span class="hs-identifier hs-var">paddings</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156495"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156495"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-806"></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t
|
|
tblock_shape tpaddings.
|
|
(TensorType t, OneOf '[Int32, Int64] tblock_shape,
|
|
OneOf '[Int32, Int64] tpaddings) =>
|
|
Tensor v'1 t
|
|
-> Tensor v'2 tblock_shape
|
|
-> Tensor v'3 tpaddings
|
|
-> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.batchToSpaceND</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156495"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156497"><span class="hs-identifier hs-var">blockShape</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156496"><span class="hs-identifier hs-var">paddings</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-807"></span><span>
|
|
</span><span id="line-808"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"OneHot"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-809"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"TruncatedNormal"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-810"></span><span>
|
|
</span><span id="line-811"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"RefIdentity"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156493"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156493"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a
|
|
forall (v :: * -> *) a.
|
|
TensorKind v =>
|
|
Tensor v a -> Tensor Build a
|
|
</span><span class="hs-identifier hs-var">expr</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156493"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-812"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Cast"</span><span> </span><span id="local-6989586621679156492"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156492"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156491"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156491"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156490"><span class="hs-identifier hs-var">reverseCast</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-813"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-814"></span><span> </span><span class="hs-comment">-- TODO(gnezdo): too permissive, python only allows float types as src_type.</span><span>
|
|
</span><span id="line-815"></span><span> </span><span id="local-6989586621679156490"><span class="annot"><span class="annottext">reverseCast :: Tensor Build a
|
|
</span><a href="#local-6989586621679156490"><span class="hs-identifier hs-var hs-var">reverseCast</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-816"></span><span> </span><span class="annot"><span class="annottext">[Int64] -> Build OpDef -> Tensor Build a
|
|
forall a. PureResult a => [Int64] -> Build OpDef -> a
|
|
</span><span class="hs-identifier hs-var">pureOp</span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">(Build OpDef -> Tensor Build a) -> Build OpDef -> Tensor Build a
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">OpDef -> Build OpDef
|
|
forall (f :: * -> *) a. Applicative f => a -> f a
|
|
</span><span class="hs-identifier hs-var">pure</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">OpType -> OpDef
|
|
</span><span class="hs-identifier hs-var">opDef</span></span><span> </span><span class="annot"><span class="hs-string">"Cast"</span></span><span>
|
|
</span><span id="line-817"></span><span> </span><span class="annot"><span class="annottext">OpDef -> (OpDef -> OpDef) -> OpDef
|
|
forall s t. s -> (s -> t) -> t
|
|
</span><span class="hs-operator hs-var">&</span></span><span> </span><span class="annot"><span class="annottext">Text -> Lens' OpDef ByteString
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"DstT"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef ByteString)
|
|
-> ByteString -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156492"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"SrcT"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-818"></span><span> </span><span class="annot"><span class="annottext">OpDef -> (OpDef -> OpDef) -> OpDef
|
|
forall s t. s -> (s -> t) -> t
|
|
</span><span class="hs-operator hs-var">&</span></span><span> </span><span class="annot"><span class="annottext">Text -> Lens' OpDef ByteString
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"SrcT"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef ByteString)
|
|
-> ByteString -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeDef -> Text -> ByteString
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156492"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"DstT"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">ByteString</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-819"></span><span> </span><span class="annot"><span class="annottext">OpDef -> (OpDef -> OpDef) -> OpDef
|
|
forall s t. s -> (s -> t) -> t
|
|
</span><span class="hs-operator hs-var">&</span></span><span> </span><span class="annot"><span class="annottext">Lens' OpDef [Output]
|
|
forall (f :: * -> *). Identical f => LensLike' f OpDef [Output]
|
|
</span><span class="hs-identifier hs-var">opInputs</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef [Output])
|
|
-> [Output] -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Value a -> Output
|
|
forall (t :: * -> *) a. Rendered t => t a -> Output
|
|
</span><span class="hs-identifier hs-var">renderedOutput</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156491"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-820"></span><span>
|
|
</span><span id="line-821"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"DynamicStitch"</span><span> </span><span id="local-6989586621679156488"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156488"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span id="local-6989586621679156487"><span class="annot"><span class="annottext">inputs :: [Output]
|
|
</span><a href="#local-6989586621679156487"><span class="hs-identifier hs-var">inputs</span></a></span></span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156486"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156486"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-822"></span><span> </span><span class="annot"><span class="annottext">Node -> Maybe (Tensor Build a) -> [Maybe (Tensor Build a)]
|
|
forall a. Node -> a -> [a]
|
|
</span><span class="hs-identifier hs-var">replicate</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156484"><span class="hs-identifier hs-var">halfLen</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span> </span><span class="annot"><span class="annottext">[Maybe (Tensor Build a)]
|
|
-> [Maybe (Tensor Build a)] -> [Maybe (Tensor Build a)]
|
|
forall a. [a] -> [a] -> [a]
|
|
</span><span class="hs-operator hs-var">++</span></span><span> </span><span class="annot"><span class="annottext">[Maybe (Tensor Build a)]
|
|
</span><a href="#local-6989586621679156483"><span class="hs-identifier hs-var">valuesGrads</span></a></span><span>
|
|
</span><span id="line-823"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-824"></span><span> </span><span id="local-6989586621679156484"><span class="annot"><span class="annottext">halfLen :: Node
|
|
</span><a href="#local-6989586621679156484"><span class="hs-identifier hs-var hs-var">halfLen</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-825"></span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679156482"><span class="annot"><span class="annottext">len :: Node
|
|
</span><a href="#local-6989586621679156482"><span class="hs-identifier hs-var hs-var">len</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Output] -> Node
|
|
forall (t :: * -> *) a. Foldable t => t a -> Node
|
|
</span><span class="hs-identifier hs-var">length</span></span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156487"><span class="hs-identifier hs-var">inputs</span></a></span><span>
|
|
</span><span id="line-826"></span><span> </span><span id="local-6989586621679156481"><span class="annot"><span class="annottext">half :: Node
|
|
</span><a href="#local-6989586621679156481"><span class="hs-identifier hs-var hs-var">half</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156482"><span class="hs-identifier hs-var">len</span></a></span><span> </span><span class="annot"><span class="annottext">Node -> Node -> Node
|
|
forall a. Integral a => a -> a -> a
|
|
</span><span class="hs-operator hs-var">`div`</span></span><span> </span><span class="annot"><span class="hs-number">2</span></span><span>
|
|
</span><span id="line-827"></span><span> </span><span class="hs-keyword">in</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">Node -> Node -> Node
|
|
forall a. Num a => a -> a -> a
|
|
</span><span class="hs-operator hs-var">*</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156481"><span class="hs-identifier hs-var">half</span></a></span><span> </span><span class="annot"><span class="annottext">Node -> Node -> Bool
|
|
forall a. Eq a => a -> a -> Bool
|
|
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156482"><span class="hs-identifier hs-var">len</span></a></span><span>
|
|
</span><span id="line-828"></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156481"><span class="hs-identifier hs-var">half</span></a></span><span>
|
|
</span><span id="line-829"></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[Char] -> Node
|
|
forall a. HasCallStack => [Char] -> a
|
|
</span><span class="hs-identifier hs-var">error</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-string">"Uneven input size "</span></span><span> </span><span class="annot"><span class="annottext">[Char] -> [Char] -> [Char]
|
|
forall a. [a] -> [a] -> [a]
|
|
</span><span class="hs-operator hs-var">++</span></span><span> </span><span class="annot"><span class="annottext">(Node, [Char]) -> [Char]
|
|
forall a. Show a => a -> [Char]
|
|
</span><span class="hs-identifier hs-var">show</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156482"><span class="hs-identifier hs-var">len</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">NodeDef -> [Char]
|
|
forall msg. Message msg => msg -> [Char]
|
|
</span><span class="hs-identifier hs-var">showMessage</span></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156488"><span class="hs-identifier hs-var">nodeDef</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-830"></span><span> </span><span id="local-6989586621679156483"><span class="annot"><span class="annottext">valuesGrads :: [Maybe (Tensor Build a)]
|
|
</span><a href="#local-6989586621679156483"><span class="hs-identifier hs-var hs-var">valuesGrads</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.gather</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156486"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="annot"><span class="annottext">Output
|
|
</span><a href="#local-6989586621679156478"><span class="hs-identifier hs-var">idx</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-831"></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679156478"><span class="annot"><span class="annottext">Output
|
|
</span><a href="#local-6989586621679156478"><span class="hs-identifier hs-var">idx</span></a></span></span><span> </span><span class="hs-glyph"><-</span><span> </span><span class="annot"><span class="annottext">Node -> [Output] -> [Output]
|
|
forall a. Node -> [a] -> [a]
|
|
</span><span class="hs-identifier hs-var">take</span></span><span> </span><span class="annot"><span class="annottext">Node
|
|
</span><a href="#local-6989586621679156484"><span class="hs-identifier hs-var">halfLen</span></a></span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156487"><span class="hs-identifier hs-var">inputs</span></a></span><span>
|
|
</span><span id="line-832"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-833"></span><span>
|
|
</span><span id="line-834"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"DynamicPartition"</span><span> </span><span id="local-6989586621679156476"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156476"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156475"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156475"><span class="hs-identifier hs-var">xs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156474"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156474"><span class="hs-identifier hs-var">indices</span></a></span></span><span class="hs-special">]</span><span> </span><span id="local-6989586621679156473"><span class="annot"><span class="annottext">dz :: [Tensor Value a]
|
|
</span><a href="#local-6989586621679156473"><span class="hs-identifier hs-var">dz</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-835"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156472"><span class="hs-identifier hs-var">reconstructed</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-836"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-837"></span><span> </span><span id="local-6989586621679156472"><span class="annot"><span class="annottext">reconstructed :: Tensor Build a
|
|
</span><a href="#local-6989586621679156472"><span class="hs-identifier hs-var hs-var">reconstructed</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156471"><span class="hs-identifier hs-var">stitched</span></a></span><span>
|
|
</span><span id="line-838"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t out_type.
|
|
(TensorType t, OneOf '[Int32, Int64] out_type) =>
|
|
Tensor v'1 t -> Tensor Build out_type
|
|
</span><span class="hs-identifier hs-var">CoreOps.shape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156475"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-839"></span><span> </span><span id="local-6989586621679156471"><span class="annot"><span class="annottext">stitched :: Tensor Build a
|
|
</span><a href="#local-6989586621679156471"><span class="hs-identifier hs-var hs-var">stitched</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Tensor Build Int32] -> [Tensor Value a] -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
TensorType t =>
|
|
[Tensor v'1 Int32] -> [Tensor v'2 t] -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.dynamicStitch</span></span><span> </span><span class="annot"><span class="annottext">[Tensor Build Int32]
|
|
</span><a href="#local-6989586621679156468"><span class="hs-identifier hs-var">partitionedIndices</span></a></span><span> </span><span class="annot"><span class="annottext">[Tensor Value a]
|
|
</span><a href="#local-6989586621679156473"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-840"></span><span> </span><span id="local-6989586621679156468"><span class="annot"><span class="annottext">partitionedIndices :: [Tensor Build Int32]
|
|
</span><a href="#local-6989586621679156468"><span class="hs-identifier hs-var hs-var">partitionedIndices</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Int64
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> [Tensor Build Int32]
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
TensorType t =>
|
|
Int64 -> Tensor v'1 t -> Tensor v'2 Int32 -> [Tensor Build t]
|
|
</span><span class="hs-identifier hs-var">CoreOps.dynamicPartition</span></span><span> </span><span class="annot"><span class="annottext">Int64
|
|
</span><a href="#local-6989586621679156466"><span class="hs-identifier hs-var">np</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156465"><span class="hs-identifier hs-var">originalIndices</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156474"><span class="hs-identifier hs-var">indices</span></a></span><span>
|
|
</span><span id="line-841"></span><span> </span><span id="local-6989586621679156466"><span class="annot"><span class="annottext">np :: Int64
|
|
</span><a href="#local-6989586621679156466"><span class="hs-identifier hs-var hs-var">np</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> Int64
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156476"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"num_partitions"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int64</span></span><span>
|
|
</span><span id="line-842"></span><span> </span><span id="local-6989586621679156465"><span class="annot"><span class="annottext">originalIndices :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156465"><span class="hs-identifier hs-var hs-var">originalIndices</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-843"></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) tidx.
|
|
OneOf '[Int32, Int64, Word16, Double, Float] tidx =>
|
|
Tensor v'1 tidx
|
|
-> Tensor v'2 tidx -> Tensor v'3 tidx -> Tensor Build tidx
|
|
</span><span class="hs-identifier hs-var">CoreOps.range</span></span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t out_type.
|
|
(TensorType t, OneOf '[Int32, Int64] out_type) =>
|
|
Tensor v'1 t -> Tensor Build out_type
|
|
</span><span class="hs-identifier hs-var">CoreOps.size</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156474"><span class="hs-identifier hs-var">indices</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="hs-number">1</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156462"><span class="hs-identifier hs-var">prefixShape</span></a></span><span>
|
|
</span><span id="line-844"></span><span> </span><span id="local-6989586621679156462"><span class="annot"><span class="annottext">prefixShape :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156462"><span class="hs-identifier hs-var hs-var">prefixShape</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="#local-6989586621679156461"><span class="hs-identifier hs-var">shapeInt32</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156474"><span class="hs-identifier hs-var">indices</span></a></span><span>
|
|
</span><span id="line-845"></span><span> </span><span id="local-6989586621679156461"><span class="annot"><span class="annottext">shapeInt32 :: Tensor v'1 t -> Tensor Build Int32
|
|
</span><a href="#local-6989586621679156461"><span class="hs-identifier hs-var hs-var">shapeInt32</span></a></span></span><span> </span><span id="local-6989586621679156460"><span class="annot"><span class="annottext">t :: Tensor v'1 t
|
|
</span><a href="#local-6989586621679156460"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor v'1 t -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t out_type.
|
|
(TensorType t, OneOf '[Int32, Int64] out_type) =>
|
|
Tensor v'1 t -> Tensor Build out_type
|
|
</span><span class="hs-identifier hs-var">CoreOps.shape</span></span><span> </span><span class="annot"><span class="annottext">Tensor v'1 t
|
|
</span><a href="#local-6989586621679156460"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span>
|
|
</span><span id="line-846"></span><span>
|
|
</span><span id="line-847"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Select"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build Bool
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156459"><span class="annot"><span class="annottext">Tensor Build Bool
|
|
</span><a href="#local-6989586621679156459"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156458"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156458"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156457"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156457"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-848"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-849"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Bool
|
|
-> Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 Bool -> Tensor v'2 t -> Tensor v'3 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.select</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Bool
|
|
</span><a href="#local-6989586621679156459"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156457"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156456"><span class="hs-identifier hs-var">zeros</span></a></span><span>
|
|
</span><span id="line-850"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Bool
|
|
-> Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 Bool -> Tensor v'2 t -> Tensor v'3 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.select</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Bool
|
|
</span><a href="#local-6989586621679156459"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156456"><span class="hs-identifier hs-var">zeros</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156457"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-851"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-852"></span><span> </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679156456"><span class="annot"><span class="annottext">zeros :: Tensor Build a
|
|
</span><a href="#local-6989586621679156456"><span class="hs-identifier hs-var hs-var">zeros</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.zerosLike</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156458"><span class="hs-identifier hs-var">x</span></a></span><span>
|
|
</span><span id="line-853"></span><span>
|
|
</span><span id="line-854"></span><span class="hs-comment">-- TODO(gnezdo): Unlike Python, no control dependency on dz.</span><span>
|
|
</span><span id="line-855"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Log"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156455"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156455"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156454"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156454"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156454"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.mul`</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.inv</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156455"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-856"></span><span class="hs-comment">-- TODO(gnezdo): Reuse the output instead of doing another exp,</span><span>
|
|
</span><span id="line-857"></span><span class="hs-comment">-- though, it is probably CSE'd away anyway.</span><span>
|
|
</span><span id="line-858"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Exp"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156452"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156452"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156451"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156451"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156451"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.mul`</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
OneOf '[Complex Double, Complex Float, Word16, Double, Float] t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.exp</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156452"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-859"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"SparseSegmentSum"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156449"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156449"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156448"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156448"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156447"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156447"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156446"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156446"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-860"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) t tindices
|
|
tnumsegments.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tindices,
|
|
OneOf '[Int32, Int64] tnumsegments) =>
|
|
Tensor v'1 t
|
|
-> Tensor v'2 tindices -> Tensor v'3 tnumsegments -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.unsortedSegmentSum</span></span><span>
|
|
</span><span id="line-861"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.gather</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156446"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156447"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
|
|
</span><span id="line-862"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156448"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156445"><span class="hs-identifier hs-var">inputRows</span></a></span><span>
|
|
</span><span id="line-863"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-864"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-865"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-866"></span><span> </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679156445"><span class="annot"><span class="annottext">inputRows :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156445"><span class="hs-identifier hs-var hs-var">inputRows</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Int32 -> Int32 -> Tensor Build Int32
|
|
forall (v1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v1 t -> Int32 -> Int32 -> Tensor Build t
|
|
</span><a href="TensorFlow.Gradient.html#flatSlice"><span class="hs-identifier hs-var">flatSlice</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156449"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-867"></span><span>
|
|
</span><span id="line-868"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"LabelClasses"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-869"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"LabelWeights"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-870"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Size"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-871"></span><span>
|
|
</span><span id="line-872"></span><span class="hs-comment">-- TODO (jcberentsen): Python implementation uses set_shape for</span><span>
|
|
</span><span id="line-873"></span><span class="hs-comment">-- static shape inference, which is unsupported.</span><span>
|
|
</span><span id="line-874"></span><span class="hs-comment">-- TODO: implement support for static shape inference</span><span>
|
|
</span><span id="line-875"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Tile"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156444"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156444"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Output -> Tensor Build Int32
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156443"><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156443"><span class="hs-identifier hs-var">multiples</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156442"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156442"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-876"></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156441"><span class="hs-identifier hs-var">inputGrad</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-877"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-878"></span><span> </span><span id="local-6989586621679156441"><span class="annot"><span class="annottext">inputGrad :: Tensor Build a
|
|
</span><a href="#local-6989586621679156441"><span class="hs-identifier hs-var hs-var">inputGrad</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sum</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156440"><span class="hs-identifier hs-var">reshapedDz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156439"><span class="hs-identifier hs-var">axes</span></a></span><span>
|
|
</span><span id="line-879"></span><span> </span><span id="local-6989586621679156438"><span class="annot"><span class="annottext">inputShape :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156438"><span class="hs-identifier hs-var hs-var">inputShape</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build Int32
|
|
forall t (v :: * -> *).
|
|
TensorType t =>
|
|
Tensor v t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Ops.html#shape"><span class="hs-identifier hs-var">shape</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156444"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><a href="#local-6989586621679157265"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-880"></span><span> </span><span id="local-6989586621679156437"><span class="annot"><span class="annottext">packed :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156437"><span class="hs-identifier hs-var hs-var">packed</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Tensor Build Int32] -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
[Tensor v'1 t] -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.pack</span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156443"><span class="hs-identifier hs-var">multiples</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156438"><span class="hs-identifier hs-var">inputShape</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-881"></span><span> </span><span id="local-6989586621679156435"><span class="annot"><span class="annottext">perm :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156435"><span class="hs-identifier hs-var hs-var">perm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Int32] -> Tensor Build Int32
|
|
forall a. TensorType a => [a] -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#vector"><span class="hs-identifier hs-var">vector</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="hs-number">1</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-882"></span><span> </span><span id="local-6989586621679156434"><span class="annot"><span class="annottext">splitShape :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156434"><span class="hs-identifier hs-var hs-var">splitShape</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.reshape</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.transpose</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156437"><span class="hs-identifier hs-var">packed</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156435"><span class="hs-identifier hs-var">perm</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="TensorFlow.Gradient.html#allDimensions"><span class="hs-identifier hs-var">allDimensions</span></a></span><span>
|
|
</span><span id="line-883"></span><span> </span><span id="local-6989586621679156439"><span class="annot"><span class="annottext">axes :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156439"><span class="hs-identifier hs-var hs-var">axes</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) tidx.
|
|
OneOf '[Int32, Int64, Word16, Double, Float] tidx =>
|
|
Tensor v'1 tidx
|
|
-> Tensor v'2 tidx -> Tensor v'3 tidx -> Tensor Build tidx
|
|
</span><span class="hs-identifier hs-var">CoreOps.range</span></span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t out_type.
|
|
(TensorType t, OneOf '[Int32, Int64] out_type) =>
|
|
Tensor v'1 t -> Tensor Build out_type
|
|
</span><span class="hs-identifier hs-var">CoreOps.size</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156434"><span class="hs-identifier hs-var">splitShape</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="hs-number">2</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-884"></span><span> </span><span id="local-6989586621679156440"><span class="annot"><span class="annottext">reshapedDz :: Tensor Build a
|
|
</span><a href="#local-6989586621679156440"><span class="hs-identifier hs-var hs-var">reshapedDz</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tshape.
|
|
(TensorType t, OneOf '[Int32, Int64] tshape) =>
|
|
Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.reshape</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156442"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156434"><span class="hs-identifier hs-var">splitShape</span></a></span><span>
|
|
</span><span id="line-885"></span><span>
|
|
</span><span id="line-886"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"ResizeBilinear"</span><span> </span><span id="local-6989586621679156433"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156433"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156432"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156432"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-identifier">_</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156431"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156431"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-887"></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">(OpDef -> OpDef)
|
|
-> Tensor Build Float -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Word16, Double, Float] t =>
|
|
(OpDef -> OpDef)
|
|
-> Tensor v'1 Float -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.resizeBilinearGrad'</span></span><span>
|
|
</span><span id="line-888"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text -> Lens' OpDef Bool
|
|
forall a. Attribute a => Text -> Lens' OpDef a
|
|
</span><span class="hs-identifier hs-var">opAttr</span></span><span> </span><span class="annot"><span class="hs-string">"align_corners"</span></span><span> </span><span class="annot"><span class="annottext">(forall (f :: * -> *). Identical f => LensLike' f OpDef Bool)
|
|
-> Bool -> OpDef -> OpDef
|
|
forall s t a b. Setter s t a b -> b -> s -> t
|
|
</span><span class="hs-operator hs-var">.~</span></span><span> </span><span class="annot"><span class="annottext">Bool
|
|
</span><a href="#local-6989586621679156429"><span class="hs-identifier hs-var">align</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-889"></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Float
|
|
forall (v'1 :: * -> *) srcT dstT.
|
|
(TensorType srcT, TensorType dstT) =>
|
|
Tensor v'1 srcT -> Tensor Build dstT
|
|
</span><span class="hs-identifier hs-var">CoreOps.cast</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156431"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-890"></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156432"><span class="hs-identifier hs-var">x</span></a></span><span>
|
|
</span><span id="line-891"></span><span>
|
|
</span><span id="line-892"></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span>
|
|
</span><span id="line-893"></span><span> </span><span class="hs-special">]</span><span>
|
|
</span><span id="line-894"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-895"></span><span> </span><span id="local-6989586621679156429"><span class="annot"><span class="annottext">align :: Bool
|
|
</span><a href="#local-6989586621679156429"><span class="hs-identifier hs-var hs-var">align</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef -> Text -> Bool
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156433"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="hs-string">"align_corners"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
|
|
</span><span id="line-896"></span><span>
|
|
</span><span id="line-897"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"ZerosLike"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-898"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Fill"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156428"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156428"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32 -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t tidx.
|
|
(OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word32, Word64, Word8, Double, Float]
|
|
t,
|
|
OneOf '[Int32, Int64] tidx) =>
|
|
Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">sum</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156428"><span class="hs-identifier hs-var">dz</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
</span><a href="#local-6989586621679156427"><span class="hs-identifier hs-var">rx</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-899"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-900"></span><span> </span><span id="local-6989586621679156427"><span class="annot"><span class="annottext">rx :: Tensor Build Int32
|
|
</span><a href="#local-6989586621679156427"><span class="hs-identifier hs-var hs-var">rx</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Gradient.html#rangeOfRank"><span class="hs-identifier hs-var">rangeOfRank</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156428"><span class="hs-identifier hs-var">dz</span></a></span><span>
|
|
</span><span id="line-901"></span><span>
|
|
</span><span id="line-902"></span><span class="hs-comment">-- Treat read ops as an identity function on the variable. This allows us to</span><span>
|
|
</span><span id="line-903"></span><span class="hs-comment">-- take gradients w.r.t. to the variable handle instead of the result of a read</span><span>
|
|
</span><span id="line-904"></span><span class="hs-comment">-- op. If a variable is read multiple times, the gradients will propagate back</span><span>
|
|
</span><span id="line-905"></span><span class="hs-comment">-- through each read.</span><span>
|
|
</span><span id="line-906"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"ReadVariableOp"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156426"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156426"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a -> Tensor Build a
|
|
forall (v :: * -> *) a.
|
|
TensorKind v =>
|
|
Tensor v a -> Tensor Build a
|
|
</span><span class="hs-identifier hs-var">expr</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156426"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-907"></span><span>
|
|
</span><span id="line-908"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Const"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-909"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"StopGradient"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Maybe (Tensor Build a)
|
|
forall a. Maybe a
|
|
</span><span class="hs-identifier hs-var">Nothing</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-910"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"VarHandleOp"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
|
|
</span><span id="line-911"></span><span>
|
|
</span><span id="line-912"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span class="hs-string">"Sqrt"</span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Output -> Tensor Build a
|
|
forall a. Output -> Tensor Build a
|
|
</span><a href="TensorFlow.Gradient.html#toT"><span class="hs-identifier hs-var">toT</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span id="local-6989586621679156425"><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156425"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span id="local-6989586621679156424"><span class="annot"><span class="annottext">dz :: Tensor Value a
|
|
</span><a href="#local-6989586621679156424"><span class="hs-identifier hs-var">dz</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a. a -> Maybe a
|
|
</span><span class="hs-identifier hs-var">Just</span></span><span> </span><span class="annot"><span class="annottext">(Tensor Build a -> Maybe (Tensor Build a))
|
|
-> Tensor Build a -> Maybe (Tensor Build a)
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156423"><span class="hs-identifier hs-var">sq'</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Value a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.mul`</span></span><span> </span><span class="annot"><span class="annottext">Tensor Value a
|
|
</span><a href="#local-6989586621679156424"><span class="hs-identifier hs-var">dz</span></a></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-913"></span><span> </span><span class="hs-keyword">where</span><span>
|
|
</span><span id="line-914"></span><span> </span><span id="local-6989586621679156423"><span class="annot"><span class="annottext">sq' :: Tensor Build a
|
|
</span><a href="#local-6989586621679156423"><span class="hs-identifier hs-var hs-var">sq'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -> Tensor Build a
|
|
forall a. TensorType a => a -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#scalar"><span class="hs-identifier hs-var">scalar</span></a></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.div`</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -> Tensor Build a
|
|
forall a. TensorType a => a -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#scalar"><span class="hs-identifier hs-var">scalar</span></a></span><span> </span><span class="annot"><span class="hs-number">2</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.mul`</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a -> Tensor Build a
|
|
forall (v'1 :: * -> *) t.
|
|
OneOf '[Complex Double, Complex Float, Word16, Double, Float] t =>
|
|
Tensor v'1 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.sqrt</span></span><span> </span><span class="annot"><span class="annottext">Tensor Build a
|
|
</span><a href="#local-6989586621679156425"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-915"></span><span>
|
|
</span><span id="line-916"></span><span class="annot"><a href="TensorFlow.Gradient.html#opGrad"><span class="hs-identifier hs-var">opGrad</span></a></span><span> </span><span id="local-6989586621679156421"><span class="annot"><span class="annottext">n :: Text
|
|
</span><a href="#local-6989586621679156421"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span id="local-6989586621679156420"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156420"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span id="local-6989586621679156419"><span class="annot"><span class="annottext">ins :: [Output]
|
|
</span><a href="#local-6989586621679156419"><span class="hs-identifier hs-var">ins</span></a></span></span><span> </span><span id="local-6989586621679156418"><span class="annot"><span class="annottext">grads :: [Tensor Value a]
|
|
</span><a href="#local-6989586621679156418"><span class="hs-identifier hs-var">grads</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-917"></span><span> </span><span class="annot"><span class="annottext">[Char] -> [Maybe (Tensor Build a)]
|
|
forall a. HasCallStack => [Char] -> a
|
|
</span><span class="hs-identifier hs-var">error</span></span><span> </span><span class="annot"><span class="annottext">([Char] -> [Maybe (Tensor Build a)])
|
|
-> [Char] -> [Maybe (Tensor Build a)]
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="hs-string">"no gradient implemented for "</span></span><span> </span><span class="annot"><span class="annottext">[Char] -> [Char] -> [Char]
|
|
forall a. [a] -> [a] -> [a]
|
|
</span><span class="hs-operator hs-var">++</span></span><span>
|
|
</span><span id="line-918"></span><span> </span><span class="annot"><span class="annottext">(Text, Node, Node, [Char], [Output]) -> [Char]
|
|
forall a. Show a => a -> [Char]
|
|
</span><span class="hs-identifier hs-var">show</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Text
|
|
</span><a href="#local-6989586621679156421"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Output] -> Node
|
|
forall (t :: * -> *) a. Foldable t => t a -> Node
|
|
</span><span class="hs-identifier hs-var">length</span></span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156419"><span class="hs-identifier hs-var">ins</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Tensor Value a] -> Node
|
|
forall (t :: * -> *) a. Foldable t => t a -> Node
|
|
</span><span class="hs-identifier hs-var">length</span></span><span> </span><span class="annot"><span class="annottext">[Tensor Value a]
|
|
</span><a href="#local-6989586621679156418"><span class="hs-identifier hs-var">grads</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">NodeDef -> [Char]
|
|
forall msg. Message msg => msg -> [Char]
|
|
</span><span class="hs-identifier hs-var">showMessage</span></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156420"><span class="hs-identifier hs-var">nodeDef</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Output]
|
|
</span><a href="#local-6989586621679156419"><span class="hs-identifier hs-var">ins</span></a></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-919"></span><span>
|
|
</span><span id="line-920"></span><span class="hs-comment">-- | The number of outputs for an op type.</span><span>
|
|
</span><span id="line-921"></span><span class="annot"><a href="TensorFlow.Gradient.html#numOutputs"><span class="hs-identifier hs-type">numOutputs</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeDef</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">OutputIx</span></span><span>
|
|
</span><span id="line-922"></span><span id="numOutputs"><span class="annot"><span class="annottext">numOutputs :: NodeDef -> OutputIx
|
|
</span><a href="TensorFlow.Gradient.html#numOutputs"><span class="hs-identifier hs-var hs-var">numOutputs</span></a></span></span><span> </span><span id="local-6989586621679156417"><span class="annot"><span class="annottext">o :: NodeDef
|
|
</span><a href="#local-6989586621679156417"><span class="hs-identifier hs-var">o</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
|
|
</span><span id="line-923"></span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156417"><span class="hs-identifier hs-var">o</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef -> FoldLike Text NodeDef NodeDef Text Text -> Text
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">FoldLike Text NodeDef NodeDef Text Text
|
|
forall (f :: * -> *) s a.
|
|
(Functor f, HasField s "op" a) =>
|
|
LensLike' f s a
|
|
</span><span class="hs-identifier hs-var">op</span></span><span> </span><span class="hs-keyword">of</span><span>
|
|
</span><span id="line-924"></span><span> </span><span class="hs-string">"Abs"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-925"></span><span> </span><span class="hs-string">"Add"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-926"></span><span> </span><span class="hs-string">"AddN"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-927"></span><span> </span><span class="hs-string">"BatchToSpaceND"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-928"></span><span> </span><span class="hs-string">"BatchMatMul"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-929"></span><span> </span><span class="hs-string">"Cast"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-930"></span><span> </span><span class="hs-string">"Const"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-931"></span><span> </span><span class="hs-string">"Concat"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-932"></span><span> </span><span class="hs-string">"Conv2D"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-933"></span><span> </span><span class="hs-string">"Conv2DBackpropInput"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-934"></span><span> </span><span class="hs-string">"DepthwiseConv2dNative"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-935"></span><span> </span><span class="hs-string">"DepthwiseConv2dNativeBackpropInput"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-936"></span><span> </span><span class="hs-string">"Div"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-937"></span><span> </span><span class="hs-string">"DynamicStitch"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-938"></span><span> </span><span class="hs-string">"DynamicPartition"</span><span> </span><span class="hs-glyph">-></span><span>
|
|
</span><span id="line-939"></span><span> </span><span class="annot"><span class="annottext">Int64 -> OutputIx
|
|
forall a b. (Integral a, Num b) => a -> b
|
|
</span><span class="hs-identifier hs-var">fromIntegral</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeDef -> Text -> Int64
|
|
forall a1. Attribute a1 => NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var">lookupAttr</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156417"><span class="hs-identifier hs-var">o</span></a></span><span> </span><span class="annot"><span class="hs-string">"num_partitions"</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int64</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-940"></span><span> </span><span class="hs-string">"Exp"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-941"></span><span> </span><span class="hs-string">"ExpandDims"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-942"></span><span> </span><span class="hs-string">"Gather"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-943"></span><span> </span><span class="hs-string">"LabelClasses"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-944"></span><span> </span><span class="hs-string">"LabelWeights"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-945"></span><span> </span><span class="hs-string">"Log"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-946"></span><span> </span><span class="hs-string">"MatMul"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-947"></span><span> </span><span class="hs-string">"Max"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-948"></span><span> </span><span class="hs-string">"Maximum"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-949"></span><span> </span><span class="hs-string">"MaxPool"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-950"></span><span> </span><span class="hs-string">"Mean"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-951"></span><span> </span><span class="hs-string">"Min"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-952"></span><span> </span><span class="hs-string">"Mul"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-953"></span><span> </span><span class="hs-string">"Neg"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-954"></span><span> </span><span class="hs-string">"Pad"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-955"></span><span> </span><span class="hs-string">"Placeholder"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-956"></span><span> </span><span class="hs-string">"StopGradient"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-957"></span><span> </span><span class="hs-string">"OneHot"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-958"></span><span> </span><span class="hs-string">"ReadVariableOp"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-959"></span><span> </span><span class="hs-string">"RefIdentity"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-960"></span><span> </span><span class="hs-string">"Relu"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-961"></span><span> </span><span class="hs-string">"ReluGrad"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-962"></span><span> </span><span class="hs-string">"Reshape"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-963"></span><span> </span><span class="hs-string">"Select"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-964"></span><span> </span><span class="hs-string">"Sigmoid"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-965"></span><span> </span><span class="hs-string">"Size"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-966"></span><span> </span><span class="hs-string">"Slice"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-967"></span><span> </span><span class="hs-string">"SoftmaxCrossEntropyWithLogits"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">2</span></span><span>
|
|
</span><span id="line-968"></span><span> </span><span class="hs-string">"SpaceToBatchND"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-969"></span><span> </span><span class="hs-string">"SparseSegmentSum"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-970"></span><span> </span><span class="hs-string">"Square"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-971"></span><span> </span><span class="hs-string">"Squeeze"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-972"></span><span> </span><span class="hs-string">"Sqrt"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-973"></span><span> </span><span class="hs-string">"Sub"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-974"></span><span> </span><span class="hs-string">"Sum"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-975"></span><span> </span><span class="hs-string">"Tanh"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-976"></span><span> </span><span class="hs-string">"Tile"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-977"></span><span> </span><span class="hs-string">"ResizeBilinear"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-978"></span><span> </span><span class="hs-string">"Transpose"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-979"></span><span> </span><span class="hs-string">"TruncatedNormal"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-980"></span><span> </span><span class="hs-string">"VarHandleOp"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-981"></span><span> </span><span class="hs-string">"Variable"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-982"></span><span> </span><span class="hs-string">"ZerosLike"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-983"></span><span> </span><span class="hs-string">"Fill"</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-984"></span><span> </span><span class="hs-identifier">_</span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="annottext">[Char] -> OutputIx
|
|
forall a. HasCallStack => [Char] -> a
|
|
</span><span class="hs-identifier hs-var">error</span></span><span> </span><span class="annot"><span class="annottext">([Char] -> OutputIx) -> [Char] -> OutputIx
|
|
forall a b. (a -> b) -> a -> b
|
|
</span><span class="hs-operator hs-var">$</span></span><span> </span><span class="annot"><span class="hs-string">"numOutputs not implemented for "</span></span><span> </span><span class="annot"><span class="annottext">[Char] -> [Char] -> [Char]
|
|
forall a. [a] -> [a] -> [a]
|
|
</span><span class="hs-operator hs-var">++</span></span><span> </span><span class="annot"><span class="annottext">Text -> [Char]
|
|
forall a. Show a => a -> [Char]
|
|
</span><span class="hs-identifier hs-var">show</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156417"><span class="hs-identifier hs-var">o</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef -> FoldLike Text NodeDef NodeDef Text Text -> Text
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">FoldLike Text NodeDef NodeDef Text Text
|
|
forall (f :: * -> *) s a.
|
|
(Functor f, HasField s "op" a) =>
|
|
LensLike' f s a
|
|
</span><span class="hs-identifier hs-var">op</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-985"></span><span>
|
|
</span><span id="line-986"></span><span class="hs-comment">-- Divides `x / y` assuming `x, y >= 0`, treating `0 / 0 = 0`</span><span>
|
|
</span><span id="line-987"></span><span id="local-6989586621679157094"><span id="local-6989586621679157095"><span class="annot"><a href="TensorFlow.Gradient.html#safeShapeDiv"><span class="hs-identifier hs-type">safeShapeDiv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><a href="#local-6989586621679157095"><span class="hs-identifier hs-type">v1</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><a href="#local-6989586621679157094"><span class="hs-identifier hs-type">v2</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span></span></span><span>
|
|
</span><span id="line-988"></span><span id="safeShapeDiv"><span class="annot"><span class="annottext">safeShapeDiv :: Tensor v1 Int32 -> Tensor v2 Int32 -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Gradient.html#safeShapeDiv"><span class="hs-identifier hs-var hs-var">safeShapeDiv</span></a></span></span><span> </span><span id="local-6989586621679156416"><span class="annot"><span class="annottext">x :: Tensor v1 Int32
|
|
</span><a href="#local-6989586621679156416"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621679156415"><span class="annot"><span class="annottext">y :: Tensor v2 Int32
|
|
</span><a href="#local-6989586621679156415"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor v1 Int32
|
|
</span><a href="#local-6989586621679156416"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Tensor v1 Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf
|
|
'[Complex Double, Complex Float, Int16, Int32, Int64, Int8, Word16,
|
|
Word8, Double, Float]
|
|
t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-operator hs-var">`CoreOps.div`</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor v2 Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) t.
|
|
OneOf '[Int16, Int32, Int64, Word16, Word8, Double, Float] t =>
|
|
Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
|
|
</span><span class="hs-identifier hs-var">CoreOps.maximum</span></span><span> </span><span class="annot"><span class="annottext">Tensor v2 Int32
|
|
</span><a href="#local-6989586621679156415"><span class="hs-identifier hs-var">y</span></a></span><span> </span><span class="annot"><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
|
|
</span><span id="line-989"></span><span>
|
|
</span><span id="line-990"></span><span class="annot"><a href="TensorFlow.Gradient.html#allDimensions"><span class="hs-identifier hs-type">allDimensions</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span>
|
|
</span><span id="line-991"></span><span id="allDimensions"><span class="annot"><span class="annottext">allDimensions :: Tensor Build Int32
|
|
</span><a href="TensorFlow.Gradient.html#allDimensions"><span class="hs-identifier hs-var hs-var">allDimensions</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Int32] -> Tensor Build Int32
|
|
forall a. TensorType a => [a] -> Tensor Build a
|
|
</span><a href="TensorFlow.Ops.html#vector"><span class="hs-identifier hs-var">vector</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-glyph">-</span><span class="annot"><span class="hs-number">1</span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span class="hs-special">]</span><span>
|
|
</span><span id="line-992"></span><span>
|
|
</span><span id="line-993"></span><span class="annot"><a href="TensorFlow.Gradient.html#rangeOfRank"><span class="hs-identifier hs-type">rangeOfRank</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-keyword">forall</span><span> </span><span id="local-6989586621679156413"><span class="annot"><a href="#local-6989586621679156413"><span class="hs-identifier hs-type">v1</span></a></span></span><span> </span><span id="local-6989586621679156412"><span class="annot"><a href="#local-6989586621679156412"><span class="hs-identifier hs-type">t</span></a></span></span><span class="hs-operator">.</span><span> </span><span class="annot"><span class="hs-identifier hs-type">TensorType</span></span><span> </span><span class="annot"><a href="#local-6989586621679156412"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><a href="#local-6989586621679156413"><span class="hs-identifier hs-type">v1</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679156412"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Tensor</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Build</span></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Int32</span></span><span>
|
|
</span><span id="line-994"></span><span id="rangeOfRank"><span class="annot"><span class="annottext">rangeOfRank :: Tensor v1 t -> Tensor Build Int32
|
|
</span><a href="TensorFlow.Gradient.html#rangeOfRank"><span class="hs-identifier hs-var hs-var">rangeOfRank</span></a></span></span><span> </span><span id="local-6989586621679156411"><span class="annot"><span class="annottext">x :: Tensor v1 t
|
|
</span><a href="#local-6989586621679156411"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Tensor Build Int32
|
|
-> Tensor Build Int32 -> Tensor Build Int32 -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) (v'2 :: * -> *) (v'3 :: * -> *) tidx.
|
|
OneOf '[Int32, Int64, Word16, Double, Float] tidx =>
|
|
Tensor v'1 tidx
|
|
-> Tensor v'2 tidx -> Tensor v'3 tidx -> Tensor Build tidx
|
|
</span><span class="hs-identifier hs-var">CoreOps.range</span></span><span> </span><span class="annot"><span class="hs-number">0</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Tensor v1 t -> Tensor Build Int32
|
|
forall (v'1 :: * -> *) t.
|
|
TensorType t =>
|
|
Tensor v'1 t -> Tensor Build Int32
|
|
</span><span class="hs-identifier hs-var">CoreOps.rank</span></span><span> </span><span class="annot"><span class="annottext">Tensor v1 t
|
|
</span><a href="#local-6989586621679156411"><span class="hs-identifier hs-var">x</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="hs-number">1</span></span><span>
|
|
</span><span id="line-995"></span><span>
|
|
</span><span id="line-996"></span><span id="local-6989586621679157085"><span class="annot"><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-type">lookupAttr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Attribute</span></span><span> </span><span class="annot"><a href="#local-6989586621679157085"><span class="hs-identifier hs-type">a1</span></a></span><span> </span><span class="hs-glyph">=></span><span> </span><span class="annot"><span class="hs-identifier hs-type">NodeDef</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Text</span></span><span> </span><span class="hs-glyph">-></span><span> </span><span class="annot"><a href="#local-6989586621679157085"><span class="hs-identifier hs-type">a1</span></a></span></span><span>
|
|
</span><span id="line-997"></span><span id="lookupAttr"><span class="annot"><span class="annottext">lookupAttr :: NodeDef -> Text -> a1
|
|
</span><a href="TensorFlow.Gradient.html#lookupAttr"><span class="hs-identifier hs-var hs-var">lookupAttr</span></a></span></span><span> </span><span id="local-6989586621679156410"><span class="annot"><span class="annottext">nodeDef :: NodeDef
|
|
</span><a href="#local-6989586621679156410"><span class="hs-identifier hs-var">nodeDef</span></a></span></span><span> </span><span id="local-6989586621679156409"><span class="annot"><span class="annottext">attrName :: Text
|
|
</span><a href="#local-6989586621679156409"><span class="hs-identifier hs-var">attrName</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">NodeDef
|
|
</span><a href="#local-6989586621679156410"><span class="hs-identifier hs-var">nodeDef</span></a></span><span> </span><span class="annot"><span class="annottext">NodeDef -> FoldLike a1 NodeDef NodeDef a1 a1 -> a1
|
|
forall s a t b. s -> FoldLike a s t a b -> a
|
|
</span><span class="hs-operator hs-var">^.</span></span><span> </span><span class="annot"><span class="annottext">LensLike' (Constant a1) NodeDef (Map Text AttrValue)
|
|
forall (f :: * -> *) s a.
|
|
(Functor f, HasField s "attr" a) =>
|
|
LensLike' f s a
|
|
</span><span class="hs-identifier hs-var">attr</span></span><span> </span><span class="annot"><span class="annottext">LensLike' (Constant a1) NodeDef (Map Text AttrValue)
|
|
-> ((a1 -> Constant a1 a1)
|
|
-> Map Text AttrValue -> Constant a1 (Map Text AttrValue))
|
|
-> FoldLike a1 NodeDef NodeDef a1 a1
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">Text -> Lens' (Map Text AttrValue) (Maybe AttrValue)
|
|
forall k v. Ord k => k -> Lens' (Map k v) (Maybe v)
|
|
</span><span class="hs-identifier hs-var">at</span></span><span> </span><span class="annot"><span class="annottext">Text
|
|
</span><a href="#local-6989586621679156409"><span class="hs-identifier hs-var">attrName</span></a></span><span> </span><span class="annot"><span class="annottext">LensLike' (Constant a1) (Map Text AttrValue) (Maybe AttrValue)
|
|
-> ((a1 -> Constant a1 a1)
|
|
-> Maybe AttrValue -> Constant a1 (Maybe AttrValue))
|
|
-> (a1 -> Constant a1 a1)
|
|
-> Map Text AttrValue
|
|
-> Constant a1 (Map Text AttrValue)
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">AttrValue -> Lens' (Maybe AttrValue) AttrValue
|
|
forall a. Eq a => a -> Lens' (Maybe a) a
|
|
</span><a href="TensorFlow.Gradient.html#non"><span class="hs-identifier hs-var">non</span></a></span><span> </span><span class="annot"><span class="annottext">AttrValue
|
|
forall a. Message a => a
|
|
</span><span class="hs-identifier hs-var">def</span></span><span> </span><span class="annot"><span class="annottext">LensLike' (Constant a1) (Maybe AttrValue) AttrValue
|
|
-> ((a1 -> Constant a1 a1) -> AttrValue -> Constant a1 AttrValue)
|
|
-> (a1 -> Constant a1 a1)
|
|
-> Maybe AttrValue
|
|
-> Constant a1 (Maybe AttrValue)
|
|
forall b c a. (b -> c) -> (a -> b) -> a -> c
|
|
</span><span class="hs-operator hs-var">.</span></span><span> </span><span class="annot"><span class="annottext">(a1 -> Constant a1 a1) -> AttrValue -> Constant a1 AttrValue
|
|
forall a. Attribute a => Lens' AttrValue a
|
|
</span><span class="hs-identifier hs-var">attrLens</span></span><span>
|
|
</span><span id="line-998"></span></pre></body></html> |