Class Index

java.lang.Object
smile.deep.tensor.Index

public class Index extends Object
Indexing a tensor.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Index
    The colon (:) is used to slice all elements of a dimension.
    static final Index
    The ellipsis (...) is used to slice higher-dimensional data structures as in numpy.
    static final Index
    The None is used to insert a singleton dimension ("unsqueeze" a dimension).
  • Method Summary

    Modifier and Type
    Method
    Description
    static Index
    of(boolean... indices)
    Returns the index of multiple elements in a dimension.
    static Index
    of(int i)
    Returns the index of a single element in a dimension.
    static Index
    of(int... indices)
    Returns the index of multiple elements in a dimension.
    static Index
    of(long i)
    Returns the index of a single element in a dimension.
    static Index
    of(long... indices)
    Returns the index of multiple elements in a dimension.
    static Index
    of(Tensor index)
    Returns the tensor index along a dimension.
    static Index
    slice(Integer start, Integer end)
    Returns the slice index for [start, end) with step 1.
    static Index
    slice(Integer start, Integer end, Integer step)
    Returns the slice index for [start, end) with step 1.
    static Index
    slice(Long start, Long end)
    Returns the slice index for [start, end) with step 1.
    static Index
    slice(Long start, Long end, Long step)
    Returns the slice index for [start, end) with the given step.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • Ellipsis

      public static final Index Ellipsis
      The ellipsis (...) is used to slice higher-dimensional data structures as in numpy. It's designed to mean at this point, insert as many full slices (:) to extend the multidimensional slice to all dimensions.
    • Colon

      public static final Index Colon
      The colon (:) is used to slice all elements of a dimension.
    • None

      public static final Index None
      The None is used to insert a singleton dimension ("unsqueeze" a dimension).
  • Method Details

    • of

      public static Index of(int i)
      Returns the index of a single element in a dimension.
      Parameters:
      i - the element index.
      Returns:
      the index.
    • of

      public static Index of(long i)
      Returns the index of a single element in a dimension.
      Parameters:
      i - the element index.
      Returns:
      the index.
    • of

      public static Index of(int... indices)
      Returns the index of multiple elements in a dimension.
      Parameters:
      indices - the indices of multiple elements.
      Returns:
      the index.
    • of

      public static Index of(long... indices)
      Returns the index of multiple elements in a dimension.
      Parameters:
      indices - the indices of multiple elements.
      Returns:
      the index.
    • of

      public static Index of(boolean... indices)
      Returns the index of multiple elements in a dimension.
      Parameters:
      indices - the boolean flags to select multiple elements. The length of array should match that of the corresponding dimension of tensor.
      Returns:
      the index.
    • of

      public static Index of(Tensor index)
      Returns the tensor index along a dimension.
      Parameters:
      index - the tensor index.
      Returns:
      the index.
    • slice

      public static Index slice(Integer start, Integer end)
      Returns the slice index for [start, end) with step 1.
      Parameters:
      start - the start index.
      end - the end index.
      Returns:
      the slice.
    • slice

      public static Index slice(Integer start, Integer end, Integer step)
      Returns the slice index for [start, end) with step 1.
      Parameters:
      start - the start index.
      end - the end index.
      step - the incremental step.
      Returns:
      the slice.
    • slice

      public static Index slice(Long start, Long end)
      Returns the slice index for [start, end) with step 1.
      Parameters:
      start - the start index.
      end - the end index.
      Returns:
      the slice.
    • slice

      public static Index slice(Long start, Long end, Long step)
      Returns the slice index for [start, end) with the given step.
      Parameters:
      start - the start index.
      end - the end index.
      step - the incremental step.
      Returns:
      the slice.