Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data Tensor v a where
- Tensor :: TensorKind v => {
- tensorOutput :: v Output
- Tensor :: TensorKind v => {
- newtype Value a = Value {
- runValue :: a
- newtype Ref a = Ref {
- runRef :: a
- value :: Tensor Ref a -> Tensor Value a
- renderValue :: MonadBuild m => Tensor v a -> m (Tensor Value a)
- data Feed = Feed Output TensorData
- class TensorKind v => Rendered v where
- rendered :: v a -> a
- renderedOutput :: Rendered v => Tensor v a -> Output
- tensorNodeName :: Rendered v => Tensor v a -> NodeName
- feed :: Rendered v => Tensor v a -> TensorData a -> Feed
- tensorFromName :: TensorKind v => Text -> Tensor v a
- tensorValueFromName :: Text -> Tensor Value a
- tensorRefFromName :: Text -> Tensor Ref a
- type TensorList v = ListOf (Tensor v)
- tensorListOutputs :: Rendered v => TensorList v as -> [Output]
- colocateWith :: (MonadBuild m, Rendered v) => Tensor v b -> m a -> m a
- render :: MonadBuild m => Tensor Build a -> m (Tensor Value a)
- expr :: TensorKind v => Tensor v a -> Tensor Build a
- addSummary :: (MonadBuild m, TensorKind v) => Tensor v ByteString -> m ()
- collectAllSummaries :: MonadBuild m => m [SummaryTensor]
- type SummaryTensor = Tensor Value ByteString
- class Monad v => TensorKind v where
Documentation
data Tensor v a where
A named output of a TensorFlow operation.
The type parameter a
is the type of the elements in the Tensor
. The
parameter v
is either:
Build
: An unrendered, immutable value.Value
: A rendered, immutable value.Ref
: A rendered stateful handle (e.g., a variable).
Note that expr
, value
, render
and renderValue
can help convert between
the different types of Tensor
.
Tensor :: TensorKind v => v Output -> Tensor v a | |
|
BuildInputs (ListOf (Tensor v) as) | |
BuildInputs (Tensor v a) | |
TensorTypes as => PureResult (TensorList Build as) | |
PureResult (Tensor Build a) | |
(Rendered v, TensorTypes as) => BuildResult (TensorList v as) | |
Rendered v => BuildResult (Tensor v a) | |
Nodes (Tensor v a) | |
(TensorType a, TensorDataType s a, (~) * a a') => Fetchable (Tensor v a) (s a') | |
(TensorType a, (~) * a a') => Fetchable (Tensor v a) (TensorData a') |
newtype Value a
value :: Tensor Ref a -> Tensor Value a
Cast a 'Tensor Ref' into a 'Tensor Value'. This behaves like a no-op.
renderValue :: MonadBuild m => Tensor v a -> m (Tensor Value a)
data Feed
class TensorKind v => Rendered v where
A class ensuring that a given tensor is rendered, i.e., has a fixed name, device, etc.
rendered :: v a -> a
renderedOutput :: Rendered v => Tensor v a -> Output
tensorNodeName :: Rendered v => Tensor v a -> NodeName
feed :: Rendered v => Tensor v a -> TensorData a -> Feed
tensorFromName :: TensorKind v => Text -> Tensor v a
Create a Tensor
for a given name. This can be used to reference nodes
in a GraphDef
that was loaded via addGraphDef
.
TODO(judahjacobson): add more safety checks here.
tensorValueFromName :: Text -> Tensor Value a
Like tensorFromName
, but type-restricted to Value
.
tensorRefFromName :: Text -> Tensor Ref a
Like tensorFromName
, but type-restricted to Ref
.
type TensorList v = ListOf (Tensor v)
tensorListOutputs :: Rendered v => TensorList v as -> [Output]
colocateWith :: (MonadBuild m, Rendered v) => Tensor v b -> m a -> m a
Places all nodes rendered in the given Build
action on the same
device as the given Tensor (see also withDevice
). Make sure that
the action has side effects of rendering the desired tensors. A pure
return would not have the desired effect.
render :: MonadBuild m => Tensor Build a -> m (Tensor Value a)
Render a Tensor
, fixing its name, scope, device and control inputs from
the MonadBuild
context. Also renders any dependencies of the Tensor
that
weren't already rendered.
This operation is idempotent; calling render
on the same input in the same
context will produce the same result. However, rendering the same
Tensor Build
in two different contexts may result in two different
Tensor Value
s.
expr :: TensorKind v => Tensor v a -> Tensor Build a
:: (MonadBuild m, TensorKind v) | |
=> Tensor v ByteString | |
-> m () |
Records the given summary action in Build for retrieval with Summary protocol buffer in string form. For safety, use the pre-composed functions: Logging.scalarSummary and Logging.histogramSummary.
collectAllSummaries :: MonadBuild m => m [SummaryTensor]
Retrieves the summary ops collected thus far. Typically this only
happens once, but if buildWithSummary
is used
repeatedly, the values accumulate.
type SummaryTensor = Tensor Value ByteString
Synonym for the tensors that return serialized Summary proto.
class Monad v => TensorKind v where
An internal class for kinds of Tensors.