oneHot function

Matrix oneHot(
  1. int value,
  2. int size
)

one hot encoding of a matrix

  • value The value to encode
  • size The size of the matrix
  • Returns The new matrix

Implementation

Matrix oneHot(int value, int size) {
  Matrix matrix = zeros(1, size);
  matrix.setAt(0, value, value: 1);
  return matrix;
}