jacinle.nd.indexing#

Functions

index_select_batch(data, indices)

Gather indices as batch indices from data, which can either be typical nd array or a list of nd array.

one_hot(label, nr_classes[, dtype])

Convert a label array to one-hot array.

one_hot_nd(label, nr_classes[, dtype])

Convert a label array to one-hot array.

Functions

index_select_batch(data, indices)[source]#

Gather indices as batch indices from data, which can either be typical nd array or a list of nd array.

Parameters:
Returns:

the selected data.

Return type:

ndarray

one_hot(label, nr_classes, dtype='float32')[source]#

Convert a label array to one-hot array. This function works for either 0d (scalar) or 1d (vector) label array. If you want to convert higher dimensional label array, use one_hot_nd() instead.

Parameters:
  • label (ndarray) – the label array.

  • nr_classes (int) – the number of classes.

  • dtype – the data type of the one-hot array.

Returns:

the one-hot array.

Return type:

ndarray

one_hot_nd(label, nr_classes, dtype='float32')[source]#

Convert a label array to one-hot array.

Parameters:
  • label – the label array.

  • nr_classes – the number of classes.

  • dtype – the data type of the one-hot array.

Returns:

the one-hot array.