Apache SINGA
A distributed deep learning platform .
 All Classes Namespaces Files Functions Variables Typedefs Macros
Namespaces | Classes | Functions
mshadow::expr Namespace Reference

namespace for abstract expressions and expressions template, have no dependecy on tensor.h, These data structure takes no charge in computations, they are only used to define operations and represent expression in a symbolic way More...

Namespaces

 type
 type of expressions
 

Classes

struct  ExpEngine
 expression engine that actually interprets these expressions this is a function template that needed to be implemented for specific expressions More...
 
class  ContainerExp
 base class of all variables, that can be assigned to values More...
 
struct  Exp
 base class for expression More...
 
struct  ScalarExp
 scalar expression More...
 
struct  TransposeExp
 represent a transpose expression of a container More...
 
struct  DotExp
 matrix multiplication expression dot( lhs[.T], rhs[.T] ) More...
 
struct  BinaryMapExp
 binary map expression lhs [op] rhs More...
 
struct  UnaryMapExp
 unary map expression op(src) More...
 
struct  MakeTensorExp
 a general class that allows extension that makes tensors of some shape More...
 
class  Plan
 This part of code gives plan that can be used to carry out execution. More...
 
class  Plan< Tensor< Device, dim > >
 
class  Plan< Tensor< Device, 1 > >
 
class  Plan< ScalarExp >
 
class  Plan< BinaryMapExp< OP, TA, TB, etype > >
 
class  Plan< UnaryMapExp< OP, TA, etype > >
 
struct  Plan< MakeTensorExp< SubType, SrcExp, dim > >
 
struct  ExpInfo
 static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == -1, this means here are mismatch in expression if ( ExpInfo<E>::kDevMask & cpu::kDevMask ) != 0, this means this expression can be assigned to cpu More...
 
struct  ExpInfo< ScalarExp >
 
struct  ExpInfo< Tensor< Device, dim > >
 
struct  ExpInfo< MakeTensorExp< T, SrcExp, dim > >
 
struct  ExpInfo< UnaryMapExp< OP, TA, etype > >
 
struct  ExpInfo< BinaryMapExp< OP, TA, TB, etype > >
 
struct  TypeCheck
 template to do type check More...
 
struct  TypeCheckPass
 
struct  TypeCheckPass< false >
 
struct  TypeCheckPass< true >
 
struct  ShapeCheck
 
struct  ShapeCheck< dim, ScalarExp >
 
struct  ShapeCheck< dim, Tensor< Device, dim > >
 
struct  ShapeCheck< dim, MakeTensorExp< T, SrcExp, dim > >
 
struct  ShapeCheck< dim, UnaryMapExp< OP, TA, etype > >
 
struct  ShapeCheck< dim, BinaryMapExp< OP, TA, TB, etype > >
 
struct  DotEngine
 
struct  BLASEngine
 
struct  BLASEngine< cpu >
 
struct  BLASEngine< gpu >
 
struct  DotEngine< SV, xpu, 2, 2, 2, transpose_left, transpose_right >
 
struct  DotEngine< SV, xpu, 1, 1, 2, false, transpose_right >
 
struct  DotEngine< SV, xpu, 2, 1, 1, true, false >
 
struct  ExpComplexEngine
 some engine that evaluate complex expression More...
 
struct  ExpEngine< SV, Tensor< Device, dim > >
 
struct  ExpComplexEngine< SV, Device, dim, DotExp< Tensor< Device, ldim >, Tensor< Device, rdim >, ltrans, rtrans > >
 
struct  Broadcast1DExp
 broadcast Tensor1D into a higher dimension Tensor input: Tensor<Device,1>: ishape[0] output: Tensor<Device,dimdst> : oshape[dimcast] = ishape[0] More...
 
struct  UnpackPatchToColXExp
 unpack local (overlap) patches of image to column of mat, can be used to implement convolution, this expression allow unpack of a batch this is a version support unpacking multiple images after getting unpacked mat, we can use: output = dot( weight, mat ) to get covolved results, the relations: More...
 
struct  PackColToPatchXExp
 reverse operation of UnpackPatchToCol, used to backprop gradient back this is a version supporting multiple images More...
 
struct  ReshapeExp
 reshape the content to another shape input: Tensor<Device,dimsrc>: ishape output: Tensor<Device,dimdst> ishape.Size() == oshape.Size() More...
 
struct  SwapAxisExp
 swap two axis of a tensor input: Tensor<Device,dim>: ishape output: Tensor<Device,dimdst> oshape[a1],oshape[a2] = ishape[a2],oshape[a1] More...
 
struct  ReduceTo1DExp
 reduction to 1 dimension tensor input: Tensor<Device,k>: ishape output: Tensor<Device,1> shape[0] = ishape[dimkeep]; More...
 
struct  PoolingExp
 pooling expression, do reduction over local patches of a image More...
 
struct  UnPoolingExp
 unpooling expr reverse operation of pooling, used to pass gradient back More...
 
struct  PaddingExp
 padding expression, pad a image with zeros More...
 
struct  CroppingExp
 crop expression, cut off the boundary region, reverse operation of padding More...
 
struct  MirroringExp
 mirror expression, mirror a image in width More...
 
struct  ChannelPoolingExp
 channel pooling expression, do reduction over (local nearby) channels, used to implement local response normalization More...
 
struct  ExpComplexEngine< SV, Device, 1, ReduceTo1DExp< EType, Reducer, dimkeep > >
 
struct  ExpComplexEngine< SV, Device, 1, ReduceTo1DExp< EType, Reducer, 0 > >
 
struct  Plan< Broadcast1DExp< Device, dimdst, dimcast > >
 execution plan of Broadcast1DExp More...
 
struct  Plan< Broadcast1DExp< Device, dimdst, 0 > >
 execution plan of Broadcast1DExp More...
 
struct  Plan< UnpackPatchToColXExp< SrcExp, srcdim > >
 
struct  Plan< PackColToPatchXExp< Device, dstdim > >
 
struct  Plan< ReshapeExp< SrcExp, dimdst, dimsrc > >
 
struct  Plan< ReshapeExp< SrcExp, dimdst, 1 > >
 
struct  Plan< SwapAxisExp< SrcExp, dimsrc, a1, a2 > >
 
struct  Plan< SwapAxisExp< SrcExp, dimsrc, 0, a2 > >
 
struct  Plan< PoolingExp< Reducer, SrcExp, srcdim > >
 
struct  Plan< UnPoolingExp< Reducer, Device > >
 
struct  Plan< PaddingExp< SrcExp, srcdim > >
 
struct  Plan< CroppingExp< SrcExp, srcdim > >
 
struct  Plan< MirroringExp< SrcExp, srcdim > >
 
struct  Plan< ChannelPoolingExp< Reducer, SrcExp, srcdim > >
 
struct  SSECheck< Broadcast1DExp< cpu, dimdst, 0 > >
 
struct  SSEAlignCheck< 2, Broadcast1DExp< cpu, dimdst, 0 > >
 
class  SSEPlan< Broadcast1DExp< cpu, dimdst, 0 > >
 
class  SSEPlan
 
class  SSEPlan< Tensor< Device, dim > >
 
class  SSEPlan< ScalarExp >
 
class  SSEPlan< BinaryMapExp< OP, TA, TB, etype > >
 
class  SSEPlan< UnaryMapExp< OP, TA, etype > >
 
struct  SSECheck
 static check sse enable if a expression E can not be evaluated using sse, then kPass = false More...
 
struct  SSECheck< ScalarExp >
 
struct  SSECheck< Tensor< cpu, dim > >
 
struct  SSECheck< UnaryMapExp< OP, TA, etype > >
 
struct  SSECheck< BinaryMapExp< OP, TA, TB, etype > >
 
struct  SSEAlignCheck
 
struct  SSEAlignCheck< dim, ScalarExp >
 
struct  SSEAlignCheck< dim, Tensor< cpu, dim > >
 
struct  SSEAlignCheck< dim, UnaryMapExp< OP, TA, etype > >
 
struct  SSEAlignCheck< dim, BinaryMapExp< OP, TA, TB, etype > >
 

Functions

template<typename TA , typename TB >
DotExp< TA, TB, false, false > dot (const ContainerExp< TA > &lhs, const ContainerExp< TB > &rhs)
 dot operator def
 
template<typename TA , typename TB >
DotExp< TA, TB, true, false > dot (const TransposeExp< TA > &lhs, const ContainerExp< TB > &rhs)
 dot operator def
 
template<typename TA , typename TB >
DotExp< TA, TB, false, true > dot (const ContainerExp< TA > &lhs, const TransposeExp< TB > &rhs)
 dot operator def
 
template<typename TA , typename TB >
DotExp< TA, TB, true, true > dot (const TransposeExp< TA > &lhs, const TransposeExp< TB > &rhs)
 dot operator def
 
template<typename TA , typename TB , bool ltrans, bool rtrans>
DotExp< TA, TB, ltrans, rtrans > operator* (const DotExp< TA, TB, ltrans, rtrans > &lhs, real_t rhs)
 dot operator def
 
template<typename TA , typename TB , bool ltrans, bool rtrans>
DotExp< TA, TB, ltrans, rtrans > operator* (real_t lhs, const DotExp< TA, TB, ltrans, rtrans > &rhs)
 scale of dot operation
 
template<typename OP , typename TA , typename TB , int ta, int tb>
BinaryMapExp< OP, TA, TB,(ta|tb|type::kMapper) > MakeExp (const Exp< TA, ta > &lhs, const Exp< TB, tb > &rhs)
 make expression
 
template<typename OP , typename TA , typename TB , int ta, int tb>
BinaryMapExp< OP, TA, TB,(ta|tb|type::kMapper) > F (const Exp< TA, ta > &lhs, const Exp< TB, tb > &rhs)
 short hand for MakeExp, usage F<op>(lhs, rhs). create a binary operation expression More...
 
template<typename OP , typename TA , int ta>
BinaryMapExp< OP, TA,
ScalarExp,(ta|type::kMapper) > 
F (const Exp< TA, ta > &lhs, const ScalarExp &rhs)
 operator overload for const
 
template<typename OP , typename TB , int tb>
BinaryMapExp< OP, ScalarExp,
TB,(tb|type::kMapper) > 
F (const ScalarExp &lhs, const Exp< TB, tb > &rhs)
 operator overload for const
 
template<typename TA , typename TB , int ta, int tb>
BinaryMapExp< op::plus, TA, TB,(ta|tb|type::kMapper) > operator+ (const Exp< TA, ta > &lhs, const Exp< TB, tb > &rhs)
 operator overload
 
template<typename TA , typename TB , int ta, int tb>
BinaryMapExp< op::minus, TA,
TB,(ta|tb|type::kMapper) > 
operator- (const Exp< TA, ta > &lhs, const Exp< TB, tb > &rhs)
 operator overload
 
template<typename TA , typename TB , int ta, int tb>
BinaryMapExp< op::mul, TA, TB,(ta|tb|type::kMapper) > operator* (const Exp< TA, ta > &lhs, const Exp< TB, tb > &rhs)
 operator overload
 
template<typename TA , typename TB , int ta, int tb>
BinaryMapExp< op::div, TA, TB,(ta|tb|type::kMapper) > operator/ (const Exp< TA, ta > &lhs, const Exp< TB, tb > &rhs)
 operator overload
 
template<typename TA , int ta>
BinaryMapExp< op::plus, TA,
ScalarExp,(ta|type::kMapper) > 
operator+ (const Exp< TA, ta > &lhs, const ScalarExp &rhs)
 operator overload
 
template<typename TA , int ta>
BinaryMapExp< op::minus, TA,
ScalarExp,(ta|type::kMapper) > 
operator- (const Exp< TA, ta > &lhs, const ScalarExp &rhs)
 operator overload
 
template<typename TA , int ta>
BinaryMapExp< op::mul, TA,
ScalarExp,(ta|type::kMapper) > 
operator* (const Exp< TA, ta > &lhs, const ScalarExp &rhs)
 operator overload
 
template<typename TA , int ta>
BinaryMapExp< op::div, TA,
ScalarExp,(ta|type::kMapper) > 
operator/ (const Exp< TA, ta > &lhs, const ScalarExp &rhs)
 operator overload
 
template<typename TB , int tb>
BinaryMapExp< op::plus,
ScalarExp, TB,(tb|type::kMapper) > 
operator+ (const ScalarExp &lhs, const Exp< TB, tb > &rhs)
 operator overload
 
template<typename TB , int tb>
BinaryMapExp< op::minus,
ScalarExp, TB,(tb|type::kMapper) > 
operator- (const ScalarExp &lhs, const Exp< TB, tb > &rhs)
 operator overload
 
template<typename TB , int tb>
BinaryMapExp< op::mul,
ScalarExp, TB,(tb|type::kMapper) > 
operator* (const ScalarExp &lhs, const Exp< TB, tb > &rhs)
 operator overload
 
template<typename TB , int tb>
BinaryMapExp< op::div,
ScalarExp, TB,(tb|type::kMapper) > 
operator/ (const ScalarExp &lhs, const Exp< TB, tb > &rhs)
 operator overload
 
template<typename OP , typename TA , int ta>
UnaryMapExp< OP, TA,(ta|type::kMapper) > MakeExp (const Exp< TA, ta > &src)
 make expression
 
template<typename OP , typename TA , int ta>
UnaryMapExp< OP, TA,(ta|type::kMapper) > F (const Exp< TA, ta > &src)
 short hand for MakeExp, usage F<op>(src), create a unary operation expression More...
 
template<typename OP , typename TA , typename TB , int etype>
Plan< BinaryMapExp< OP, TA, TB,
etype > > 
MakePlan (const BinaryMapExp< OP, TA, TB, etype > &e)
 
Plan< ScalarExpMakePlan (const ScalarExp &e)
 
template<typename T >
Plan< T > MakePlan (const ContainerExp< T > &e)
 
template<typename T , typename SrcExp , int dim>
Plan< T > MakePlan (const MakeTensorExp< T, SrcExp, dim > &e)
 
template<typename OP , typename TA , int etype>
Plan< UnaryMapExp< OP, TA,
etype > > 
MakePlan (const UnaryMapExp< OP, TA, etype > &e)
 
template<typename E , typename R , int d>
ReduceTo1DExp< E, R, d > operator* (const ReduceTo1DExp< E, R, d > &e, real_t scale)
 operator overload
 
template<typename E , typename R , int d>
ReduceTo1DExp< E, R, d > operator* (real_t scale, const ReduceTo1DExp< E, R, d > &e)
 operator overload
 
template<int dimcast, typename Device , int dimdst>
Broadcast1DExp< Device, dimdst,
dimcast > 
broadcast (const Tensor< Device, 1 > &src, Shape< dimdst > shape)
 a expression that replicate a 1 dimension tensor in dimension dimcast More...
 
template<typename SrcExp , int etype>
UnpackPatchToColXExp< SrcExp,
ExpInfo< SrcExp >::kDim > 
unpack_patch2col (const Exp< SrcExp, etype > &img, index_t psize, index_t pstride)
 unpack local (overlap) patches of image to column of mat, can be used to implement convolution after getting unpacked mat, we can use: output = dot( weight, mat ) to get covolved results, the relations: More...
 
template<typename Device , int dstdim>
PackColToPatchXExp< Device,
dstdim > 
pack_col2patch (const Tensor< Device, 2 > &mat, Shape< dstdim > imshape, index_t psize, index_t pstride)
 reverse operation of pack_col2patch, can be used to implement deconvolution More...
 
template<typename SrcExp , int etype, int dimdst>
ReshapeExp< SrcExp, dimdst,
ExpInfo< SrcExp >::kDim > 
reshape (const Exp< SrcExp, etype > &src, Shape< dimdst > oshape)
 a expression that reshapes a tensor to another shape More...
 
template<int a1, int a2, typename SrcExp , int etype>
SwapAxisExp< SrcExp, ExpInfo
< SrcExp >::kDim, a1, a2 > 
swapaxis (const Exp< SrcExp, etype > &src)
 a expression that reshapes a tensor to another shape More...
 
template<int dimkeep, typename SrcExp , int etype>
ReduceTo1DExp< SrcExp,
red::sum, dimkeep > 
sumall_except_dim (const Exp< SrcExp, etype > &exp)
 a sum over all dimensions, except dimkeep More...
 
template<typename Reducer , typename SrcExp , int etype>
PoolingExp< Reducer, SrcExp,
ExpInfo< SrcExp >::kDim > 
pool (const Exp< SrcExp, etype > &src, index_t ksize, index_t kstride)
 pooling subregion results together More...
 
template<typename Reducer , typename SrcExp , int etype>
PoolingExp< Reducer, SrcExp,
ExpInfo< SrcExp >::kDim > 
pool (const Exp< SrcExp, etype > &src, Shape< 2 > pshape, index_t ksize, index_t kstride)
 same as pool, except the output shape is specified by pshape More...
 
template<typename Reducer , typename Device >
UnPoolingExp< Reducer, Device > unpool (const Tensor< Device, 4 > &data_src, const Tensor< Device, 4 > &data_pooled, const Tensor< Device, 4 > &grad_pooled, index_t ksize, index_t kstride)
 unpooling gradient for 4D, backprop gradient value back, revserse operation of pooling More...
 
template<typename SrcExp , int etype>
PaddingExp< SrcExp, ExpInfo
< SrcExp >::kDim > 
pad (const Exp< SrcExp, etype > &src, index_t pad)
 padding expression, pad a image with zeros on boundaries, padding affects shape[0], and shape[1] More...
 
template<typename SrcExp , int etype>
CroppingExp< SrcExp, ExpInfo
< SrcExp >::kDim > 
crop (const Exp< SrcExp, etype > &src, Shape< 2 > oshape)
 revserse operationg of padding, cut off boundaries, crop output from center of input More...
 
template<typename SrcExp , int etype>
CroppingExp< SrcExp, ExpInfo
< SrcExp >::kDim > 
crop (const Exp< SrcExp, etype > &src, Shape< 2 > oshape, index_t start_height, index_t start_width)
 same as crop, but can specify starting position to do cropping More...
 
template<typename SrcExp , int etype>
MirroringExp< SrcExp, ExpInfo
< SrcExp >::kDim > 
mirror (const Exp< SrcExp, etype > &src)
 mirroring expression, mirror images in width More...
 
template<typename Reducer , typename SrcExp , int etype>
ChannelPoolingExp< Reducer,
SrcExp, ExpInfo< SrcExp >
::kDim > 
chpool (const Exp< SrcExp, etype > &src, index_t nsize)
 channel pooling, do reduction over (local nearby) channels, used to implement local response normalization More...
 
template<typename Device >
Broadcast1DExp< Device, 2, 0 > repmat (const Tensor< Device, 1 > &src, index_t nrow)
 a expression that replicate a 1 dimension tensor for nrow times More...
 
template<typename SrcExp , int etype>
ReduceTo1DExp< SrcExp,
red::sum, 0 > 
sum_rows (const Exp< SrcExp, etype > &exp)
 a expression that sum over rows of a matrix More...
 
template<typename OP , typename TA , typename TB , int etype>
SSEPlan< BinaryMapExp< OP, TA,
TB, etype > > 
MakeSSEPlan (const BinaryMapExp< OP, TA, TB, etype > &e)
 
SSEPlan< ScalarExpMakeSSEPlan (const ScalarExp &e)
 
template<typename T >
SSEPlan< T > MakeSSEPlan (const ContainerExp< T > &e)
 
template<typename T , int dim>
SSEPlan< T > MakeSSEPlan (const MakeTensorExp< T, cpu, dim > &e)
 
template<typename OP , typename TA , int etype>
SSEPlan< UnaryMapExp< OP, TA,
etype > > 
MakeSSEPlan (const UnaryMapExp< OP, TA, etype > &e)
 

Detailed Description

namespace for abstract expressions and expressions template, have no dependecy on tensor.h, These data structure takes no charge in computations, they are only used to define operations and represent expression in a symbolic way

Function Documentation

template<int dimcast, typename Device , int dimdst>
Broadcast1DExp<Device,dimdst,dimcast> mshadow::expr::broadcast ( const Tensor< Device, 1 > &  src,
Shape< dimdst >  shape 
)
inline

a expression that replicate a 1 dimension tensor in dimension dimcast

Parameters
srcTensor<Device,1>: shape[0]
shapeshape of output
Returns
a expresion with type Tensor<Device,dimdst>
Template Parameters
dimcasttarget dimension where the 1D tensor will be broadcasted
Devicewhich device it lies
dimdstdimension of destination tensor
template<typename Reducer , typename SrcExp , int etype>
ChannelPoolingExp<Reducer,SrcExp, ExpInfo<SrcExp>::kDim > mshadow::expr::chpool ( const Exp< SrcExp, etype > &  src,
index_t  nsize 
)
inline

channel pooling, do reduction over (local nearby) channels, used to implement local response normalization

Parameters
srcsource data
nsizeneighbor size
Returns
expression of pooled result
Template Parameters
Reducerreducer type
SrcExpsource expression
etypetype of expression
template<typename SrcExp , int etype>
CroppingExp<SrcExp, ExpInfo<SrcExp>::kDim> mshadow::expr::crop ( const Exp< SrcExp, etype > &  src,
Shape< 2 >  oshape 
)
inline

revserse operationg of padding, cut off boundaries, crop output from center of input

Parameters
srcoriginal image batches
oshapeoutput shape to be cropped
Returns
expression corresponding to padded result
Template Parameters
SrcExpsource expression
etypetype of expression
template<typename SrcExp , int etype>
CroppingExp<SrcExp, ExpInfo<SrcExp>::kDim> mshadow::expr::crop ( const Exp< SrcExp, etype > &  src,
Shape< 2 >  oshape,
index_t  start_height,
index_t  start_width 
)
inline

same as crop, but can specify starting position to do cropping

Parameters
srcoriginal image batches
oshapeoutput shape to be cropped
start_heightstart height position to do cropping
start_widthstart width position to do cropping
Returns
expression corresponding to padded result
Template Parameters
SrcExpsource expression
etypetype of expression
template<typename OP , typename TA , typename TB , int ta, int tb>
BinaryMapExp<OP,TA,TB, (ta|tb|type::kMapper) > mshadow::expr::F ( const Exp< TA, ta > &  lhs,
const Exp< TB, tb > &  rhs 
)
inline

short hand for MakeExp, usage F<op>(lhs, rhs). create a binary operation expression

Parameters
lhsleft operand
rhsright operand
Template Parameters
binaryoperator
TAlhs expression
talhs expression type
TBrhs expression
tbrhs expression type
See Also
mshadow::op
template<typename OP , typename TA , int ta>
UnaryMapExp<OP,TA,(ta|type::kMapper) > mshadow::expr::F ( const Exp< TA, ta > &  src)
inline

short hand for MakeExp, usage F<op>(src), create a unary operation expression

Parameters
srcsource expression
Template Parameters
operator
TAsource expression
tasource expression type
See Also
mshadow::op
template<typename SrcExp , int etype>
MirroringExp<SrcExp, ExpInfo<SrcExp>::kDim> mshadow::expr::mirror ( const Exp< SrcExp, etype > &  src)
inline

mirroring expression, mirror images in width

Parameters
srcoriginal image batches
Returns
expression corresponding to mirrored result
Template Parameters
SrcExpsource expression
etypetype of expression
template<typename Device , int dstdim>
PackColToPatchXExp<Device,dstdim> mshadow::expr::pack_col2patch ( const Tensor< Device, 2 > &  mat,
Shape< dstdim >  imshape,
index_t  psize,
index_t  pstride 
)
inline

reverse operation of pack_col2patch, can be used to implement deconvolution

Returns
packed img expression
Parameters
matsource matrix
imshapeshape of target img
psizeheight and width of each patch
pstridestride of each patch
Template Parameters
Devicethe Device where input data lies
template<typename SrcExp , int etype>
PaddingExp<SrcExp, ExpInfo<SrcExp>::kDim> mshadow::expr::pad ( const Exp< SrcExp, etype > &  src,
index_t  pad 
)
inline

padding expression, pad a image with zeros on boundaries, padding affects shape[0], and shape[1]

Parameters
srcoriginal image batches
padpadding size
Returns
expression corresponding to padded result
Template Parameters
SrcExpsource expression
etypetype of expression
template<typename Reducer , typename SrcExp , int etype>
PoolingExp<Reducer,SrcExp, ExpInfo<SrcExp>::kDim > mshadow::expr::pool ( const Exp< SrcExp, etype > &  src,
index_t  ksize,
index_t  kstride 
)
inline

pooling subregion results together

Parameters
srcsource image, shape[3]: batch, shape[2]: channel shape[1]: height shape[0]:width
ksizekernel size
kstridestride for each kernel
Returns
expression of pooled result
Template Parameters
Reducerreducer type
SrcExpsource expression
etypetype of expression
template<typename Reducer , typename SrcExp , int etype>
PoolingExp<Reducer,SrcExp, ExpInfo<SrcExp>::kDim > mshadow::expr::pool ( const Exp< SrcExp, etype > &  src,
Shape< 2 >  pshape,
index_t  ksize,
index_t  kstride 
)
inline

same as pool, except the output shape is specified by pshape

Parameters
srcsource image
pshapeouput shape
ksizekernel size
kstridestride for each kernel
Returns
expression of pooled result
Template Parameters
Reducerreducer type
SrcExpsource expression
etypetype of expression
template<typename Device >
Broadcast1DExp<Device,2,0> mshadow::expr::repmat ( const Tensor< Device, 1 > &  src,
index_t  nrow 
)
inline

a expression that replicate a 1 dimension tensor for nrow times

Parameters
srcTensor<Device,1>: shape[0]
nrownumber of rows to replicate
Returns
a expresion with type Tensor<Device,2> shape[0], shape[1] = nrow
Template Parameters
Devicewhich device it lies
template<typename SrcExp , int etype, int dimdst>
ReshapeExp< SrcExp,dimdst, ExpInfo<SrcExp>::kDim > mshadow::expr::reshape ( const Exp< SrcExp, etype > &  src,
Shape< dimdst >  oshape 
)
inline

a expression that reshapes a tensor to another shape

Parameters
srcTensor<Device,dimsrc>:
oshapetarget shape
Returns
a expresion with type Tensor<Device,dimdst>
Template Parameters
SrcExpsource expression
etypesource expression type
dimdsttarget dimension
template<typename SrcExp , int etype>
ReduceTo1DExp<SrcExp, red::sum, 0 > mshadow::expr::sum_rows ( const Exp< SrcExp, etype > &  exp)
inline

a expression that sum over rows of a matrix

Parameters
expinput expression that must be a matrix Tensor<?,2>
Returns
a expresion with type Tensor<Device,1>
Template Parameters
SrcExpexpression
etypetype of expression
template<int dimkeep, typename SrcExp , int etype>
ReduceTo1DExp<SrcExp, red::sum, dimkeep > mshadow::expr::sumall_except_dim ( const Exp< SrcExp, etype > &  exp)
inline

a sum over all dimensions, except dimkeep

Parameters
expinput expression that must be a matrix Tensor<?,2>
Returns
a expresion with type Tensor<Device,1>
Template Parameters
dimkeepthe dimension that will be kept
SrcExpexpression
etypetype of expression
template<int a1, int a2, typename SrcExp , int etype>
SwapAxisExp< SrcExp, ExpInfo<SrcExp>::kDim, a1,a2> mshadow::expr::swapaxis ( const Exp< SrcExp, etype > &  src)
inline

a expression that reshapes a tensor to another shape

Parameters
srcTensor<Device,dimsrc>:
Returns
a expresion with type Tensor<Device,dimdst>
Template Parameters
a1smaller dimension to be swapped
a2larger dimension to be swapped
SrcExpsource expression
etypesource expression type
template<typename SrcExp , int etype>
UnpackPatchToColXExp<SrcExp, ExpInfo<SrcExp>::kDim > mshadow::expr::unpack_patch2col ( const Exp< SrcExp, etype > &  img,
index_t  psize,
index_t  pstride 
)
inline

unpack local (overlap) patches of image to column of mat, can be used to implement convolution after getting unpacked mat, we can use: output = dot( weight, mat ) to get covolved results, the relations:

weight; shape[1]: out_channel, shape[0]: ichannel*psize*psize output; shape[1]: out_channel, shape[0]: out_height*out_width * num_of_images out_height = ( in_height - psize ) / pstride + 1, this means we pad inperfect patch with 0 out_width = ( in_width - psize ) / pstride + 1

Returns
mat target matrix; shape[1]: in_channel*psize*psize shape[0]: out_height*out_width * num_of_images
Parameters
imgsource image; shape[2]: in_channels, shape[1]: in_height, shape[0]: in_width, can be 3D or 4D tensor(multiple images)
psizeheight and width of each patch
pstridestride of each patch
Template Parameters
SrcExpsource expression
etypetype of expression
template<typename Reducer , typename Device >
UnPoolingExp<Reducer, Device> mshadow::expr::unpool ( const Tensor< Device, 4 > &  data_src,
const Tensor< Device, 4 > &  data_pooled,
const Tensor< Device, 4 > &  grad_pooled,
index_t  ksize,
index_t  kstride 
)
inline

unpooling gradient for 4D, backprop gradient value back, revserse operation of pooling

Parameters
data_srcsource input, corresponds to src in pooling
data_pooledresult of pooled data, corresponds to result of pooling
grad_pooledgradient data of pooled part, to be propgate down
ksizekernel size
kstridestride for each kernel
Returns
expression corresponding to unpooled 4D Tensor, storing backproped gradient
Template Parameters
Reducerreducer type
Devicedevice where data lies