tensorflow-0.1.0.0: TensorFlow bindings.

Safe HaskellNone
LanguageHaskell2010

TensorFlow.Types

Contents

Synopsis

Documentation

newtype TensorData a

Tensor data with the correct memory layout for tensorflow.

Constructors

TensorData 

Instances

(TensorType a, (~) * a a') => Fetchable (Tensor v a) (TensorData a') 

class TensorType a => TensorDataType s a where

Types that can be converted to and from TensorData.

Vector is the most efficient to encode/decode for most element types.

Methods

decodeTensorData :: TensorData a -> s a

Decode the bytes of a TensorData into an s.

encodeTensorData :: Shape -> s a -> TensorData a

Encode an s into a TensorData.

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

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

newtype Scalar a

Constructors

Scalar 

Fields

unScalar :: a
 

Instances

TensorDataType Vector a => TensorDataType Scalar a 
Eq a => Eq (Scalar a) 
Floating a => Floating (Scalar a) 
Fractional a => Fractional (Scalar a) 
Num a => Num (Scalar a) 
Ord a => Ord (Scalar a) 
Real a => Real (Scalar a) 
RealFloat a => RealFloat (Scalar a) 
RealFrac a => RealFrac (Scalar a) 
Show a => Show (Scalar a) 
IsString a => IsString (Scalar a) 

newtype Shape

Shape (dimensions) of a tensor.

Constructors

Shape [Int64] 

Lists

data ListOf f as where

A heterogeneous list type.

Constructors

Nil :: ListOf f `[]` 
(:/) :: f a -> ListOf f as -> ListOf f (a : as) infixr 5 

Instances

All Eq (Map f as) => Eq (ListOf f as) 
All Show (Map f as) => Show (ListOf f as) 
BuildInputs (ListOf (Tensor v) as) 
TensorTypes as => PureResult (TensorList Build as) 
(Rendered v, TensorTypes as) => BuildResult (TensorList v as) 
(Nodes (f a), Nodes (ListOf f as)) => Nodes (ListOf f ((:) * a as)) 
Nodes (ListOf f ([] *)) 
(~) * l (List ([] *)) => Fetchable (ListOf f ([] *)) l 
(Fetchable (f t) a, Fetchable (ListOf f ts) (List as), (~) (* -> *) i Identity) => Fetchable (ListOf f ((:) * t ts)) (ListOf i ((:) * a as)) 

(/:/) :: a -> List as -> List (a : as) infixr 5

Equivalent of :/ for lists.

data TensorTypeProxy a where

class TensorTypes ts where

Instances

TensorTypes ([] *) 
(TensorType t, TensorTypes ts) => TensorTypes ((:) * t ts)

A constraint that the input is a list of TensorTypes.

fromTensorTypes :: forall as. TensorTypes as => Proxy as -> [DataType]

Type constraints

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

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

A constraint checking that two types are different.

Equations

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

type OneOfs ts as = (TensorTypes as, TensorTypes ts, NoneOfs (AllTensorTypes \\ ts) as)

Implementation of constraints

data TypeError a

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 NoneOf ts a :: Constraint

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 (t1 : (t2 : (t3 : (t4 : ts)))) a = (a /= t1, a /= t2, a /= t3, a /= t4, NoneOf ts a) 
NoneOf (t1 : (t2 : (t3 : ts))) a = (a /= t1, a /= t2, a /= t3, NoneOf ts a) 
NoneOf (t1 : (t2 : ts)) a = (a /= t1, a /= t2, NoneOf ts a) 
NoneOf (t1 : ts) a = (a /= t1, NoneOf ts a) 
NoneOf `[]` a = () 

type family as \\ bs

Takes the difference of two lists of types.

Equations

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

type family Delete a as

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]`

An enumeration of all valid TensorTypes.