Packages

  • package root
    Definition Classes
    root
  • package lamp

    Lamp provides utilities to build state of the art machine learning applications

    Lamp provides utilities to build state of the art machine learning applications

    Overview

    Notable types and packages:

    • lamp.STen is a memory managed wrapper around aten.ATen, an off the heap, native n-dimensionl array backed by libtorch.
    • lamp.autograd implements reverse mode automatic differentiation.
    • lamp.nn contains neural network building blocks, see e.g. lamp.nn.Linear.
    • lamp.data.IOLoops implements a training loop and other data related abstractions.
    • lamp.knn implements k-nearest neighbor search on the CPU and GPU
    • lamp.umap.Umap implements the UMAP dimension reduction algorithm
    • lamp.onnx implements serialization of computation graphs into ONNX format
    • lamp.io contains CSV and NPY readers
    How to get data into lamp

    Use one of the file readers in lamp.io or one of the factories in lamp.STen$.

    How to define a custom neural network layer

    See the documentation on lamp.nn.GenericModule

    How to compose neural network layers

    See the documentation on lamp.nn

    How to train models

    See the training loops in lamp.data.IOLoops

    Definition Classes
    root
  • package autograd

    Implements reverse mode automatic differentiaton

    Implements reverse mode automatic differentiaton

    The main types in this package are lamp.autograd.Variable and lamp.autograd.Op. The computational graph built by this package consists of vertices representing values (as lamp.autograd.Variable) and vertices representing operations (as lamp.autograd.Op).

    Variables contain the value of a Rn => Rm function. Variables may also contain the partial derivative of their argument with respect to a single scalar. A Variable whose value is a scalar (m=1) can trigger the computation of partial derivatives of all the intermediate upstream Variables. Computing partial derivatives with respect to non-scalar variables is not supported.

    A constant Variable may be created with the const or param factory method in this package. const may be used for constants which do not need their partial derivatives to be computed. param on the other hand create Variables which will fill in their partial derivatives. Further variables may be created by the methods in this class, eventually expressing more complex Rn => Rm functions.

    Example
    lamp.Scope.root{ implicit scope =>
      // x is constant (depends on no other variables) and won't compute a partial derivative
      val x = lamp.autograd.const(STen.eye(3, STenOptions.d))
      // y is constant but will compute a partial derivative
      val y = lamp.autograd.param(STen.ones(List(3,3), STenOptions.d))
    
      // z is a Variable with x and y dependencies
      val z = x+y
    
      // w is a Variable with z as a direct and x, y as transient dependencies
      val w = z.sum
      // w is a scalar (number of elements is 1), thus we can call backprop() on it.
      // calling backprop will fill out the partial derivatives of the upstream variables
      w.backprop()
    
      // partialDerivative is empty since we created `x` with `const`
      assert(x.partialDerivative.isEmpty)
    
      // `y`'s partial derivatie is defined and is computed
      // it holds `y`'s partial derivative with respect to `w`, the scalar which we called backprop() on
      assert(y.partialDerivative.isDefined)
    
    }

    This package may be used to compute the derivative of any function, provided the function can be composed out of the provided methods. A particular use case is gradient based optimization.

    Definition Classes
    lamp
    See also

    https://arxiv.org/pdf/1811.05031.pdf for a review of the algorithm

    lamp.autograd.Op for how to implement a new operation

  • package data
    Definition Classes
    lamp
  • package distributed
    Definition Classes
    lamp
  • package extratrees
    Definition Classes
    lamp
  • package knn
    Definition Classes
    lamp
  • package nn

    Provides building blocks for neural networks

    Provides building blocks for neural networks

    Notable types:

    Optimizers:

    Modules facilitating composing other modules:

    • nn.Sequential composes a homogenous list of modules (analogous to List)
    • nn.sequence composes a heterogeneous list of modules (analogous to tuples)
    • nn.EitherModule composes two modules in a scala.Either

    Examples of neural network building blocks, layers etc:

    Definition Classes
    lamp
  • package onnx
    Definition Classes
    lamp
  • package saddle
    Definition Classes
    lamp
  • package table
    Definition Classes
    lamp
  • package umap
    Definition Classes
    lamp
  • package util
    Definition Classes
    lamp
  • BufferPair
  • CPU
  • ColumnSelection
  • CudaDevice
  • Device
  • DoublePrecision
  • EmptyMovable
  • FloatingPointPrecision
  • HalfPrecision
  • MPS
  • Movable
  • NcclUniqueId
  • STen
  • STenOptions
  • Scope
  • SinglePrecision
  • TensorHelpers

case class STen extends Product with Serializable

Memory managed, off-heap, GPU and CPU compatible N-dimensional array.

This class is a wrapper around aten.Tensor providing a more convenient API. All allocating operations require an implicit lamp.Scope.

STen instances are associated with a device which determines where the memory is allocated, and where the operations are performed. Operations on multiple tensors expect that all the arguments reside on the same device.

lamp.STen.options returns a lamp.STenOptions which describes the device, shape, data type and storage layout of a tensor. Most factory methods in the companion object in turn require a lamp.STenOptions to specify the device, data types and storage layout.

Naming convention of most operations follows libtorch. Operations return their result in a copy, i.e. not in place. These operations need a lamp.Scope. Operations whose name ends with an underscore are in place. Operations whose name contains out will write their results into the specified output tensor, these are in the companion object. Some operations are exempt from this naming rule, e.g. +=, -=, *= etc.

Semantics of operations follow those of libtorch with the same name. Many of the operations broadcasts. See https://numpy.org/doc/stable/user/basics.broadcasting.html#general-broadcasting-rules for broadcasting rules. In short:

  1. shapes are aligned from the right, extending with ones to the left as needed. 2. If two aligned dimensions are not matching but one of them is 1, then it is expanded to the size of the other dimension, pretending a copy of all its values. If two aligned dimension are not matching and neither of them is 1, then the operation fails.

Examples

Scope.root { implicit scope =>
    val sum = Scope { implicit scope =>
    val ident = STen.eye(3, STenOptions.d)
    val ones = STen.ones(List(3, 3), STenOptions.d)
    ident + ones
    }
    assert(sum.toMat == mat.ones(3, 3) + mat.ident(3))
}
Broadcasting examples
// successful
3 x 4 x 6 A
    4 x 6 B
3 x 4 x 6 Result // B is repeated 3 times first dimensions

// successful
3 x 4 x 6 A
3 x 1 x 6 B
3 x 4 x 6 Result // B's second dimension is repeated 4 times

// fail
3 x 4 x 6 A
3 x 2 x 6 B
3 x 4 x 6 Result // 2 != 4

The companion object contains various factories which copy data from the JVM memory to STen tensors.

Linear Supertypes
Serializable, Product, Equals, AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. STen
  2. Serializable
  3. Product
  4. Equals
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. def *[S](other: Double)(implicit arg0: Sc[S]): STen

    Multiplication

  4. def *[S](other: Tensor)(implicit arg0: Sc[S]): STen

    Multiplication

  5. def *[S](other: Long)(implicit arg0: Sc[S]): STen
  6. def *[S](other: STen)(implicit arg0: Sc[S]): STen

    Multiplication

  7. def *=(other: Long): Unit

    In place multiplication.

  8. def *=(other: Double): Unit

    In place multiplication.

  9. def *=(other: STen): Unit

    In place multiplication.

  10. def +[S](other: Long)(implicit arg0: Sc[S]): STen

    Adds a scalar to all elements.

  11. def +[S](other: Double)(implicit arg0: Sc[S]): STen

    Adds a scalar to all elements.

  12. def +[S](other: STen)(implicit arg0: Sc[S]): STen

    Adds to tensors.

  13. def +=(other: Long): Unit

    In place add.

  14. def +=(other: Double): Unit

    In place add.

  15. def +=(other: STen): Unit

    In place add.

  16. def -[S](other: STen)(implicit arg0: Sc[S]): STen

    Subtracts other.

  17. def -=(other: STen): Unit

    Subtracts other in place.

  18. def /[S](other: Long)(implicit arg0: Sc[S]): STen

    Division.

  19. def /[S](other: Double)(implicit arg0: Sc[S]): STen

    Division.

  20. def /[S](other: Tensor)(implicit arg0: Sc[S]): STen

    Division.

  21. def /[S](other: STen)(implicit arg0: Sc[S]): STen

    Division.

  22. def /=(other: STen): Unit

    In place division.

  23. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  24. def abs[S](implicit arg0: Sc[S]): STen
  25. def abs_(): Unit
  26. def acos[S](implicit arg0: Sc[S]): STen
  27. def acos_(): Unit
  28. def add[S](other: Double, alpha: Double)(implicit arg0: Sc[S]): STen

    Adds a value multipled by a scalar (a + alpha * b).

  29. def add[S](other: STen, alpha: Double)(implicit arg0: Sc[S]): STen

    Adds an other tensor multipled by a scalar (a + alpha * b).

  30. def add_l[S](other: STen)(implicit arg0: Sc[S]): STen

    Adds to tensors.

  31. def addcmul[S](tensor1: STen, tensor2: STen, alpha: Double)(implicit arg0: Sc[S]): STen

    Elementwise this + alpha * tensor1 * tensor2

  32. def addcmulSelf(tensor1: STen, tensor2: Tensor, alpha: Double): Unit

    Elementwise in place this + alpha * tensor1 * tensor2

  33. def addcmulSelf(tensor1: STen, tensor2: STen, alpha: Double): Unit

    Elementwise in place this + alpha * tensor1 * tensor2

  34. def addmm[S](mat1: STen, mat2: STen, beta: Double, alpha: Double)(implicit arg0: Sc[S]): STen

    beta * this + alpha * (mat1 matmul mat2)

  35. def all[S](dim: Int, keepDim: Boolean)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating that all of the elements are true in the respective dimension

  36. def all[S](implicit arg0: Sc[S]): STen

    Return a boolean scalar tensor indicating that all of the elements are true

  37. def any[S](dim: Int, keepDim: Boolean)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating that any of the elements true in the respective dimension

  38. def any[S](implicit arg0: Sc[S]): STen

    Return a boolean scalar tensor indicating that any of the elements is true

  39. def argmax[S](dim: Long, keepDim: Boolean)(implicit arg0: Sc[S]): STen

    Reduces the given dimension with the index of its maximum element.

    Reduces the given dimension with the index of its maximum element.

    keepDim

    if true then the reduced dimension is kept with size 1

  40. def argmin[S](dim: Long, keepDim: Boolean)(implicit arg0: Sc[S]): STen

    Reduces the given dimension with the index of its minimum element.

    Reduces the given dimension with the index of its minimum element.

    keepDim

    if true then the reduced dimension is kept with size 1

  41. def argsort[S](stable: Boolean, dim: Int, descending: Boolean)(implicit arg0: Sc[S]): STen

    Returns a long tensors with the argsort of the given dimension.

    Returns a long tensors with the argsort of the given dimension.

    Indexing the given dimension by the returned tensor would result in a sorted order.

  42. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  43. def asin[S](implicit arg0: Sc[S]): STen
  44. def asin_(): Unit
  45. def atan[S](implicit arg0: Sc[S]): STen
  46. def atan_(): Unit
  47. def baddbmm[S](batch1: STen, batch2: STen, beta: Double, alpha: Double)(implicit arg0: Sc[S]): STen

    Batched add mm.

  48. def bincount[S](weights: Option[STen], minLength: Int = 0)(implicit arg0: Sc[S]): STen
  49. def bmm[S](other: STen)(implicit arg0: Sc[S]): STen

    Batched matrix multiplication.

    Batched matrix multiplication. Maps to Aten.bmm.

    Performs the same matrix multiplication along multiple batches. Batch dimensions do not broadcast.

  50. def castToBool[S](implicit arg0: Sc[S]): STen

    Casts to bool

  51. def castToByte[S](implicit arg0: Sc[S]): STen

    Casts to byte.

    Casts to byte. signed 8-bit integer (like Scala's Byte) This is called Char in libtorch

  52. def castToDouble[S](implicit arg0: Sc[S]): STen

    Casts to double

  53. def castToFloat[S](implicit arg0: Sc[S]): STen

    Casts to float

  54. def castToHalf[S](implicit arg0: Sc[S]): STen

    Casts to half

  55. def castToInt[S](implicit arg0: Sc[S]): STen

    Casts to int

  56. def castToLong[S](implicit arg0: Sc[S]): STen

    Casts to long

  57. def castToShort[S](implicit arg0: Sc[S]): STen

    Casts to short

  58. def castToType[S](scalarType: Byte)(implicit arg0: Sc[S]): STen
  59. def cat[S](other: STen, dim: Long)(implicit arg0: Sc[S]): STen

    Concatenates two tensors along the given dimension.

    Concatenates two tensors along the given dimension. Other dimensions must conform.

  60. def ceil[S](implicit arg0: Sc[S]): STen
  61. def ceil_(): Unit
  62. def cholesky[S](upper: Boolean)(implicit arg0: Sc[S]): STen
  63. def choleskyInverse[S](upper: Boolean)(implicit arg0: Sc[S]): STen
  64. def choleskyLower[S](implicit arg0: Sc[S]): STen
  65. def choleskySolve[S](choleskyFactor: STen, upper: Boolean)(implicit arg0: Sc[S]): STen
  66. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @IntrinsicCandidate() @native()
  67. def cloneTensor[S](implicit arg0: Sc[S]): STen

    Returns a copy of this tensor

  68. def coalesce[S](implicit arg0: Sc[S]): STen
  69. def colSum[S](implicit arg0: Sc[S]): STen

    Sum over the first dimension

  70. def cond[S](norm: String)(implicit arg0: Sc[S]): STen
  71. def copyFrom(source: STen, nonBlocking: Boolean): Unit

    Overwrites the contents of this tensor with the contents of an other.

    Overwrites the contents of this tensor with the contents of an other. Must conform.

  72. def copyFrom(source: STen): Unit

    Overwrites the contents of this tensor with the contents of an other.

    Overwrites the contents of this tensor with the contents of an other. Must conform. non blocking is true

  73. def copyFrom(source: Tensor, nonBlocking: Boolean = true): Unit

    Overwrites the contents of this tensor with the contents of an other.

    Overwrites the contents of this tensor with the contents of an other. Must conform.

  74. def copyTo[S](options: STenOptions)(implicit arg0: Sc[S]): STen

    Returns a copy of this tensor adapted to the given options

  75. def copyToDevice(device: Device)(implicit scope: Scope): STen

    Returns a copy of this tensor on the given device

  76. def cos[S](implicit arg0: Sc[S]): STen
  77. def cos_(): Unit
  78. def cross[S](other: STen, dim: Int)(implicit arg0: Sc[S]): STen
  79. def det[S](implicit arg0: Sc[S]): STen
  80. def device: Product with Device with Serializable

    Returns the Device this tensor resides on

  81. def deviceIndex: Int

    Returns the device index.

    Returns the device index. Only for Cuda tensors.

  82. def diag[S](diagonal: Long)(implicit arg0: Sc[S]): STen
  83. def diagonalView[S](offset: Int = 0, dim1: Int = 0, dim2: Int = 1)(implicit arg0: Sc[S]): STen
  84. def dot[S](other: STen)(implicit arg0: Sc[S]): STen
  85. def dropout_(p: Double, training: Boolean): Unit
  86. def eigh[S](uplo: String)(implicit arg0: Sc[S]): (STen, STen)
  87. def eigvalsh[S](uplo: String)(implicit arg0: Sc[S]): STen
  88. def elementSize: Long
  89. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  90. def equ[S](other: Long)(implicit arg0: Sc[S]): STen

    Returns a boolean tensors of the same shape, indicating equality with the other value.

  91. def equ[S](other: Double)(implicit arg0: Sc[S]): STen

    Returns a boolean tensors of the same shape, indicating equality with the other value.

  92. def equ[S](other: STen)(implicit arg0: Sc[S]): STen

    Returns a boolean tensors of the same shape, indicating equality with the other tensor.

  93. def equalDeep(input2: STen): Boolean

    Return a boolean tensor indicating element-wise equality.

    Return a boolean tensor indicating element-wise equality. Maps to Aten.equal

  94. def exp[S](implicit arg0: Sc[S]): STen
  95. def exp_(): Unit
  96. def expand(shape: List[Long])(implicit scope: Scope): STen
  97. def expandAs[S](other: STen)(implicit arg0: Sc[S]): STen
  98. def expm1[S](implicit arg0: Sc[S]): STen
  99. def fill_(v: STen): Unit

    In place fills with the given tensor.

  100. def fill_(v: Double): Unit

    In place fills the tensors with the given value

  101. def flatten[S](startDim: Long, endDim: Long)(implicit arg0: Sc[S]): STen

    Flattens between the given dimensions.

    Flattens between the given dimensions. Inclusive.

  102. def floor[S](implicit arg0: Sc[S]): STen
  103. def floor_(): Unit
  104. def frobeniusNorm[S](dim: Seq[Int], keepDim: Boolean)(implicit arg0: Sc[S]): STen
  105. def gather[S](dim: Long, index: STen)(implicit arg0: Sc[S]): STen
  106. def gather[S](dim: Long, index: Tensor)(implicit arg0: Sc[S]): STen
  107. def ge[S](other: Double)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise greater-or-equal.

  108. def ge[S](other: STen)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise greater-or-equal.

  109. def gelu[S](implicit arg0: Sc[S]): STen

    Gaussian Error Linear Unit

  110. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @IntrinsicCandidate() @native()
  111. def gt[S](other: Double)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise greater-than.

  112. def gt[S](other: STen)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise greater-than.

  113. def hardSwish[S](implicit arg0: Sc[S]): STen
  114. def index[S](indices: STen*)(implicit arg0: Sc[S]): STen

    Indexes with the given tensors along multiple dimensions.

  115. def indexAdd[S](dim: Long, index: Tensor, source: STen)(implicit arg0: Sc[S]): STen
  116. def indexAdd[S](dim: Long, index: STen, source: STen)(implicit arg0: Sc[S]): STen
  117. def indexCopy[S](dim: Int, index: STen, source: STen)(implicit arg0: Sc[S]): STen
  118. def indexFill[S](dim: Long, index: Tensor, source: Double)(implicit arg0: Sc[S]): STen
  119. def indexFill[S](dim: Long, index: STen, source: Double)(implicit arg0: Sc[S]): STen
  120. def indexFill[S](dim: Long, index: STen, source: STen)(implicit arg0: Sc[S]): STen
  121. def indexPut[S](indices: List[STen], values: STen, accumulate: Boolean)(implicit arg0: Sc[S]): STen
  122. def indexSelect[S](dim: Long, index: Tensor)(implicit arg0: Sc[S]): STen

    Selects along the given dimension with indices in the supplied long tensor.

  123. def indexSelect[S](dim: Long, index: STen)(implicit arg0: Sc[S]): STen

    Selects along the given dimension with indices in the supplied long tensor.

  124. def indices[S](implicit arg0: Sc[S]): STen

    Returns indices.

    Returns indices. Only for sparse tensors

  125. def inner[S](other: STen)(implicit arg0: Sc[S]): STen
  126. def inv[S](implicit arg0: Sc[S]): STen
  127. def isCPU: Boolean

    Returns true if device is CPU

  128. def isCuda: Boolean

    Returns true if device is Cuda

  129. def isDouble: Boolean

    Returns true if data type is double

  130. def isFloat: Boolean

    Returns true if data type is float

  131. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  132. def isInt: Boolean

    Returns true if data type is int

  133. def isLong: Boolean

    Returns true if data type is long

  134. def isPinned: Boolean
  135. def isShort: Boolean

    Returns true if data type is short

  136. def isSparse: Boolean

    Returns true if this is sparse tensor

  137. def isfinite[S](implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise is-finite.

  138. def isnan[S](implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise is-nan.

  139. def le[S](other: Double)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise less-or-equal.

  140. def le[S](other: STen)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise less-or-equal.

  141. def leakyRelu[S](negativeSlope: Double)(implicit arg0: Sc[S]): STen

    Leaky rectified linear unit

  142. def leakyRelu_(negativeSlope: Double): Unit

    In place leaky rectified linear unit

  143. def log[S](implicit arg0: Sc[S]): STen
  144. def log10[S](implicit arg0: Sc[S]): STen
  145. def log1p[S](implicit arg0: Sc[S]): STen
  146. def log1p_(): Unit
  147. def logSoftMax[S](dim: Int)(implicit arg0: Sc[S]): STen

    Reduces the given dimension with the log-softmax of its elements.

  148. def log_(): Unit
  149. def logicalAnd[S](other: STen)(implicit arg0: Sc[S]): STen

    Return a boolean tensor with element-wise logical and.

  150. def logicalNot[S](implicit arg0: Sc[S]): STen

    Return a boolean tensor with element-wise logical not.

  151. def logicalOr[S](other: STen)(implicit arg0: Sc[S]): STen

    Return a boolean tensor with element-wise logical or.

  152. def logicalXor[S](other: STen)(implicit arg0: Sc[S]): STen

    Return a boolean tensor with element-wise logical xor.

  153. def lt[S](other: Double)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise greater-than.

  154. def lt[S](other: STen)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise less-than.

  155. def maskFill[S](mask: STen, fill: Long)(implicit arg0: Sc[S]): STen

    Fills the tensor with the given fill value in the locations indicated by the mask boolean mask.

  156. def maskFill[S](mask: STen, fill: Double)(implicit arg0: Sc[S]): STen

    Fills the tensor with the given fill value in the locations indicated by the mask boolean mask.

  157. def maskedFill[S](mask: Tensor, fill: Double)(implicit arg0: Sc[S]): STen

    Fills with the given value according to the boolean mask.

  158. def maskedFill[S](mask: STen, fill: Double)(implicit arg0: Sc[S]): STen

    Fills with the given value according to the boolean mask.

  159. def maskedScatter[S](mask: STen, src: STen)(implicit arg0: Sc[S]): STen
  160. def maskedSelect[S](mask: Tensor)(implicit arg0: Sc[S]): STen

    Selects the elements according to the boolean mask.

    Selects the elements according to the boolean mask. Returns a 1D tensor.

  161. def maskedSelect[S](mask: STen)(implicit arg0: Sc[S]): STen

    Selects the elements according to the boolean mask.

    Selects the elements according to the boolean mask. Returns a 1D tensor.

  162. def matmul[S](other: STen)(implicit arg0: Sc[S]): STen
  163. def matrixPower[S](n: Int)(implicit arg0: Sc[S]): STen
  164. def matrixRank[S](hermitian: Boolean)(implicit arg0: Sc[S]): STen
  165. def matrixRank[S](tol: STen, symmetric: Boolean)(implicit arg0: Sc[S]): STen
  166. def max[S](dim: Int, keepDim: Boolean)(implicit arg0: Sc[S]): (STen, STen)

    Reduces the given dimension with its max.

  167. def max[S](other: STen)(implicit arg0: Sc[S]): STen

    Return the elementwise max.

  168. def max[S](implicit arg0: Sc[S]): STen
  169. def mean[S](dim: Int, keepDim: Boolean)(implicit arg0: Sc[S]): STen
  170. def mean[S](dim: Seq[Int], keepDim: Boolean)(implicit arg0: Sc[S]): STen

    Reduces the given dimensions with their mean.

  171. def mean[S](implicit arg0: Sc[S]): STen
  172. def median[S](dim: Int, keepDim: Boolean)(implicit arg0: Sc[S]): (STen, STen)

    Reduces the given dimension with its median.

  173. def median[S](implicit arg0: Sc[S]): STen
  174. def min[S](dim: Int, keepDim: Boolean)(implicit arg0: Sc[S]): (STen, STen)

    Reduces the given dimension with its max.

  175. def min[S](other: STen)(implicit arg0: Sc[S]): STen

    Return the elementwise minimum.

  176. def min[S](implicit arg0: Sc[S]): STen
  177. def mm[S](other: STen)(implicit arg0: Sc[S]): STen

    Matrix multiplication.

    Matrix multiplication. Maps to Aten.mm.

  178. def mode[S](dim: Int, keepDim: Boolean)(implicit arg0: Sc[S]): (STen, STen)

    Reduces the given dimension with its mode.

  179. def multiply[S](other: Long)(implicit arg0: Sc[S]): STen
  180. def nanToNum[S](implicit arg0: Sc[S]): STen

    Replaces NaNs with zeros

  181. def narrow[S](dim: Int, start: STen, length: Long)(implicit arg0: Sc[S]): STen
  182. def narrow[S](dim: Int, start: Long, length: Long)(implicit arg0: Sc[S]): STen

    Returns a tensor with a subset of its elements.

    Returns a tensor with a subset of its elements.

    The returned tensor includes elements from start to start+length along the given dimension.

    No copy is made, storage is shared.

  183. def ne[S](other: Double)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise less-or-equal.

  184. def ne[S](other: STen)(implicit arg0: Sc[S]): STen

    Return a boolean tensor indicating element-wise not-equal.

  185. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  186. def neg[S](implicit arg0: Sc[S]): STen

    Returns the negation (not applicable for Boolean).

  187. def norm2[S](dim: Seq[Int], keepDim: Boolean)(implicit arg0: Sc[S]): STen

    Reduces the given dimensions with their L2 norm.

  188. def not[S](implicit arg0: Sc[S]): STen

    Returns the logical negation (applicable for Boolean).

  189. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  190. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @IntrinsicCandidate() @native()
  191. def numBytes: Long
  192. def numel: Long

    Returns the number of elements in the tensor

  193. def oneHot[S](numClasses: Int)(implicit arg0: Sc[S]): STen
  194. def options[S](implicit arg0: Sc[S]): STenOptions

    Returns the associated STenOptions

  195. def outer[S](other: STen)(implicit arg0: Sc[S]): STen
  196. def pin[S](implicit arg0: Sc[S]): STen
  197. def pinv[S](hermitian: Boolean)(implicit arg0: Sc[S]): STen
  198. def pinverse[S](rcond: Double)(implicit arg0: Sc[S]): STen
  199. def pow[S](exponent: STen)(implicit arg0: Sc[S]): STen
  200. def pow[S](exponent: Double)(implicit arg0: Sc[S]): STen
  201. def pow_(exponent: Double): Unit
  202. def productElementNames: Iterator[String]
    Definition Classes
    Product
  203. def put[S](index: STen, values: STen, accumulate: Boolean)(implicit arg0: Sc[S]): STen
  204. def qr[S](mode: String)(implicit arg0: Sc[S]): (STen, STen)
  205. def reciprocal[S](implicit arg0: Sc[S]): STen
  206. def reciprocal_(): Unit
  207. def relu[S](implicit arg0: Sc[S]): STen

    Rectified linear unit

  208. def relu_(): Unit

    In place rectified linear unit

  209. def remainder[S](other: Double)(implicit arg0: Sc[S]): STen
  210. def remainder[S](other: STen)(implicit arg0: Sc[S]): STen
  211. def repeat[S](dims: List[Long])(implicit arg0: Sc[S]): STen
  212. def repeatInterleave[S](implicit arg0: Sc[S]): STen
  213. def repeatInterleave[S](repeats: Long, dim: Int)(implicit arg0: Sc[S]): STen
  214. def repeatInterleave[S](repeats: STen, dim: Int)(implicit arg0: Sc[S]): STen
  215. def reshape[S](dims: Long*)(implicit arg0: Sc[S]): STen

    Returns a tensor with a new shape.

    Returns a tensor with a new shape. May copy.

  216. def round[S](implicit arg0: Sc[S]): STen
  217. def rowSum[S](implicit arg0: Sc[S]): STen

    Sum over the second dimension

  218. def scalarTypeByte: Byte

    Returns the byte representation of the data type

    Returns the byte representation of the data type

    The mapping is:

    • 1 for Byte
    • 2 for Short
    • 3 for Int
    • 4 for Long
    • 5 for Half
    • 6 for Float
    • 7 for Double
  219. def scatter[S](dim: Long, index: STen, source: Double)(implicit arg0: Sc[S]): STen
  220. def scatter[S](dim: Long, index: STen, source: STen)(implicit arg0: Sc[S]): STen
  221. def scatterAdd[S](dim: Long, index: STen, source: STen)(implicit arg0: Sc[S]): STen
  222. def select[S](dim: Long, index: Long)(implicit arg0: Sc[S]): STen

    Selects a scalar element or a tensor in the given dimension and index.

  223. def shape: List[Long]

    Returns the shape of the tensor

  224. def sigmoid[S](implicit arg0: Sc[S]): STen

    Sigmoid funtion

  225. def sigmoid_(): Unit

    In place sigmoid funtion

  226. def sign[S](implicit arg0: Sc[S]): STen
  227. def sign_(): Unit
  228. def sin[S](implicit arg0: Sc[S]): STen
  229. def sin_(): Unit
  230. def sizes: List[Long]

    Returns the shape of the tensor

  231. def slice[S](dim: Long, start: Long, end: Long, step: Long)(implicit arg0: Sc[S]): STen

    Returns a slice over the selected dimension

  232. def slice[S](dim: Int, start: Long, end: Long, step: Long)(implicit arg0: Sc[S]): STen

    Returns a slice over the selected dimension

  233. def slogdet[S](implicit arg0: Sc[S]): (STen, STen)
  234. def softplus[S](beta: Double, threshold: Double)(implicit arg0: Sc[S]): STen
  235. def solve[S](other: Tensor)(implicit arg0: Sc[S]): STen
  236. def sort[S](dim: Int, descending: Boolean)(implicit arg0: Sc[S]): (STen, STen)
  237. def sqrt[S](implicit arg0: Sc[S]): STen
  238. def sqrt_(): Unit
  239. def square[S](implicit arg0: Sc[S]): STen
  240. def square_(): Unit
  241. def squeeze[S](implicit arg0: Sc[S]): STen

    Removes dimensions of size=1 from the shape

  242. def squeeze[S](dim: Int)(implicit arg0: Sc[S]): STen

    Removes dimensions of size=1 from the shape

  243. def std[S](dim: Int, unbiased: Boolean, keepDim: Boolean)(implicit arg0: Sc[S]): STen
  244. def std[S](dim: Seq[Int], unbiased: Boolean, keepDim: Boolean)(implicit arg0: Sc[S]): STen

    Reduces the given dimensions with their standard deviation.

  245. def std[S](unbiased: Boolean)(implicit arg0: Sc[S]): STen
  246. def stdAndMean[S](dim: Seq[Int], unbiased: Boolean, keepDim: Boolean)(implicit arg0: Sc[S]): (STen, STen)
  247. def stdAndMean[S](unbiased: Boolean)(implicit arg0: Sc[S]): (STen, STen)
  248. def sub[S](other: Double, alpha: Double)(implicit arg0: Sc[S]): STen

    Subtracts other after multiplying with a number.

  249. def sub[S](other: STen, alpha: Double)(implicit arg0: Sc[S]): STen

    Subtracts other after multiplying with a number.

  250. def sub_l[S](other: STen)(implicit arg0: Sc[S]): STen

    Subtracts other.

  251. def sum[S](dim: Int, keepDim: Boolean)(implicit arg0: Sc[S]): STen
  252. def sum[S](dim: Seq[Int], keepDim: Boolean)(implicit arg0: Sc[S]): STen

    Reduces the given dimensions with the sum of their elements.

    Reduces the given dimensions with the sum of their elements.

    keepDim

    if true then the reduced dimensions are kept with size 1

  253. def sum[S](implicit arg0: Sc[S]): STen
  254. def svd[S](fullMatrices: Boolean = false)(implicit arg0: Sc[S]): (STen, STen, STen)

    fullMatrices

    whether to return reduced or full matrices (in case of non-square input)

    returns

    (U,S,Vh) , Vh being the conjugate transpose of V ; input = U diag(S) Vh

  255. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  256. def t[S](implicit arg0: Sc[S]): STen

    Transposes the first two dimensions.

  257. def tan[S](implicit arg0: Sc[S]): STen
  258. def tan_(): Unit
  259. def tanh[S](implicit arg0: Sc[S]): STen
  260. def tanh_(): Unit
  261. def tensordot[S](other: STen, dims: List[Int], dimsOther: List[Int])(implicit arg0: Sc[S]): STen
  262. def tensorinv[S](int: Int)(implicit arg0: Sc[S]): STen
  263. def tensorsolve[S](other: Tensor)(implicit arg0: Sc[S]): STen
  264. def to[S](options: STenOptions, nonBlocking: Boolean, copy: Boolean)(implicit arg0: Sc[S]): STen
  265. def toByteArray: Array[Byte]
  266. def toDense[S](implicit arg0: Sc[S]): STen
  267. def toDoubleArray: Array[Double]
  268. def toFloatArray: Array[Float]
  269. def toIntArray: Array[Int]
  270. def toLongArray: Array[Long]
  271. def toShortArray: Array[Short]
  272. def toString(): String
    Definition Classes
    STen → AnyRef → Any
  273. def topk[S](k: Int, dim: Int, largest: Boolean, sorted: Boolean)(implicit arg0: Sc[S]): (STen, STen)

    Selects the top k elements along the given dimension

    Selects the top k elements along the given dimension

    k

    How many elements to select

    dim

    which dimension to select in

    largest

    if true, then the highest k element is selected

    sorted

    if true, the selected elements are further sorted

    returns

    a pair of (value,index) tensors where value holds the selected elements and index holds the indices of the selected elements

  274. def trace[S](implicit arg0: Sc[S]): STen
  275. def transpose[S](dim1: Int, dim2: Int)(implicit arg0: Sc[S]): STen

    Transposes the given dimensions.

  276. def tril[S](diagonal: Int = 0)(implicit arg0: Sc[S]): STen
  277. def tril_(diagonal: Int = 0): Unit
  278. def unbroadcast[S](sizes: Seq[Long])(implicit arg0: Sc[S]): STen
  279. def unique[S](dim: Int, sorted: Boolean, returnInverse: Boolean, returnCounts: Boolean)(implicit arg0: Sc[S]): (STen, STen, STen)
  280. def unique[S](sorted: Boolean, returnInverse: Boolean, returnCounts: Boolean)(implicit arg0: Sc[S]): (STen, STen, STen)
  281. def unique[S](sorted: Boolean, returnInverse: Boolean)(implicit arg0: Sc[S]): (STen, STen)
  282. def uniqueConsecutive[S](dim: Int, returnInverse: Boolean = false, returnCounts: Boolean = false)(implicit arg0: Sc[S]): (STen, STen, STen)
  283. def unsqueeze[S](dim: Int)(implicit arg0: Sc[S]): STen

    Inserts a dimension of size=1 in the given position

  284. val value: Tensor
  285. def values[S](implicit arg0: Sc[S]): STen

    Returns values.

    Returns values. Only for sparse tensors

  286. def varAndMean[S](dim: Seq[Int], unbiased: Boolean, keepDim: Boolean)(implicit arg0: Sc[S]): (STen, STen)
  287. def varAndMean[S](unbiased: Boolean)(implicit arg0: Sc[S]): (STen, STen)
  288. def variance[S](dim: Int, unbiased: Boolean, keepDim: Boolean)(implicit arg0: Sc[S]): STen
  289. def variance[S](dim: Seq[Int], unbiased: Boolean, keepDim: Boolean)(implicit arg0: Sc[S]): STen

    Reduces the given dimensions with their variance.

  290. def variance[S](unbiased: Boolean)(implicit arg0: Sc[S]): STen
  291. def view[S](dims: Long*)(implicit arg0: Sc[S]): STen

    Returns a tensor with a new shape.

    Returns a tensor with a new shape.

    No data is copied. The new shape must be compatible with the number of elements and the stride of the tensor.

  292. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  293. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  294. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  295. def where[S](implicit arg0: Sc[S]): List[STen]

    Returns the indices of non-zero values

  296. def zero_(): Unit

    In place fills with zeros.

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from Serializable

Inherited from Product

Inherited from Equals

Inherited from AnyRef

Inherited from Any

Ungrouped