researchutils
master

Contents:

  • API Reference
    • Utilities related to arrays
      • Arrays
    • Utilities related to chainer
    • Utilities related to files
    • Utilities related to images
    • Utilities related to math
researchutils
  • Docs »
  • API Reference »
  • Utilities related to arrays
  • Edit on GitHub

Utilities related to arrays¶

Arrays¶

researchutils.arrays.one_hot(indices, shape, on_value=1, off_value=0, dtype=None)[source]¶

Create one hot vector(s)

Parameters:
  • indices (list of int) – list of index to set on_value in each vector
  • shape (tuple of int) – Number of rows and arrays to create. Length of the shape must be 2. shape must be in the form of (rows, array_num) and will create array_num vectors of shape (rows, 1)
  • on_value (int, default 1) – value to set on given indices
  • off_value (int, default 0) – value to set on fields other than given indices
  • dtype (numpy.dtype) –
Returns:

one hot vectors – matrix of given shape

Return type:

numpy.ndarray

Next Previous

© Copyright 2018, Yu Ishihara Revision 34a5e71f.

Built with Sphinx using a theme provided by Read the Docs.