tensorflow-0.1.0.2: TensorFlow bindings.

Safe HaskellNone
LanguageHaskell2010

TensorFlow.Build

Contents

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 

Ops

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

The Build monad

data GraphState Source #

Instances

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

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

MonadTrans BuildT Source # 

Methods

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

TensorKind Build Source # 

Methods

toBuild :: Build a -> Build a Source #

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

Methods

get :: BuildT m GraphState

put :: GraphState -> BuildT m ()

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

Monad m => Monad (BuildT m) Source # 

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 #

fail :: String -> BuildT m a #

Functor m => Functor (BuildT m) Source # 

Methods

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

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

MonadFix m => MonadFix (BuildT m) Source # 

Methods

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

Monad m => Applicative (BuildT m) Source # 

Methods

pure :: a -> BuildT m a #

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

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

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

MonadIO m => MonadIO (BuildT m) Source # 

Methods

liftIO :: IO a -> BuildT m a #

MonadThrow m => MonadThrow (BuildT m) Source # 

Methods

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

MonadMask m => MonadMask (BuildT m) Source # 

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

MonadCatch m => MonadCatch (BuildT m) Source # 

Methods

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

Monad m => MonadBuild (BuildT m) Source # 

Methods

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

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

Methods

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

PureResult (Tensor Build a) Source # 

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.

Minimal complete definition

build

Methods

build :: Build a -> m a Source #

Instances

Monad m => MonadBuild (BuildT m) Source # 

Methods

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

Monad m => MonadBuild (SessionT m) Source # 

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.