1
0
Fork 0
mirror of https://github.com/tensorflow/haskell.git synced 2024-12-26 11:39:46 +01:00
tensorflow-haskell/docs/haddock/tensorflow-ops-0.1.0.0/tensorflow-ops.txt

492 lines
26 KiB
Text
Raw Normal View History

-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/
-- | Friendly layer around TensorFlow bindings.
--
-- Please see README.md
@package tensorflow-ops
@version 0.1.0.0
-- | This module contains definitions for some built-in TensorFlow
-- operations.
--
2016-11-23 19:55:35 +01:00
-- Note that certain, "stateful" ops like <tt>variable</tt> and
-- <tt>assign</tt> return a <a>Build</a> action (e.g., <tt>Build (Tensor
-- Ref a)</tt> instead of a pure value; the returned <a>Tensor</a>s are
-- always rendered in the current <a>Build</a> context. This approach
-- helps us avoid problems with inlining or common subexpression
-- elimination, by writing
--
-- <pre>
-- do
-- v &lt;- variable []
-- w &lt;- assign v 3
-- render $ w * w
-- </pre>
--
-- instead of
--
-- <pre>
-- let
-- v = variable []
-- w = assign v 3
-- in w * w
-- </pre>
--
-- since the latter could be reasonably transformed by the compiler into
-- (or vice versa)
--
-- <pre>
-- let
-- v = variable []
-- w = assign v 3
-- w' = assign v 3
-- in w * w'
-- </pre>
--
-- Ops should return a <a>Build</a> action if their original
-- <tt>OpDef</tt> marks them as stateful, or if they take any Refs as
-- input. (This mirrors the rules that TensorFlow uses to avoid common
-- subexpression elimination.)
module TensorFlow.Ops
-- | Returns x + y element-wise.
--
-- <ul>
-- <li>NOTE*: <tt>Add</tt> supports broadcasting. <tt>AddN</tt> does not.
-- More about broadcasting <a>here</a></li>
-- </ul>
2017-04-08 16:14:47 +02:00
add :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * ByteString ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *)))))))))))) t => Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
add' :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * ByteString ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *)))))))))))) t => OpParams -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
-- | Computes the absolute value of a tensor.
--
-- Given a tensor <tt>x</tt>, this operation returns a tensor containing
-- the absolute value of each element in <tt>x</tt>. For example, if x is
-- an input element and y is an output element, this operation computes
-- \(y = |x|\).
2017-04-08 16:14:47 +02:00
abs :: OneOf ((:) * Int32 ((:) * Int64 ((:) * Word16 ((:) * Double ((:) * Float ([] *)))))) t => Tensor v'1 t -> Tensor Build t
abs' :: OneOf ((:) * Int32 ((:) * Int64 ((:) * Word16 ((:) * Double ((:) * Float ([] *)))))) t => OpParams -> Tensor v'1 t -> Tensor Build t
-- | Add all input tensors element wise.
2017-04-08 16:14:47 +02:00
addN :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))))) t => [Tensor v'1 t] -> Tensor Build t
addN' :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))))) t => OpParams -> [Tensor v'1 t] -> Tensor Build t
-- | Returns the index with the largest value across dimensions of a
-- tensor.
2017-04-08 16:14:47 +02:00
argMax :: (OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))))) t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tidx) => Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build Int64
argMax' :: (OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))))) t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tidx) => OpParams -> Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build Int64
2016-11-23 19:55:35 +01:00
-- | Update <tt>ref</tt> by assigning <a>value</a> to it.
--
-- This operation outputs "ref" after the assignment is done. This makes
-- it easier to chain operations that need to use the reset value.
2017-04-08 16:14:47 +02:00
assign :: (MonadBuild m', TensorType t) => Tensor Ref t -> Tensor v'2 t -> m' (Tensor Ref t)
assign' :: (MonadBuild m', TensorType t) => OpParams -> Tensor Ref t -> Tensor v'2 t -> m' (Tensor Ref t)
-- | Return the reduction indices for computing gradients of s0 op s1 with
-- broadcast.
--
-- This is typically used by gradient computations for a broadcasting
-- operation.
2017-04-08 16:14:47 +02:00
broadcastGradientArgs :: OneOf ((:) * Int32 ((:) * Int64 ([] *))) t => Tensor v'1 t -> Tensor v'2 t -> (Tensor Build t, Tensor Build t)
broadcastGradientArgs' :: OneOf ((:) * Int32 ((:) * Int64 ([] *))) t => OpParams -> Tensor v'1 t -> Tensor v'2 t -> (Tensor Build t, Tensor Build t)
-- | Cast x of type SrcT to y of DstT.
2017-04-08 16:14:47 +02:00
cast :: (TensorType srcT, TensorType dstT) => Tensor v'1 srcT -> Tensor Build dstT
cast' :: (TensorType srcT, TensorType dstT) => OpParams -> Tensor v'1 srcT -> Tensor Build dstT
-- | Concatenates tensors along one dimension.
2017-04-08 16:14:47 +02:00
concat :: TensorType t => Tensor v'1 Int32 -> [Tensor v'2 t] -> Tensor Build t
concat' :: TensorType t => OpParams -> Tensor v'1 Int32 -> [Tensor v'2 t] -> Tensor Build t
-- | Create a constant tensor.
--
-- The values should be in row major order, e.g.,
--
-- element 0: index (0, ..., 0) element 1: index (0, ..., 1) ...
2017-04-08 16:14:47 +02:00
constant :: TensorType a => Shape -> [a] -> Tensor Build a
constant' :: TensorType a => OpParams -> Shape -> [a] -> Tensor Build a
2016-10-31 22:22:48 +01:00
-- | Returns the truth value of (x == y) element-wise.
--
-- <ul>
-- <li>NOTE*: <tt>Equal</tt> supports broadcasting. More about
-- broadcasting <a>here</a></li>
-- </ul>
2017-04-08 16:14:47 +02:00
equal :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Bool ((:) * ByteString ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))))))) t => Tensor v'1 t -> Tensor v'2 t -> Tensor Build Bool
equal' :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Bool ((:) * ByteString ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))))))) t => OpParams -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build Bool
expandDims :: TensorType t => Tensor v1 t -> Tensor v2 Int32 -> Tensor Build t
expandDims' :: TensorType t => OpParams -> Tensor v1 t -> Tensor v2 Int32 -> Tensor Build t
-- | Creates a variable initialized to the given value. Initialization
-- happens next time session runs.
2017-04-08 16:14:47 +02:00
initializedVariable :: (MonadBuild m, TensorType a) => Tensor v a -> m (Tensor Ref a)
initializedVariable' :: (MonadBuild m, TensorType a) => OpParams -> Tensor v a -> m (Tensor Ref a)
-- | Creates a zero-initialized variable with the given shape.
2017-04-08 16:14:47 +02:00
zeroInitializedVariable :: (MonadBuild m, TensorType a, Num a) => Shape -> m (Tensor Ref a)
zeroInitializedVariable' :: (MonadBuild m, TensorType a, Num a) => OpParams -> Shape -> m (Tensor Ref a)
-- | Creates a tensor filled with a scalar value.
--
-- This operation creates a tensor of shape <tt>dims</tt> and fills it
-- with <a>value</a>.
--
-- For example:
--
-- ```prettyprint # Output tensor has shape [2, 3]. fill([2, 3], 9)
-- ==&gt; [[9, 9, 9] [9, 9, 9]] ```
2017-04-08 16:14:47 +02:00
fill :: TensorType t => Tensor v'1 Int32 -> Tensor v'2 t -> Tensor Build t
fill' :: TensorType t => OpParams -> Tensor v'1 Int32 -> Tensor v'2 t -> Tensor Build t
-- | Return a tensor with the same shape and contents as the input tensor
-- or value.
identity :: TensorType t => Tensor v'1 t -> Tensor Build t
identity' :: TensorType t => OpParams -> Tensor v'1 t -> Tensor Build t
-- | Multiply the matrix "a" by the matrix "b".
--
-- The inputs must be two-dimensional matrices and the inner dimension of
-- "a" (after being transposed if transpose_a is true) must match the
-- outer dimension of "b" (after being transposed if transposed_b is
-- true).
--
-- <ul>
-- <li>Note*: The default kernel implementation for MatMul on GPUs uses
-- cublas.</li>
-- </ul>
matMul :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int32 ((:) * Word16 ((:) * Double ((:) * Float ([] *))))))) t => Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
matMul' :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int32 ((:) * Word16 ((:) * Double ((:) * Float ([] *))))))) t => OpParams -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
matTranspose :: TensorType a => Tensor e a -> Tensor Build a
matTranspose' :: TensorType a => OpParams -> Tensor v a -> Tensor Build a
-- | Computes the mean of elements across dimensions of a tensor.
--
-- Reduces <tt>input</tt> along the dimensions given in
-- <tt>reduction_indices</tt>. Unless <tt>keep_dims</tt> is true, the
-- rank of the tensor is reduced by 1 for each entry in
-- <tt>reduction_indices</tt>. If <tt>keep_dims</tt> is true, the reduced
-- dimensions are retained with length 1.
mean :: (OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))))) t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tidx) => Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
mean' :: (OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))))) t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tidx) => OpParams -> Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
-- | Returns x * y element-wise.
--
-- <ul>
-- <li>NOTE*: <tt>Mul</tt> supports broadcasting. More about broadcasting
-- <a>here</a></li>
-- </ul>
mul :: 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
mul' :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))))) t => OpParams -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
-- | Computes numerical negative value element-wise.
--
-- I.e., \(y = -x\).
neg :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int32 ((:) * Int64 ((:) * Word16 ((:) * Double ((:) * Float ([] *)))))))) t => Tensor v'1 t -> Tensor Build t
neg' :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int32 ((:) * Int64 ((:) * Word16 ((:) * Double ((:) * Float ([] *)))))))) t => OpParams -> Tensor v'1 t -> Tensor Build t
2016-10-31 22:22:48 +01:00
-- | Returns a one-hot tensor.
--
-- The locations represented by indices in <tt>indices</tt> take value
-- <tt>on_value</tt>, while all other locations take value
-- <tt>off_value</tt>.
--
-- If the input <tt>indices</tt> is rank <tt>N</tt>, the output will have
-- rank `N+1`, The new axis is created at dimension <tt>axis</tt>
-- (default: the new axis is appended at the end).
--
-- If <tt>indices</tt> is a scalar the output shape will be a vector of
-- length <tt>depth</tt>.
--
-- If <tt>indices</tt> is a vector of length <tt>features</tt>, the
-- output shape will be: ``` features x depth if axis == -1 depth x
-- features if axis == 0 ```
--
-- If <tt>indices</tt> is a matrix (batch) with shape `[batch,
-- features]`, the output shape will be: ``` batch x features x depth if
-- axis == -1 batch x depth x features if axis == 1 depth x batch x
-- features if axis == 0 ```
--
-- Examples =========
--
-- Suppose that
--
-- ``` indices = [0, 2, -1, 1] depth = 3 on_value = 5.0 off_value = 0.0
-- axis = -1 ```
--
-- Then output is `[4 x 3]`:
--
-- ```output = [5.0 0.0 0.0] // one_hot(0) [0.0 0.0 5.0] // one_hot(2)
-- [0.0 0.0 0.0] // one_hot(-1) [0.0 5.0 0.0] // one_hot(1) ```
--
-- Suppose that
--
-- ``` indices = [0, 2, -1, 1] depth = 3 on_value = 0.0 off_value = 3.0
-- axis = 0 ```
--
-- Then output is `[3 x 4]`:
--
-- ```output = [0.0 3.0 3.0 3.0] [3.0 3.0 3.0 0.0] [3.0 3.0 3.0 3.0] [3.0
-- 0.0 3.0 3.0] // ^ one_hot(0) // ^ one_hot(2) // ^ one_hot(-1) // ^
-- one_hot(1) ``` Suppose that
--
-- ``` indices = [[0, 2], [1, -1]] depth = 3 on_value = 1.0 off_value =
-- 0.0 axis = -1 ```
--
-- Then output is `[2 x 2 x 3]`:
--
-- ```output = [ [1.0, 0.0, 0.0] // one_hot(0) [0.0, 0.0, 1.0] //
-- one_hot(2) ][ [0.0, 1.0, 0.0] // one_hot(1) [0.0, 0.0, 0.0] //
-- one_hot(-1) ]```
2017-04-08 16:14:47 +02:00
oneHot :: (TensorType t, OneOf ((:) * Int32 ((:) * Int64 ((:) * Word8 ([] *)))) tI) => Tensor v'1 tI -> Tensor v'2 Int32 -> Tensor v'3 t -> Tensor v'4 t -> Tensor Build t
oneHot' :: (TensorType t, OneOf ((:) * Int32 ((:) * Int64 ((:) * Word8 ([] *)))) tI) => OpParams -> Tensor v'1 tI -> Tensor v'2 Int32 -> Tensor v'3 t -> Tensor v'4 t -> Tensor Build t
-- | Packs a list of <tt>N</tt> rank-<tt>R</tt> tensors into one
-- rank-`(R+1)` tensor.
--
-- Packs the <tt>N</tt> tensors in <tt>values</tt> into a tensor with
-- rank one higher than each tensor in <tt>values</tt>, by packing them
-- along the <tt>axis</tt> dimension. Given a list of tensors of shape
-- `(A, B, C)`;
--
-- if `axis == 0` then the <tt>output</tt> tensor will have the shape
-- `(N, A, B, C)`. if `axis == 1` then the <tt>output</tt> tensor will
-- have the shape `(A, N, B, C)`. Etc.
--
-- For example:
--
-- ```prettyprint # <tt>x</tt> is [1, 4] # <tt>y</tt> is [2, 5] #
-- <tt>z</tt> is [3, 6] pack([x, y, z]) =&gt; [[1, 4], [2, 5], [3, 6]] #
-- Pack along first dim. pack([x, y, z], axis=1) =&gt; [[1, 2, 3], [4, 5,
-- 6]] ```
--
-- This is the opposite of <a>unpack</a>.
2017-04-08 16:14:47 +02:00
pack :: TensorType t => [Tensor v'1 t] -> Tensor Build t
pack' :: TensorType t => OpParams -> [Tensor v'1 t] -> Tensor Build t
placeholder :: (MonadBuild m, TensorType a) => Shape -> m (Tensor Value a)
placeholder' :: (MonadBuild m, TensorType a) => OpParams -> Shape -> m (Tensor Value a)
2016-11-23 19:55:35 +01:00
-- | Creates a sequence of numbers.
--
2016-11-23 19:55:35 +01:00
-- This operation creates a sequence of numbers that begins at
-- <tt>start</tt> and extends by increments of <tt>delta</tt> up to but
-- not including <tt>limit</tt>.
--
-- For example:
--
-- ``` # <tt>start</tt> is 3 # <tt>limit</tt> is 18 # <tt>delta</tt> is 3
-- tf.range(start, limit, delta) ==&gt; [3, 6, 9, 12, 15] ```
2017-04-08 16:14:47 +02:00
range :: OneOf ((:) * Int32 ((:) * Int64 ((:) * Double ((:) * Float ([] *))))) tidx => Tensor v'1 tidx -> Tensor v'2 tidx -> Tensor v'3 tidx -> Tensor Build tidx
range' :: OneOf ((:) * Int32 ((:) * Int64 ((:) * Double ((:) * Float ([] *))))) tidx => OpParams -> Tensor v'1 tidx -> Tensor v'2 tidx -> Tensor v'3 tidx -> Tensor Build tidx
-- | Helper function for reduction ops (translation of
-- math_ops.reduced_shape).
2017-04-08 16:14:47 +02:00
reducedShape :: (OneOf '[Int32, Int64] t1, OneOf '[Int32, Int64] t2) => Tensor v1 t1 -> Tensor v2 t2 -> Tensor Build Int32
-- | Computes rectified linear: `max(features, 0)`.
2017-04-08 16:14:47 +02:00
relu :: OneOf ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))) t => Tensor v'1 t -> Tensor Build t
relu' :: OneOf ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))) t => OpParams -> Tensor v'1 t -> Tensor Build t
-- | Computes rectified linear gradients for a Relu operation.
2017-04-08 16:14:47 +02:00
reluGrad :: OneOf ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))) t => Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
reluGrad' :: OneOf ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))) t => OpParams -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
-- | Reshapes a tensor.
--
-- Given <tt>tensor</tt>, this operation returns a tensor that has the
-- same values as <tt>tensor</tt> with shape <a>shape</a>.
--
-- If one component of <a>shape</a> is the special value -1, the size of
-- that dimension is computed so that the total size remains constant. In
-- particular, a <a>shape</a> of `[-1]` flattens into 1-D. At most one
-- component of <a>shape</a> can be -1.
--
-- If <a>shape</a> is 1-D or higher, then the operation returns a tensor
-- with shape <a>shape</a> filled with the values of <tt>tensor</tt>. In
-- this case, the number of elements implied by <a>shape</a> must be the
-- same as the number of elements in <tt>tensor</tt>.
--
-- For example:
--
-- ```prettyprint # tensor <tt>t</tt> is [1, 2, 3, 4, 5, 6, 7, 8, 9] #
-- tensor <tt>t</tt> has shape [9] reshape(t, [3, 3]) ==&gt; [[1, 2, 3],
-- [4, 5, 6], [7, 8, 9]]
--
-- # tensor <tt>t</tt> is [[[1, 1], [2, 2]], # [[3, 3], [4, 4]]] # tensor
-- <tt>t</tt> has shape [2, 2, 2] reshape(t, [2, 4]) ==&gt; [[1, 1, 2,
-- 2], [3, 3, 4, 4]]
--
-- # tensor <tt>t</tt> is [[[1, 1, 1], # [2, 2, 2]], # [[3, 3, 3], # [4,
-- 4, 4]], # [[5, 5, 5], # [6, 6, 6]]] # tensor <tt>t</tt> has shape [3,
-- 2, 3] # pass '[-1]' to flatten <tt>t</tt> reshape(t, [-1]) ==&gt; [1,
-- 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6]
--
-- # -1 can also be used to infer the shape
--
-- # -1 is inferred to be 9: reshape(t, [2, -1]) ==&gt; [[1, 1, 1, 2, 2,
-- 2, 3, 3, 3], [4, 4, 4, 5, 5, 5, 6, 6, 6]] # -1 is inferred to be 2:
-- reshape(t, [-1, 9]) ==&gt; [[1, 1, 1, 2, 2, 2, 3, 3, 3], [4, 4, 4, 5,
-- 5, 5, 6, 6, 6]] # -1 is inferred to be 3: reshape(t, [ 2, -1, 3])
-- ==&gt; [[[1, 1, 1], [2, 2, 2], [3, 3, 3]], [[4, 4, 4], [5, 5, 5], [6,
-- 6, 6]]]
--
-- # tensor <tt>t</tt> is [7] # shape `[]` reshapes to a scalar
-- reshape(t, []) ==&gt; 7 ```
2017-04-08 16:14:47 +02:00
reshape :: (TensorType t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tshape) => Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
reshape' :: (TensorType t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tshape) => OpParams -> Tensor v'1 t -> Tensor v'2 tshape -> Tensor Build t
-- | Restore a tensor's value from a checkpoint file.
2017-04-08 16:14:47 +02:00
restore :: (MonadBuild m, TensorType a) => ByteString -> Tensor Ref a -> m ControlNode
-- | Restore a tensor's value from a checkpoint file.
--
-- This version allows restoring from a checkpoint file that uses a
-- different tensor name than the variable.
2017-04-08 16:14:47 +02:00
restoreFromName :: (MonadBuild m, TensorType a) => ByteString -> ByteString -> Tensor Ref a -> m ControlNode
save :: (Rendered v, MonadBuild m, TensorType a) => ByteString -> [Tensor v a] -> m ControlNode
-- | Create a constant scalar.
2017-04-08 16:14:47 +02:00
scalar :: TensorType a => a -> Tensor Build a
scalar' :: TensorType a => OpParams -> a -> Tensor Build a
shape :: TensorType t => Tensor v t -> Tensor Build Int32
shape' :: TensorType t => OpParams -> Tensor v t -> Tensor Build Int32
-- | Returns an element-wise indication of the sign of a number.
--
-- `y = sign(x) = -1` if `x <a>0 if `x == 0`; 1 if `x</a> 0`.
--
-- For complex numbers, `y = sign(x) = x / |x|` if `x != 0`, otherwise `y
-- = 0`.
2017-04-08 16:14:47 +02:00
sign :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int32 ((:) * Int64 ((:) * Word16 ((:) * Double ((:) * Float ([] *)))))))) t => Tensor v'1 t -> Tensor Build t
sign' :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int32 ((:) * Int64 ((:) * Word16 ((:) * Double ((:) * Float ([] *)))))))) t => OpParams -> Tensor v'1 t -> Tensor Build t
-- | Returns the size of a tensor.
--
-- This operation returns an integer representing the number of elements
-- in <tt>input</tt>.
--
-- For example:
--
-- ```prettyprint # <tt>t</tt> is [[[1, 1,, 1], [2, 2, 2]], [[3, 3, 3],
-- [4, 4, 4]]]] size(t) ==&gt; 12 ```
2017-04-08 16:14:47 +02:00
size :: (TensorType t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) out_type) => Tensor v'1 t -> Tensor Build out_type
size' :: (TensorType t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) out_type) => OpParams -> Tensor v'1 t -> Tensor Build out_type
-- | Computes softmax activations.
--
-- For each batch <tt>i</tt> and class <tt>j</tt> we have
--
-- softmax[i, j] = exp(logits[i, j]) / sum_j(exp(logits[i, j]))
2017-04-08 16:14:47 +02:00
softmax :: OneOf ((:) * Word16 ((:) * Double ((:) * Float ([] *)))) t => Tensor v'1 t -> Tensor Build t
softmax' :: OneOf ((:) * Word16 ((:) * Double ((:) * Float ([] *)))) t => OpParams -> Tensor v'1 t -> Tensor Build t
-- | Computes softmax cross entropy cost and gradients to backpropagate.
--
-- Inputs are the logits, not probabilities.
2017-04-08 16:14:47 +02:00
softmaxCrossEntropyWithLogits :: OneOf ((:) * Word16 ((:) * Double ((:) * Float ([] *)))) t => Tensor v'1 t -> Tensor v'2 t -> (Tensor Build t, Tensor Build t)
softmaxCrossEntropyWithLogits' :: OneOf ((:) * Word16 ((:) * Double ((:) * Float ([] *)))) t => OpParams -> Tensor v'1 t -> Tensor v'2 t -> (Tensor Build t, Tensor Build t)
-- | Converts a sparse representation into a dense tensor.
--
-- Builds an array <tt>dense</tt> with shape <tt>output_shape</tt> such
-- that
--
-- ```prettyprint # If sparse_indices is scalar dense[i] = (i ==
-- sparse_indices ? sparse_values : default_value)
--
-- # If sparse_indices is a vector, then for each i
-- dense[sparse_indices[i]] = sparse_values[i]
--
-- # If sparse_indices is an n by d matrix, then for each i in [0, n)
-- dense[sparse_indices[i][0], ..., sparse_indices[i][d-1]] =
-- sparse_values[i] ```
--
-- All other values in <tt>dense</tt> are set to <tt>default_value</tt>.
-- If <tt>sparse_values</tt> is a scalar, all sparse indices are set to
-- this single value.
--
-- Indices should be sorted in lexicographic order, and indices must not
-- contain any repeats. If <tt>validate_indices</tt> is true, these
-- properties are checked during execution.
2017-04-08 16:14:47 +02:00
sparseToDense :: (TensorType t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tindices) => Tensor v'1 tindices -> Tensor v'2 tindices -> Tensor v'3 t -> Tensor v'4 t -> Tensor Build t
sparseToDense' :: (TensorType t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tindices) => OpParams -> Tensor v'1 tindices -> Tensor v'2 tindices -> Tensor v'3 t -> Tensor v'4 t -> Tensor Build t
-- | Returns x - y element-wise.
--
-- <ul>
-- <li>NOTE*: <tt>Sub</tt> supports broadcasting. More about broadcasting
-- <a>here</a></li>
-- </ul>
2017-04-08 16:14:47 +02:00
sub :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int32 ((:) * Int64 ((:) * Word16 ((:) * Double ((:) * Float ([] *)))))))) t => Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
sub' :: OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int32 ((:) * Int64 ((:) * Word16 ((:) * Double ((:) * Float ([] *)))))))) t => OpParams -> Tensor v'1 t -> Tensor v'2 t -> Tensor Build t
-- | Computes the sum of elements across dimensions of a tensor.
--
-- Reduces <tt>input</tt> along the dimensions given in
-- <tt>reduction_indices</tt>. Unless <tt>keep_dims</tt> is true, the
-- rank of the tensor is reduced by 1 for each entry in
-- <tt>reduction_indices</tt>. If <tt>keep_dims</tt> is true, the reduced
-- dimensions are retained with length 1.
2017-04-08 16:14:47 +02:00
sum :: (OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))))) t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tidx) => Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
sum' :: (OneOf ((:) * (Complex Double) ((:) * (Complex Float) ((:) * Int16 ((:) * Int32 ((:) * Int64 ((:) * Int8 ((:) * Word16 ((:) * Word8 ((:) * Double ((:) * Float ([] *))))))))))) t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tidx) => OpParams -> Tensor v'1 t -> Tensor v'2 tidx -> Tensor Build t
-- | Shuffle dimensions of x according to a permutation.
--
-- The output <tt>y</tt> has the same rank as <tt>x</tt>. The shapes of
-- <tt>x</tt> and <tt>y</tt> satisfy: `y.shape[i] == x.shape[perm[i]] for
-- i in [0, 1, ..., rank(x) - 1]`
2017-04-08 16:14:47 +02:00
transpose :: (TensorType t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tperm) => Tensor v'1 t -> Tensor v'2 tperm -> Tensor Build t
transpose' :: (TensorType t, OneOf ((:) * Int32 ((:) * Int64 ([] *))) tperm) => OpParams -> Tensor v'1 t -> Tensor v'2 tperm -> Tensor Build t
2017-04-08 16:14:47 +02:00
-- | Random tensor from the unit normal distribution with bounded values.
2016-11-23 19:55:35 +01:00
--
2017-04-08 16:14:47 +02:00
-- This is a type-restricted version of <a>truncatedNormal</a>.
truncatedNormal :: (MonadBuild m, OneOf '[Word16, Double, Float] a) => Tensor v Int64 -> m (Tensor Value a)
truncatedNormal' :: (MonadBuild m, OneOf '[Word16, Double, Float] a) => OpParams -> Tensor v Int64 -> m (Tensor Value a)
-- | Use VariableV2 instead.
variable :: (MonadBuild m', TensorType dtype) => Shape -> m' (Tensor Ref dtype)
variable' :: (MonadBuild m', TensorType dtype) => OpParams -> Shape -> m' (Tensor Ref dtype)
-- | Create a constant vector.
2017-04-08 16:14:47 +02:00
vector :: TensorType a => [a] -> Tensor Build a
vector' :: TensorType a => OpParams -> [a] -> Tensor Build a
zeros :: (Num a, TensorType a) => Shape -> Tensor Build a
-- | Returns a tensor of zeros with the same shape and type as x.
2017-04-08 16:14:47 +02:00
zerosLike :: TensorType t => Tensor v'1 t -> Tensor Build t
zerosLike' :: TensorType t => OpParams -> Tensor v'1 t -> Tensor Build t
2016-11-23 19:55:35 +01:00
-- | Reshape a N-D tensor down to a scalar.
--
-- See <a>reshape</a>.
2017-04-08 16:14:47 +02:00
scalarize :: TensorType a => Tensor v a -> Tensor Build a
instance (TensorFlow.Types.TensorType a, GHC.Num.Num a, v ~ TensorFlow.Build.Build, TensorFlow.Types.OneOf '[GHC.Types.Double, GHC.Types.Float, GHC.Int.Int32, GHC.Int.Int64, Data.Complex.Complex GHC.Types.Float, Data.Complex.Complex GHC.Types.Double] a) => GHC.Num.Num (TensorFlow.Tensor.Tensor v a)
-- | Parallel lookups on the list of tensors.
module TensorFlow.EmbeddingOps
-- | Looks up <tt>ids</tt> in a list of embedding tensors.
--
-- This function is used to perform parallel lookups on the list of
-- tensors in <tt>params</tt>. It is a generalization of <a>gather</a>,
-- where <tt>params</tt> is interpreted as a partition of a larger
-- embedding tensor.
--
-- The partition_strategy is "mod", we assign each id to partition `p =
-- id % len(params)`. For instance, 13 ids are split across 5 partitions
-- as: `[[0, 5, 10], [1, 6, 11], [2, 7, 12], [3, 8], [4, 9]]`
--
-- The results of the lookup are concatenated into a dense tensor. The
-- returned tensor has shape `shape(ids) + shape(params)[1:]`.
2017-04-08 16:14:47 +02:00
embeddingLookup :: (MonadBuild m, Rendered v1, TensorType a, OneOf '[Int64, Int32] b, Num b) => [Tensor v1 a] -> Tensor v2 b -> m (Tensor Value a)
module TensorFlow.Gradient
-- | Gradient of <tt>y</tt> w.r.t. each element of <tt>xs</tt>.
2017-04-08 16:14:47 +02:00
gradients :: (MonadBuild m, Rendered v2, GradientCompatible a) => Tensor v1 a -> [Tensor v2 a] -> m [Tensor Value a]