typedflow-0.9: Typed frontend to TensorFlow and higher-order deep learning

Copyright(c) Jean-Philippe Bernardy 2017
LicenseLGPL-3
Maintainerjean-philippe.bernardy@gu.se
Stabilityexperimental
Safe HaskellNone
LanguageHaskell2010

TypedFlow.Layers.Core

Contents

Description

 

Synopsis

Dense

data DenseP t a b Source #

A dense layer is a linear function form a to b: a transformation matrix and a bias.

Constructors

DenseP 

Fields

Instances

(KnownNat n, KnownNat m, KnownBits NBits b) => ParamWithDefault (DenseP b n m) Source # 
(KnownNat a, KnownNat b, KnownBits NBits t) => KnownTensors (DenseP t a b) Source # 

Methods

travTensor :: (forall s c. (KnownTyp Typ c, KnownShape s) => String -> T s c -> Gen (T s c)) -> String -> DenseP t a b -> Gen (DenseP t a b) Source #

dense :: forall m n batchSize t. DenseP t n m -> Tensor '[n, batchSize] (Flt t) -> Tensor '[m, batchSize] (Flt t) Source #

Dense layer (Apply a linear function)

(#) :: forall m n batchSize t. DenseP t n m -> Tensor '[n, batchSize] (Flt t) -> Tensor '[m, batchSize] (Flt t) Source #

Dense layer (Apply a linear function)

Dropout

data DropProb Source #

A drop probability. (This type is used to make sure one does not confuse keep probability and drop probability)

Constructors

DropProb Float 

mkDropout :: forall s t. KnownShape s => KnownBits t => DropProb -> Gen (Tensor s (Typ Float t) -> Tensor s (Typ Float t)) Source #

Generate a dropout function. The mask applied by the returned function will be constant for any given call to mkDropout. This behavior allows to use the same mask in the several steps of an RNN.

mkDropouts :: KnownBits t => KnownLen shapes => All KnownShape shapes => DropProb -> Gen (HTV (Typ Float t) shapes -> HTV (Typ Float t) shapes) Source #

Generate a dropout function for an heterogeneous tensor vector.

Embedding

newtype EmbeddingP numObjects embeddingSize t Source #

Parameters for the embedding layers

Constructors

EmbeddingP (Tensor '[numObjects, embeddingSize] (Typ Float t)) 

Instances

(KnownNat numObjects, KnownBits NBits b, KnownNat embeddingSize) => ParamWithDefault (EmbeddingP numObjects embeddingSize b) Source # 

Methods

defaultInitializer :: EmbeddingP numObjects embeddingSize b Source #

(KnownNat numObjects, KnownBits NBits b, KnownNat embeddingSize) => KnownTensors (EmbeddingP numObjects embeddingSize b) Source # 

Methods

travTensor :: (forall s t. (KnownTyp Typ t, KnownShape s) => String -> T s t -> Gen (T s t)) -> String -> EmbeddingP numObjects embeddingSize b -> Gen (EmbeddingP numObjects embeddingSize b) Source #

embedding :: forall embeddingSize numObjects batchSize t. EmbeddingP numObjects embeddingSize t -> Tensor '[batchSize] Int32 -> Tensor '[embeddingSize, batchSize] (Typ Float t) Source #

embedding layer

Convolutional

data ConvP t outChannels inChannels filterSpatialShape Source #

Constructors

ConvP (T ('[outChannels, inChannels] ++ filterSpatialShape) (Typ Float t)) (T '[outChannels] (Typ Float t)) 

Instances

(KnownNat outChannels, KnownNat inChannels, KnownShape filterSpatialShape, KnownBits NBits t) => ParamWithDefault (ConvP t outChannels inChannels filterSpatialShape) Source # 

Methods

defaultInitializer :: ConvP t outChannels inChannels filterSpatialShape Source #

(KnownNat outChannels, KnownNat inChannels, KnownShape filterSpatialShape, KnownBits NBits t) => KnownTensors (ConvP t outChannels inChannels filterSpatialShape) Source # 

Methods

travTensor :: (forall s a. (KnownTyp Typ a, KnownShape s) => String -> T s a -> Gen (T s a)) -> String -> ConvP t outChannels inChannels filterSpatialShape -> Gen (ConvP t outChannels inChannels filterSpatialShape) Source #

conv :: forall outChannels filterSpatialShape inChannels s t. ((1 + Length filterSpatialShape) ~ Length s, Length filterSpatialShape <= 3, KnownLen filterSpatialShape) => ConvP t outChannels inChannels filterSpatialShape -> T ('[inChannels] ++ s) (Typ Float t) -> T ('[outChannels] ++ s) (Typ Float t) Source #

Size-preserving convolution layer

maxPool2D :: forall stridex stridey batch height width channels t. (KnownNat stridex, KnownNat stridey) => T '[channels, width * stridex, height * stridex, batch] (Flt t) -> T '[channels, width, height, batch] (Flt t) Source #

2 by 2 maxpool layer.