TensorD

scalation.mathstat.TensorD
See theTensorD companion class
object TensorD

The TensorD companion object provides factory methods for the TensorD class.

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
TensorD.type

Members list

Value members

Concrete methods

def apply(n: (Int, Int, Int), x: Double*): TensorD

Build a tensor from the scaler argument list x.

Build a tensor from the scaler argument list x.

Value parameters

n1

the first dimension

n2

the second dimension

n3

the third dimension

x

the list/vararg of scacollection.immutable.IndexedSeq [MatrixD]lars

Attributes

def apply(n: Int, vs: VectorD*): TensorD

Build a tensor from the vector argument list x.

Build a tensor from the vector argument list x.

Value parameters

n

the first dimension

vs

the list/vararg of vectors

Attributes

def apply(n: Int, vs: IndexedSeq[VectorD]): TensorD

Build a tensor from the vector argument list x.

Build a tensor from the vector argument list x.

Value parameters

n

the first dimension

vs

the indexed sequence of vectors

Attributes

def apply(n: Int, vs: IndexedSeq[VectorD]): TensorD

Build a tensor from the vector argument list x.

Build a tensor from the vector argument list x.

Value parameters

n

the first dimension

vs

the indexed sequence of vectors

Attributes

def apply(vs: MatrixD*): TensorD

Create a tensor from a variable argument list of matrices (row-wise). Use transpose to make it column-wise.

Create a tensor from a variable argument list of matrices (row-wise). Use transpose to make it column-wise.

Value parameters

vs

the vararg list of matrices

Attributes

def apply(vs: IndexedSeq[MatrixD]): TensorD

Create a tensor from an mutable IndexedSeq of matrices (row-wise). Use transpose to make it column-wise.

Create a tensor from an mutable IndexedSeq of matrices (row-wise). Use transpose to make it column-wise.

Value parameters

vs

the indexed sequence of matrices

Attributes

def apply(vs: IndexedSeq[MatrixD]): TensorD

Create a tensor from an immutable IndexedSeq of matrices (row-wise), as produce by for yield. Use transpose to make it column-wise.

Create a tensor from an immutable IndexedSeq of matrices (row-wise), as produce by for yield. Use transpose to make it column-wise.

Value parameters

vs

the indexed sequence of matrices

Attributes

def broadcastMatrix(m: MatrixD, shape: Option[(Int, Int, Int)] = ...): TensorD

Broadcast a MatrixD into a 3D tensor (TensorD) in batch‑first layout.

Broadcast a MatrixD into a 3D tensor (TensorD) in batch‑first layout.

  • Base tensor is created with batch=1, rows=m.dim, cols=m.dim2
  • We explicitly fill base(0,i,j) = m(i,j) so there’s n
  • If you request a larger batch, we replicate that slice across batch

Attributes

def broadcastShapes(aShape: List[Int], bShape: List[Int]): List[Int]

Compute the broadcasted shape for two 3D shapes aShape and bShape.

Compute the broadcasted shape for two 3D shapes aShape and bShape.

  • If one dimension is 1 and the other is R, pick R.
  • If both are the same, pick that value.
  • Otherwise, throw an error for mismatched dimensions.

Attributes

def broadcastTo(src: TensorD, newShape: List[Int]): TensorD

Expand a TensorD 'src' to 'newShape' if needed. If src.shape == newShape, just return src. Otherwise replicate data along any dimension that was 1 in src.shape but is >1 in newShape.

Expand a TensorD 'src' to 'newShape' if needed. If src.shape == newShape, just return src. Otherwise replicate data along any dimension that was 1 in src.shape but is >1 in newShape.

Attributes

def broadcastVector(v: VectorD, axis: Int = ..., shape: Option[(Int, Int, Int)] = ...): TensorD

Broadcast a VectorD into a 3D tensor (TensorD), allowing partial broadcasting. The default shape is determined by the axis parameter:

Broadcast a VectorD into a 3D tensor (TensorD), allowing partial broadcasting. The default shape is determined by the axis parameter:

  • If axis == 0, the default is a column vector: (v.dim, 1, 1)
  • If axis == 1, the default is a row vector: (1, v.dim, 1)
  • If axis == 2, the default is a sheet vector: (1, 1, v.dim) If a shape is provided, a base tensor is created with the default shape and then expanded to the given shape using broadcastTo.

Attributes

def concat(xs: Seq[TensorD], axis: Int): TensorD

Concatenate a sequence of 3D tensors along the specified axis (0, 1, or 2).

Concatenate a sequence of 3D tensors along the specified axis (0, 1, or 2).

Value parameters

axis

dimension along which to concatenate (0, 1, or 2)

xs

sequence of TensorD to concatenate

Attributes

def diag(s: Double, size: Int): TensorD
def eLU_(yp: TensorD, alpha: Double): TensorD
def fill(dim: Int, dim2: Int, dim3: Int, value: Double): TensorD

Create a tensor of dimensions dim by dim2 by dim3 where all elements equal to the given value.

Create a tensor of dimensions dim by dim2 by dim3 where all elements equal to the given value.

Value parameters

dim

the row dimension

dim2

the sheet dimension

value

the given value to assign to all elements

Attributes

def fromMatrix(m: MatrixD, shape: Option[(Int, Int, Int)] = ...): TensorD

Create a TensorD from a MatrixD with default shape (1, rows, cols).

Create a TensorD from a MatrixD with default shape (1, rows, cols).

Value parameters

m

the matrix to convert

Attributes

Returns

A TensorD of shape (1, rows, cols)

def fromVector(v: VectorD, axis: Int = ...): TensorD

Create a TensorD from a VectorD with default shape (length, 1, 1).

Create a TensorD from a VectorD with default shape (length, 1, 1).

Value parameters

v

the vector to convert

Attributes

Returns

A TensorD of shape (length, 1, 1)

def fullLike(t: TensorD, value: Double): TensorD
def geLU_(yp: TensorD): TensorD
def id_(yp: TensorD): TensorD
def logistic_(yp: TensorD, a: Double, b: Double, c: Double): TensorD
def logit_(yp: TensorD): TensorD
def lreLU_(yp: TensorD, alpha: Double): TensorD
def max(x: TensorD, y: TensorD): TensorD
def meanAlongAxis(x: TensorD, axis: Int): TensorD
def min(x: TensorD, y: TensorD): TensorD
def ones(dims: (Int, Int, Int)): TensorD

Create a new tensor filled with ones, based on the given dimensions tuple.

Create a new tensor filled with ones, based on the given dimensions tuple.

Value parameters

dims

a tuple representing the shape of the tensor (dim, dim2, dim3).

Attributes

Returns

a new tensor filled with ones.

def onesLike(tensor: TensorD): TensorD

Create a new tensor filled with ones, having the same dimensions as the given tensor.

Create a new tensor filled with ones, having the same dimensions as the given tensor.

Value parameters

tensor

the tensor to mimic in dimensions.

Attributes

Returns

a new tensor filled with ones.

def reLU_(yp: TensorD): TensorD
def scalar(s: Double): TensorD
def standardize(x: TensorD, axis: Int): TensorD
def stdAlongAxis(x: TensorD, axis: Int): TensorD
def sumAlongAxis(tensor: TensorD, axis: Int): TensorD

Sum all elements of the tensor along the specified axis.

Sum all elements of the tensor along the specified axis.

Value parameters

axis

the axis along which to sum (0 = rows, 1 = columns, 2 = sheets).

tensor

the tensor to sum over.

Attributes

Returns

A new TensorD with the reduced dimension.

def tanh_(yp: TensorD): TensorD
def varianceAlongAxis(x: TensorD, axis: Int): TensorD
def zerosLike(tensor: TensorD): TensorD

Create a new tensor filled with zeros, having the same dimensions as the given tensor.

Create a new tensor filled with zeros, having the same dimensions as the given tensor.

Value parameters

tensor

the tensor to mimic in dimensions.

Attributes

Returns

A new tensor filled with zeros.