Copyright | (c) 2016-2017 Tao He |
---|---|
License | MIT |
Maintainer | sighingnow@gmail.com |
Safe Haskell | Safe |
Language | Haskell2010 |
DType corresponding between Haskell's data type and numpy's data type.
- class (Storable a, Show a, Eq a, Ord a, Num a, Real a) => DType a where
- pattern FLOAT32 :: forall a. (Num a, Eq a) => a
- pattern FLOAT64 :: forall a. (Num a, Eq a) => a
- pattern FLOAT16 :: forall a. (Num a, Eq a) => a
- pattern UINT8 :: forall a. (Num a, Eq a) => a
- pattern INT32 :: forall a. (Num a, Eq a) => a
- class Tensor (tensor :: * -> *) where
- class Tensor tensor => Neural tensor where
- data Context = Context {
- deviceType :: Int
- deviceId :: Int
- contextCPU :: Context
- contextGPU :: Context
Documentation
class (Storable a, Show a, Eq a, Ord a, Num a, Real a) => DType a where Source #
DType class, used to quantify types that can be passed to mxnet.
class Tensor (tensor :: * -> *) where Source #
Tensor operations.
dot, reshape, transpose, (+.), (-.), (*.), (/.), (^.), (.+), (.-), (.*), (./), (.^), (..-), (../), (..^), (.+=), (.-=), (.*=), (./=), (.^=), _Maximum, _Minimum, equal, notEqual, greater, greaterEqual, lesser, lesserEqual, _Maximum', _Minimum', equal', notEqual', greater', greaterEqual', lesser', lesserEqual'
dot :: DType a => tensor a -> tensor a -> IO (tensor a) Source #
Dot product.
reshape :: DType a => tensor a -> [Int] -> IO (tensor a) Source #
Reshape a tensor value.
transpose :: DType a => tensor a -> IO (tensor a) Source #
Transpose a tensor value.
(+.), (-.), (*.), (/.), (^.) :: DType a => tensor a -> tensor a -> IO (tensor a) Source #
Add, subtract, multiply, divide and power with IO action.
(.+), (.-), (.*), (./), (.^) :: DType a => tensor a -> a -> IO (tensor a) infixr 8 .^infixl 7 .*, ./infixl 6 .+, .- Source #
Ordinary arithmetic operators with scalar value.
(..-), (../), (..^) :: DType a => a -> tensor a -> IO (tensor a) infixr 8 ..^infixl 7 ../infixl 6 ..- Source #
Flip version of ordinary arithmetic operators with scalar value.
(.+=), (.-=), (.*=), (./=), (.^=) :: DType a => tensor a -> a -> IO () Source #
Mutable ordinary arithmetic operators with scalar value.
_Maximum, _Minimum, equal, notEqual, greater, greaterEqual, lesser, lesserEqual :: DType a => tensor a -> tensor a -> IO (tensor a) Source #
Compare two tensor values, after comparison, all cell may be set as a same value, or 0, or 1.
_Maximum', _Minimum', equal', notEqual', greater', greaterEqual', lesser', lesserEqual' :: DType a => tensor a -> a -> IO (tensor a) Source #
Compare a tensor value with a scalar value, after comparison, all cell may be set as a same value, or 0, or 1.
class Tensor tensor => Neural tensor where Source #
Neural network combinators.
fullyConnected, correlation, activation, leakyReLU, softmaxActivation, dropout, batchNorm, instanceNorm, l2Normalization, convolution, lrn, deconvolution, pooling, roiPooling, rnn, embedding, bilinearSampler, gridGenerator, upSampling, spatialTransformer, linearRegressionOutput, logisticRegressionOutput, softmaxOutput, maeRegressionOutput, svmOutput, softmaxCrossEntropy, smoothL1, identityAttachKLSparsereg, makeLoss, blockGrad, custom
:: DType a | |
=> tensor a | Input data. |
-> tensor a | Weight matrix. |
-> tensor a | Bias parameter. |
-> Int | Number of hidden nodes of the output. |
-> IO (tensor a) |
Apply a linear transformation: Y = X W^T + b.
:: DType a | |
=> tensor a | Input data1 to the correlation. |
-> tensor a | Input data2 to the correlation. |
-> IO (tensor a) |
Apply correlation to inputs
:: DType a | |
=> tensor a | Input data to activation function. |
-> String | Activation function to be applied, one of { |
-> IO (tensor a) |
ElementWise activation function.
:: DType a | |
=> tensor a | Input data to activation function. |
-> String | Activation function to be applied, one of { |
-> IO (tensor a) |
Leaky ReLu activation
The following types are supported:
- elu: y = x > 0 ? x : slop * (exp(x)-1)
- leaky: y = x > 0 ? x : slope * x
- prelu: same as leaky but the slope is learnable.
- rrelu: same as leaky but the slope is uniformly randomly chosen from [lower_bound, upper_bound) for training, while fixed to be (lower_bound+upper_bound)/2 for inference.
Apply softmax activation to input.
:: DType a | |
=> tensor a | Input data to dropout. |
-> Float | Fraction of the input that gets dropped out at training time, default is 0.5. |
-> IO (tensor a) |
Apply dropout to input.
:: DType a | |
=> tensor a | Input data to batch normalization. |
-> tensor a | Gamma |
-> tensor a | Beta |
-> tensor a | Moving mean |
-> tensor a | Moving var |
-> IO (tensor a) |
Batch normalization.
:: DType a | |
=> tensor a | A n-dimensional tensor (n > 2) of the form [batch, channel, spatial_dim1, spatial_dim2, ...]. |
-> tensor a | Gamma, a vector of length |
-> tensor a | Beta, a vector of length |
-> Float | Epsilon to prevent division by 0. |
-> IO (tensor a) |
An operator taking in a n-dimensional input tensor (n > 2), and normalizing the input by subtracting the mean and variance calculated over the spatial dimensions.
:: DType a | |
=> tensor a | Input data to the L2NormalizationOp. |
-> Float | Epsilon to prevent div 0, default is 1e-10. |
-> String | Normalization Mode, one of { |
-> IO (tensor a) |
Set the l2 norm of each instance to a constant.
:: DType a | |
=> tensor a | Input data. |
-> tensor a | Weight matrix. |
-> tensor a | Bias parameter. |
-> String | Convolution kernel size: (h, w) or (d, h, w). |
-> Int | Convolution filter(channel) number. |
-> IO (tensor a) |
Convolution Compute N-D convolution on (N+2)-D input.
:: DType a | |
=> tensor a | Input data to the ConvolutionOp. |
-> Float | Alpha, value of the alpha variance scaling parameter in the normalization formula, default is 0.0001. |
-> Float | Beta, value of the beta power parameter in the normalization formula, default is 0.75. |
-> Float | Value of the k parameter in normalization formula, default is 2. |
-> Int | Normalization window width in elements. |
-> IO (tensor a) |
Apply convolution to input then add a bias.
:: DType a | |
=> tensor a | Input data to the DeconvolutionOp. |
-> tensor a | Weight matrix. |
-> tensor a | Bias parameter. |
-> String | Convolution kernel size: (h, w) or (d, h, w). |
-> Int | Convolution filter(channel) number. |
-> IO (tensor a) |
Apply deconvolution to input then add a bias.
:: DType a | |
=> tensor a | Input data to the pooling operator. |
-> String | Pooling kernel size: (y, x) or (d, y, x). |
-> String | |
-> IO (tensor a) |
Perform pooling on the input.
:: DType a | |
=> tensor a | Input data to the pooling operator, a 4D Feature maps. |
-> tensor a | Bounding box coordinates. |
-> String | Fix pooled size: (h, w). |
-> Int | Ratio of input feature map height (or w) to raw image height (or w). |
-> IO (tensor a) |
Performs region-of-interest pooling on inputs.
:: DType a | |
=> tensor a | Input data to RNN. |
-> tensor a | Vector of all RNN trainable parameters concatenated. |
-> tensor a | Initial hidden state of the RNN. |
-> tensor a | Initial cell state for LSTM networks (only for LSTM). |
-> Int | Size of the state for each layer. |
-> Int | Number of stacked layers. |
-> String | The type of RNN to compute, one of { |
-> IO (tensor a) |
Apply a recurrent layer to input.
:: DType a | |
=> tensor a | Input data to the EmbeddingOp. |
-> tensor a | Embedding weight matrix. |
-> Int | Vocabulary size of the input indices. |
-> Int | Dimension of the embedding vectors. |
-> IO (tensor a) |
Map integer index to vector representations (embeddings).
:: DType a | |
=> tensor a | Input data to the BilinearsamplerOp. |
-> tensor a | Input grid to the BilinearsamplerOp.grid has two channels: x_src, y_src. |
-> IO (tensor a) |
Apply bilinear sampling to input feature map, which is the key of “[NIPS2015] Spatial Transformer Networks” output[batch, channel, y_dst, x_dst] = G(data[batch, channel, y_src, x_src) x_dst, y_dst enumerate all spatial locations in output x_src = grid[batch, 0, y_dst, x_dst] y_src = grid[batch, 1, y_dst, x_dst] G() denotes the bilinear interpolation kernel The out-boundary points will be padded as zeros.
:: DType a | |
=> tensor a | Input data to the BilinearsamplerOp. |
-> tensor a | Input grid to the BilinearsamplerOp.grid has two channels: x_src, y_src. |
-> IO (tensor a) |
generate sampling grid for bilinear sampling.
:: DType a | |
=> [tensor a] | Array of tensors to upsample. |
-> Int | Up sampling scale. |
-> String | Upsampling method, one of { |
-> IO (tensor a) |
Perform nearest neighboor/bilinear up sampling to inputs
:: DType a | |
=> tensor a | Input data to the SpatialTransformerOp. |
-> tensor a | Localisation net, the output dim should be 6 when transform_type is affine. |
-> IO (tensor a) |
Apply spatial transformer to input feature map.
linearRegressionOutput Source #
Use linear regression for final output, this is used on final output of a net.
logisticRegressionOutput Source #
Use Logistic regression for final output, this is used on final output of a net.
Softmax with logit loss.
Use mean absolute error regression for final output, this is used on final output of a net.
:: DType a | |
=> tensor a | Input data to svm. |
-> tensor a | Label data. |
-> Int | Margin, scale the DType(param_.margin) for activation size, default is 1. |
-> Float | Regularization coefficient, Scale the coefficient responsible for balacing coefficient size and error tradeoff, default is 1. |
-> Bool | Use linear, if set true, uses L1-SVM objective function. Default uses L2-SVM objective, default is False. |
-> IO (tensor a) |
Support Vector Machine based transformation on input, backprop L2-SVM
Calculate cross_entropy(data, one_hot(label))
Calculate Smooth L1 Loss(lhs, scalar)
identityAttachKLSparsereg Source #
Apply a sparse regularization to the output a sigmoid activation function.
:: DType a | |
=> tensor a | Input data. |
-> Float | Gradient scale as a supplement to unary and binary operators, default is 1. |
-> Float | Valid thresh, default is 0. Regard element valid when x > valid_thresh, this is used only in valid normalization mode. |
-> String | Normalization, one of { |
-> IO (tensor a) |
Get output from a symbol and pass 1 gradient back.
Get output from a symbol and pass 0 gradient back
:: DType a | |
=> [tensor a] | Input of custom operator |
-> String | Type of custom operator, must be registered first. |
-> IO (tensor a) |
Custom operator implemented in frontend.
Context definition.
DeviceType
- cpu
- gpu
- cpu_pinned
Context | |
|
contextCPU :: Context Source #
Context for CPU 0.
contextGPU :: Context Source #
Context for GPU 0.