tensorflow-0.1.0.0: TensorFlow bindings.

Safe HaskellNone
LanguageHaskell2010

TensorFlow.Types

Contents

Synopsis

Documentation

class TensorType a where Source

The class of scalar types supported by tensorflow.

Methods

tensorType :: a -> DataType Source

tensorRefType :: a -> DataType Source

tensorVal :: Lens' TensorProto [a] Source

decodeTensorData :: TensorData a -> Vector a Source

Decode the bytes of a TensorData into a Vector.

encodeTensorData :: Shape -> Vector a -> TensorData a Source

Encode a Vector into a TensorData.

The values should be in row major order, e.g.,

element 0: index (0, ..., 0) element 1: index (0, ..., 1) ...

newtype TensorData a Source

Data about a tensor that is encoded for the TensorFlow APIs.

Constructors

TensorData 

newtype Shape Source

Shape (dimensions) of a tensor.

Constructors

Shape [Int64] 

Type constraints

type OneOf ts a = (TensorType a, TensorTypes ts, NoneOf (AllTensorTypes \\ ts) a) Source

A Constraint specifying the possible choices of a TensorType.

We implement a Constraint like OneOf '[Double, Float] a by turning the natural representation as a conjunction, i.e.,

   a == Double || a == Float

into a disjunction like

    a /= Int32 && a /= Int64 && a /= ByteString && ...

using an enumeration of all the possible TensorTypes.

type family a /= b :: Constraint Source

A constraint checking that two types are different.

Equations

a /= a = TypeError a ~ ExcludedCase 
a /= b = () 

Implementation of constraints

data TypeError a Source

Helper types to produce a reasonable type error message when the Constraint "a /= a" fails. TODO(judahjacobson): Use ghc-8's CustomTypeErrors for this.

type family TensorTypes ts :: Constraint Source

A Constraint checking that the input is a list of TensorTypes. Helps improve error messages when using OneOf.

Equations

TensorTypes `[]` = () 
TensorTypes (t : ts) = (TensorType t, TensorTypes ts) 

type family NoneOf ts a :: Constraint Source

A constraint that the type a doesn't appear in the type list ts. Assumes that a and each of the elements of ts are TensorTypes.

Equations

NoneOf `[]` a = () 
NoneOf (t : ts) a = (a /= t, NoneOf ts a) 

type family as \\ bs Source

Takes the difference of two lists of types.

Equations

as \\ `[]` = as 
as \\ (b : bs) = Delete b as \\ bs 

type family Delete a as Source

Removes a type from the given list of types.

Equations

Delete a `[]` = `[]` 
Delete a (a : as) = Delete a as 
Delete a (b : as) = b : Delete a as 

type AllTensorTypes = `[Float, Double, Int8, Int16, Int32, Int64, Word8, Word16, ByteString, Bool]` Source

An enumeration of all valid TensorTypes.