aesara.tensor.extra_ops.to_one_hot

Contents

aesara.tensor.extra_ops.to_one_hot#

aesara.tensor.extra_ops.to_one_hot(y, nb_class, dtype=None)[source]#

Return a matrix where each row correspond to the one hot encoding of each element in y.

Parameters:
  • y – A vector of integer value between 0 and nb_class - 1.

  • nb_class (int) – The number of class in y.

  • dtype (data-type) – The dtype of the returned matrix. Default aesara.config.floatX.

Returns:

A matrix of shape (y.shape[0], nb_class), where each row i is the one hot encoding of the corresponding y[i] value.

Return type:

object