Safe Haskell | None |
---|---|
Language | Haskell2010 |
- type family IsSubSamp (f :: [Nat]) (m :: [Nat]) (n :: [Nat]) :: Bool where ...
- type family IsMatMul (m :: [Nat]) (o :: [Nat]) (n :: [Nat]) :: Bool where ...
- type family IsConcat (m :: [Nat]) (o :: [Nat]) (n :: [Nat]) :: Bool where ...
- type family IsSameProduct (m :: [Nat]) (n :: [Nat]) :: Bool where ...
- data Tensor n t a
- = Num t => TScalar t
- | Tensor a
- | TAdd (Tensor n t a) (Tensor n t a)
- | TSub (Tensor n t a) (Tensor n t a)
- | TMul (Tensor n t a) (Tensor n t a)
- | TAbs (Tensor n t a)
- | TSign (Tensor n t a)
- | TRep (Tensor (Tail n) t a)
- | TTr (Tensor (Reverse n) t a)
- | (SingI o, SingI m, SingI n, IsMatMul m o n ~ True) => TMatMul (Tensor m t a) (Tensor o t a)
- | (SingI o, SingI m, SingI n, IsConcat m o n ~ True) => TConcat (Tensor m t a) (Tensor o t a)
- | (SingI m, IsSameProduct m n ~ True) => TReshape (Tensor m t a)
- | (SingI o, SingI m, Last n ~ Last o, Last m ~ Head (Tail (Reverse o)), Tail (Reverse n) ~ Tail (Reverse m)) => TConv2d (Tensor m t a) (Tensor o t a)
- | (SingI f, SingI m, IsSubSamp f m n ~ True) => TMaxPool (Sing f) (Tensor m t a)
- | TSoftMax (Tensor n t a)
- | TReLu (Tensor n t a)
- | TNorm (Tensor n t a)
- | (SingI f, SingI m, IsSubSamp f m n ~ True) => TSubSamp (Sing f) (Tensor m t a)
- | TApp (Tensor n t a) (Tensor m t2 a)
- | TFunc String (Tensor n t a)
- | TSym String
- | TArgT String (Tensor n t a)
- | TArgS String String
- | TArgI String Integer
- | TArgF String Float
- | TArgD String Double
- | SingI f => TArgSing String (Sing (f :: [Nat]))
- | TLabel String (Tensor n t a)
- (<+>) :: forall n t a m t2. Tensor n t a -> Tensor m t2 a -> Tensor n t a
- class Dimension a where
- toValue :: forall n t a. Sing (n :: [Nat]) -> a -> Tensor n t a
- (%*) :: forall o m n t a. (SingI o, SingI m, SingI n, IsMatMul m o n ~ True) => Tensor m t a -> Tensor o t a -> Tensor n t a
- (<--) :: SingI n => String -> Tensor n t a -> Tensor n t a
- class FromTensor a where
Documentation
type family IsSubSamp (f :: [Nat]) (m :: [Nat]) (n :: [Nat]) :: Bool where ... Source #
IsSubSamp // Subsampling constraint
- (f :: [Nat]) // strides for subsampling
- (m :: [Nat]) // dimensions of original tensor
- (n :: [Nat]) // dimensions of subsampled tensor
- :: Bool
type family IsMatMul (m :: [Nat]) (o :: [Nat]) (n :: [Nat]) :: Bool where ... Source #
IsMatMul // A constraint for matrix multiplication
- (m :: [Nat]) // dimensions of a[..., i, k]
- (o :: [Nat]) // dimensions of b[..., k, j]
- (n :: [Nat]) // dimensions of output[..., i, j] = sum_k (a[..., i, k] * b[..., k, j]), for all indices i, j.
- :: Bool
type family IsConcat (m :: [Nat]) (o :: [Nat]) (n :: [Nat]) :: Bool where ... Source #
IsConcat // A constraint for concatination of tensor
- (m :: [Nat]) // dimensions of a[..., i, ...]
- (o :: [Nat]) // dimensions of b[..., k, ...]
- (n :: [Nat]) // dimensions of output[..., i+k, ...] = concat (a,b)
- :: Bool
type family IsSameProduct (m :: [Nat]) (n :: [Nat]) :: Bool where ... Source #
IsSameProduct // A constraint for reshaping tensor
- (m :: [Nat]) // dimensions of original tensor
- (n :: [Nat]) // dimensions of reshaped tensor
- :: Bool
IsSameProduct (m ': mx) (n ': nx) = (m :== n) :&& (Product mx :== Product nx) | |
IsSameProduct mx nx = Product mx :== Product nx |
Dependently typed tensor model
This model includes basic arithmetic operators and tensorflow functions.
Num t => TScalar t | Scalar value |
Tensor a | Transform a value to dependently typed value |
TAdd (Tensor n t a) (Tensor n t a) | + of Num |
TSub (Tensor n t a) (Tensor n t a) |
|
TMul (Tensor n t a) (Tensor n t a) |
|
TAbs (Tensor n t a) | abs of Num |
TSign (Tensor n t a) | signum of Num |
TRep (Tensor (Tail n) t a) | vector wise operator |
TTr (Tensor (Reverse n) t a) | tensor tansporse operator |
(SingI o, SingI m, SingI n, IsMatMul m o n ~ True) => TMatMul (Tensor m t a) (Tensor o t a) | matrix multiply |
(SingI o, SingI m, SingI n, IsConcat m o n ~ True) => TConcat (Tensor m t a) (Tensor o t a) | concat operator |
(SingI m, IsSameProduct m n ~ True) => TReshape (Tensor m t a) | reshape function |
(SingI o, SingI m, Last n ~ Last o, Last m ~ Head (Tail (Reverse o)), Tail (Reverse n) ~ Tail (Reverse m)) => TConv2d (Tensor m t a) (Tensor o t a) | conv2d function |
(SingI f, SingI m, IsSubSamp f m n ~ True) => TMaxPool (Sing f) (Tensor m t a) | max pool |
TSoftMax (Tensor n t a) | |
TReLu (Tensor n t a) | |
TNorm (Tensor n t a) | |
(SingI f, SingI m, IsSubSamp f m n ~ True) => TSubSamp (Sing f) (Tensor m t a) | subsampling function |
TApp (Tensor n t a) (Tensor m t2 a) | |
TFunc String (Tensor n t a) | |
TSym String | |
TArgT String (Tensor n t a) | |
TArgS String String | |
TArgI String Integer | |
TArgF String Float | |
TArgD String Double | |
SingI f => TArgSing String (Sing (f :: [Nat])) | |
TLabel String (Tensor n t a) | When generating code, this label is used. |
class Dimension a where Source #
get dimension from tensor
>>>
dim (Tensor 1 :: Tensor '[192,10] Float Int)
[192,10]