25 #ifndef MSHADOW_EXTENSION_ONE_HOT_H_ 26 #define MSHADOW_EXTENSION_ONE_HOT_H_ 28 #include "../extension.h" 38 template<
typename IndexExp,
typename DType>
40 public Exp<OneHotEncodeExp<IndexExp, DType>,
41 DType, type::kChainer> {
48 : index_(index), num_choices_(num_choices) {}
51 template<
typename IndexExp,
52 typename IDType,
int e1>
56 ::Error_Expression_Does_Not_Meet_Dimension_Req();
63 template<
typename IndexExp,
typename DType>
71 return static_cast<DType
>(x == idx);
78 template<
typename IndexExp,
typename DType>
84 template<
int dim,
typename IndexExp,
typename DType>
89 <<
"OneHotEncodeExp only support 2 dimension output";
98 template<
typename IndexExp,
typename DType>
100 static const int kDim = 2;
105 #endif // MSHADOW_EXTENSION_ONE_HOT_H_ index_t num_choices_
number of choices we can have.
Definition: one_hot.h:45
MSHADOW_XINLINE DType Eval(index_t y, index_t x) const
Definition: one_hot.h:69
const SubType & self(void) const
Definition: expression.h:82
Definition: expr_engine-inl.h:58
used to help static type check
Definition: expr_engine-inl.h:330
static Shape< dim > Check(const OneHotEncodeExp< IndexExp, DType > &t)
Definition: one_hot.h:87
Create a one-hot indicator array.
Definition: one_hot.h:39
static Shape< dim > Check(const E &t)
#define MSHADOW_XINLINE
Definition: base.h:230
static type inference template, used to get the dimension of each expression, if ExpInfo<E>::kDim == ...
Definition: expr_engine-inl.h:262
int32_t index_t
type that will be used for index
Definition: base.h:343
runtime shape checking template get the shape of an expression, report error if shape mismatch ...
Definition: expr_engine-inl.h:364
OneHotEncodeExp(const IndexExp &index, index_t num_choices)
constructor
Definition: one_hot.h:47
defines how expression exp can be evaluated and stored into dst
Definition: expression.h:79
Plan< BinaryMapExp< OP, TA, TB, DType, etype >, DType > MakePlan(const BinaryMapExp< OP, TA, TB, DType, etype > &e)
Definition: expr_engine-inl.h:239
const IndexExp & index_
index operand
Definition: one_hot.h:43
overloaded + operator between half_t and bf16_t
Definition: base.h:334
Plan(const OneHotEncodeExp< IndexExp, DType > &e)
Definition: one_hot.h:66
OneHotEncodeExp< IndexExp, default_real_t > one_hot_encode(const Exp< IndexExp, IDType, e1 > &index, index_t num_choices)
Definition: one_hot.h:54