7 #ifndef MSHADOW_EXTENSION_ONE_HOT_H_ 8 #define MSHADOW_EXTENSION_ONE_HOT_H_ 10 #include "../extension.h" 20 template<
typename IndexExp,
typename DType>
22 public Exp<OneHotEncodeExp<IndexExp, DType>,
23 DType, type::kChainer> {
30 : index_(index), num_choices_(num_choices) {}
33 template<
typename IndexExp,
34 typename IDType,
int e1>
38 ::Error_Expression_Does_Not_Meet_Dimension_Req();
45 template<
typename IndexExp,
typename DType>
53 return static_cast<DType
>(x == idx);
60 template<
typename IndexExp,
typename DType>
66 template<
int dim,
typename IndexExp,
typename DType>
71 <<
"OneHotEncodeExp only support 2 dimension output";
80 template<
typename IndexExp,
typename DType>
82 static const int kDim = 2;
87 #endif // MSHADOW_EXTENSION_ONE_HOT_H_ index_t num_choices_
number of choices we can have.
Definition: one_hot.h:27
Definition: expr_engine-inl.h:40
used to help static type check
Definition: expr_engine-inl.h:312
static Shape< dim > Check(const OneHotEncodeExp< IndexExp, DType > &t)
Definition: one_hot.h:69
Create a one-hot indicator array.
Definition: one_hot.h:21
static Shape< dim > Check(const E &t)
#define MSHADOW_XINLINE
Definition: base.h:204
static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == ...
Definition: expr_engine-inl.h:244
int32_t index_t
type that will be used for index
Definition: base.h:291
runtime shape checking template get the shape of an expression, report error if shape mismatch ...
Definition: expr_engine-inl.h:346
OneHotEncodeExp(const IndexExp &index, index_t num_choices)
constructor
Definition: one_hot.h:29
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:61
const SubType & self(void) const
Definition: expression.h:64
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:221
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: one_hot.h:51
const IndexExp & index_
index operand
Definition: one_hot.h:25
namespace for mshadow
Definition: base.h:282
Plan(const OneHotEncodeExp< IndexExp, DType > &e)
Definition: one_hot.h:48
OneHotEncodeExp< IndexExp, default_real_t > one_hot_encode(const Exp< IndexExp, IDType, e1 > &index, index_t num_choices)
Definition: one_hot.h:36