tensorflow-0.3.0.0: TensorFlow bindings.
Safe HaskellNone
LanguageHaskell2010

TensorFlow.Build

Synopsis

Graph node types

newtype ControlNode Source #

A type of graph node which has no outputs. These nodes are valuable for causing side effects when they are run.

Constructors

ControlNode 

Instances

Instances details
Nodes ControlNode Source # 
Instance details

Defined in TensorFlow.Nodes

BuildResult ControlNode Source # 
Instance details

Defined in TensorFlow.BuildOp

Methods

buildResult :: Result ControlNode Source #

a ~ () => Fetchable ControlNode a Source # 
Instance details

Defined in TensorFlow.Nodes

data Unique Source #

Instances

Instances details
Enum Unique Source # 
Instance details

Defined in TensorFlow.Build

Eq Unique Source # 
Instance details

Defined in TensorFlow.Build

Methods

(==) :: Unique -> Unique -> Bool #

(/=) :: Unique -> Unique -> Bool #

Ord Unique Source # 
Instance details

Defined in TensorFlow.Build

Ops

opAttr :: Attribute a => Text -> Lens' OpDef a Source #

The Build monad

data GraphState Source #

Instances

Instances details
Monad m => MonadState GraphState (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

get :: BuildT m GraphState #

put :: GraphState -> BuildT m () #

state :: (GraphState -> (a, GraphState)) -> BuildT m a #

data BuildT m a Source #

An action for building nodes in a TensorFlow graph. Used to manage build state internally as part of the Session monad.

Instances

Instances details
MonadTrans BuildT Source # 
Instance details

Defined in TensorFlow.Build

Methods

lift :: Monad m => m a -> BuildT m a #

TensorKind Build Source # 
Instance details

Defined in TensorFlow.Tensor

Methods

toBuild :: Build a -> Build a Source #

Monad m => MonadState GraphState (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

get :: BuildT m GraphState #

put :: GraphState -> BuildT m () #

state :: (GraphState -> (a, GraphState)) -> BuildT m a #

Monad m => Monad (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

(>>=) :: BuildT m a -> (a -> BuildT m b) -> BuildT m b #

(>>) :: BuildT m a -> BuildT m b -> BuildT m b #

return :: a -> BuildT m a #

Functor m => Functor (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

fmap :: (a -> b) -> BuildT m a -> BuildT m b #

(<$) :: a -> BuildT m b -> BuildT m a #

MonadFix m => MonadFix (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

mfix :: (a -> BuildT m a) -> BuildT m a #

MonadFail m => MonadFail (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

fail :: String -> BuildT m a #

Monad m => Applicative (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

pure :: a -> BuildT m a #

(<*>) :: BuildT m (a -> b) -> BuildT m a -> BuildT m b #

liftA2 :: (a -> b -> c) -> BuildT m a -> BuildT m b -> BuildT m c #

(*>) :: BuildT m a -> BuildT m b -> BuildT m b #

(<*) :: BuildT m a -> BuildT m b -> BuildT m a #

MonadIO m => MonadIO (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

liftIO :: IO a -> BuildT m a #

MonadCatch m => MonadCatch (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

catch :: Exception e => BuildT m a -> (e -> BuildT m a) -> BuildT m a

MonadMask m => MonadMask (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

mask :: ((forall a. BuildT m a -> BuildT m a) -> BuildT m b) -> BuildT m b

uninterruptibleMask :: ((forall a. BuildT m a -> BuildT m a) -> BuildT m b) -> BuildT m b

generalBracket :: BuildT m a -> (a -> ExitCase b -> BuildT m c) -> (a -> BuildT m b) -> BuildT m (b, c)

MonadThrow m => MonadThrow (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

throwM :: Exception e => e -> BuildT m a

Monad m => MonadBuild (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

build :: Build a -> BuildT m a Source #

TensorTypes as => PureResult (TensorList Build as) Source # 
Instance details

Defined in TensorFlow.BuildOp

Methods

pureResult :: ReaderT (Build OpDef) (State ResultState) (TensorList Build as) Source #

PureResult (Tensor Build a) Source # 
Instance details

Defined in TensorFlow.BuildOp

Methods

pureResult :: ReaderT (Build OpDef) (State ResultState) (Tensor Build a) Source #

type Build = BuildT Identity Source #

An action for building nodes in a TensorFlow graph.

class Monad m => MonadBuild m where Source #

Lift a Build action into a monad, including any explicit op renderings.

Methods

build :: Build a -> m a Source #

Instances

Instances details
Monad m => MonadBuild (BuildT m) Source # 
Instance details

Defined in TensorFlow.Build

Methods

build :: Build a -> BuildT m a Source #

Monad m => MonadBuild (SessionT m) Source # 
Instance details

Defined in TensorFlow.Session

Methods

build :: Build a -> SessionT m a Source #

addInitializer :: MonadBuild m => ControlNode -> m () Source #

Registers the given node to be executed before the next run.

hoistBuildT :: (forall a. m a -> n a) -> BuildT m b -> BuildT n b Source #

This is Control.Monad.Morph.hoist sans the dependency.

evalBuildT :: Monad m => BuildT m a -> m a Source #

asGraphDef :: Build a -> GraphDef Source #

Produce a GraphDef proto representation of the nodes that are rendered in the given Build action.

flushInitializers :: Monad m => BuildT m [NodeName] Source #

Get all the initializers that have accumulated so far, and clear that buffer.

flushNodeBuffer :: MonadBuild m => m [NodeDef] Source #

Get all the NodeDefs that have accumulated so far, and clear that buffer.

Creating and looking up Ops

getOrAddOp :: OpDef -> Build NodeName Source #

Render the given op if it hasn't been rendered already, and return its name.

addNewOp :: OpDef -> Build NodeName Source #

Add a new node for a given OpDef. This is used for making "stateful" ops which are not safe to dedup (e.g, "variable" and "assign").

encodeOutput :: Output -> Text Source #

Turn an Output into a string representation for the TensorFlow foreign APIs.

Modifying all nodes in a Build action

withStateLens :: MonadBuild m => Lens' GraphState a -> (a -> a) -> m b -> m b Source #

Modify some part of the state, run an action, and restore the state after that action is done.

withDevice :: MonadBuild m => Maybe Device -> m a -> m a Source #

Set a device for all nodes rendered in the given Build action (unless further overridden by another use of withDevice).

withNameScope :: MonadBuild m => Text -> m a -> m a Source #

Prepend a scope to all nodes rendered in the given Build action.

withNodeDependencies :: MonadBuild m => Set NodeName -> m a -> m a Source #

Add control inputs to all nodes rendered in the given Build action.