Multiply a Tensor by another one, return the result in new allocated memory.
Multiply a Tensor by another one, return the result in new allocated memory. The number of elements in the Tensors must match, but the sizes do not matter. The size of the returned Tensor will be the size of the first Tensor
multiply all elements of this with value not in place.
multiply all elements of this with value not in place. It will allocate new memory.
Add a Tensor to another one, return the result in new allocated memory.
Add a Tensor to another one, return the result in new allocated memory. The number of elements in the Tensors must match, but the sizes do not matter. The size of the returned Tensor will be the size of the first Tensor
Add all elements of this with value not in place.
Add all elements of this with value not in place. It will allocate new memory.
Subtract a Tensor from another one, return the result in new allocated memory.
Subtract a Tensor from another one, return the result in new allocated memory. The number of elements in the Tensors must match, but the sizes do not matter. The size of the returned Tensor will be the size of the first Tensor
subtract all elements of this with the value not in place.
subtract all elements of this with the value not in place. It will allocate new memory.
Divide a Tensor by another one, return the result in new allocated memory.
Divide a Tensor by another one, return the result in new allocated memory. The number of elements in the Tensors must match, but the sizes do not matter. The size of the returned Tensor will be the size of the first Tensor
divide all elements of this with value not in place.
divide all elements of this with value not in place. It will allocate new memory.
replaces all elements in-place with the absolute values of the elements of this.
replaces all elements in-place with the absolute values of the elements of this.
x.
z.
z.add(x, value, y) puts the result of x + value * y in z.
accumulates all elements of y into this
accumulates all elements of y into this
other tensor
current tensor
x.
x.add(value,y) multiply-accumulates values of y into x.
scalar
other tensor
current tensor
view this.
view this.tensor and add a Singleton Dimension to dim
dimension
source tensor
the specific dimension, default is 1
this
Performs the element-wise division of tensor1 by tensor2, multiply the result by the scalar value and add it to x.
Performs the element-wise division of tensor1 by tensor2, multiply the result by the scalar value and add it to x. The number of elements must match, but sizes do not matter.
Performs the element-wise multiplication of tensor1 by tensor2, multiply the result by the scalar value (1 if not present) and add it to x.
Performs the element-wise multiplication of tensor1 by tensor2, multiply the result by the scalar value (1 if not present) and add it to x. The number of elements must match, but sizes do not matter.
res = v1 * res + v2 * mat1*mat2
res = v1 * res + v2 * mat1*mat2
res = res + v2 * mat1 * mat2
res = res + v2 * mat1 * mat2
res = res + mat1 * mat2
res = res + mat1 * mat2
res = M + (mat1*mat2)
res = M + (mat1*mat2)
Performs a matrix-matrix multiplication between mat1 (2D tensor) and mat2 (2D tensor).
Performs a matrix-matrix multiplication between mat1 (2D tensor) and mat2 (2D tensor). Optional values v1 and v2 are scalars that multiply M and mat1 * mat2 respectively. Optional value beta is a scalar that scales the result tensor, before accumulating the result into the tensor. Defaults to 1.0. If mat1 is a n x m matrix, mat2 a m x p matrix, M must be a n x p matrix.
res = (v1 * M) + (v2 * mat1*mat2)
res = res + alpha * (mat * vec2)
res = res + alpha * (mat * vec2)
res = beta * res + alpha * (mat * vec2)
res = beta * res + alpha * (mat * vec2)
Performs a matrix-vector multiplication between mat (2D Tensor) and vec2 (1D Tensor) and add it to vec1.
Performs a matrix-vector multiplication between mat (2D Tensor) and vec2 (1D Tensor) and add it to vec1. Optional values v1 and v2 are scalars that multiply vec1 and vec2 respectively.
In other words, res = (beta * vec1) + alpha * (mat * vec2)
Sizes must respect the matrix-multiplication operation: if mat is a n × m matrix, vec2 must be vector of size m and vec1 must be a vector of size n.
Performs the outer-product between vec1 (1D Tensor) and vec2 (1D Tensor).
Performs the outer-product between vec1 (1D Tensor) and vec2 (1D Tensor). Optional values v1 and v2 are scalars that multiply mat and vec1 [out] vec2 respectively. In other words,res_ij = (v1 * mat_ij) + (v2 * vec1_i * vec2_j)
Performs the outer-product between vec1 (1D tensor) and vec2 (1D tensor).
Performs the outer-product between vec1 (1D tensor) and vec2 (1D tensor). Optional values v1 and v2 are scalars that multiply mat and vec1 [out] vec2 respectively. In other words, res_ij = (v1 * mat_ij) + (v2 * vec1_i * vec2_j)
Subset the tensor by apply the elements of the given table to the corresponding dimension of the tensor.
Subset the tensor by apply the elements of the given table to the corresponding dimension of the tensor. The elements of the given table can be an Int or another Table. An Int means select on current dimension; A table means narrow on current dimension, the table should have two elements, of which the first is the start index and the second is the end index. An empty table is equal to Table(1, size_of_current_dimension) If the table length is less than the tensor dimension, each missing dimension is token up by an empty table
The table length should be less than or equal to the tensor dimensions
narrow
select
Query the value on a given index.
Query the value on a given index. Tensor should not be empty
the indexes length should be same as the tensor dimension length and each value count from 1
the value on the given index
Query tensor on a given index.
Query tensor on a given index. Tensor should not be empty
count from 1
Apply a function to each element of the tensor and modified it value if it return a double
Apply a function to each element of the tensor and modified it value if it return a double
applied function
current tensor
Apply a function to each element of the tensor t
and set each value to self
Apply a function to each element of the tensor t
and set each value to self
tensor to be modified
applied function
current tensor
res_i = res_i + (alpha * batch1_i * batch2_i)
res_i = res_i + (alpha * batch1_i * batch2_i)
res_i = (beta * res_i) + (alpha * batch1_i * batch2_i)
res_i = (beta * res_i) + (alpha * batch1_i * batch2_i)
Perform a batch matrix matrix multiplication of matrices and stored in batch1 and batch2 with batch add.
Perform a batch matrix matrix multiplication of matrices and stored in batch1 and batch2 with batch add. batch1 and batch2 must be 3D Tensors each containing the same number of matrices. If batch1 is a b × n × m Tensor, batch2 a b × m × p Tensor, res will be a b × n × p Tensor.
In other words, res_i = (beta * M_i) + (alpha * batch1_i * batch2_i)
Fill with random value(bernoulli distribution).
Fill with random value(bernoulli distribution). It will change the value of the current tensor and return itself
current tensor
res_i = res_i + batch1_i * batch2_i
res_i = res_i + batch1_i * batch2_i
Cast the currenct tensor to a tensor with tensor numeric type D
and set cast value to castTensor
Cast the currenct tensor to a tensor with tensor numeric type D
and set cast value to castTensor
new numeric type
the cast value set to this tensor
return castTensort
Element-wise divide z.
Element-wise divide z.cdiv(x, y) means z = x / y
tensor
tensor
current tensor
Element-wise divide x.
Element-wise divide x.cdiv(y) all elements of x divide all elements of y. x = x / y
tensor
current tensor
stores the element-wise maximum of x and y in z.
stores the element-wise maximum of x and y in z. z.cmax(x, y) means z = max(x, y)
tensor
tensor
stores the element-wise maximum of x and y in x.
stores the element-wise maximum of x and y in x. x.cmax(y) = max(x, y)
tensor
current tensor
For each elements of the tensor, performs the max operation compared with the given value vector.
For each elements of the tensor, performs the max operation compared with the given value vector.
Element-wise multiply z.
Element-wise multiply z.cmul(x, y) equals z = x * y
tensor
tensor
current tensor
Element-wise multiply x.
Element-wise multiply x.cmul(y) multiplies all elements of x with corresponding elements of y. x = x * y
tensor
current tensor
Get a contiguous tensor from current tensor
Get a contiguous tensor from current tensor
the current tensor if it's contiguous; or a new contiguous tensor with separated storage
This function computes 2 dimensional convolution of a single image with a single kernel (2D output).
This function computes 2 dimensional convolution of a single image with a single kernel (2D output). the dimensions of input and kernel need to be 2, and Input image needs to be bigger than kernel. The last argument controls if the convolution is a full ('F') or valid ('V') convolution. The default is valid convolution.
full ('F') or valid ('V') convolution.
Copy the value of the given tensor to the current.
Copy the value of the given tensor to the current. They should have same size. It will use the old storage
source tensor
current tensor
Compare and print differences between two tensors
Compare and print differences between two tensors
true if there's difference, vice versa
A shortcut of nDimension()
A shortcut of nDimension()
nDimension()
Performs the p-norm distance calculation between two tensors
Performs the p-norm distance calculation between two tensors
the secode Tensor
the norm of distance
Element-wise divide x.
Element-wise divide x.div(y) all elements of x divide all elements of y. x = x / y
tensor
current tensor
divide all elements of this with value in-place.
Performs the dot product.
Performs the dot product. The number of elements must match: both Tensors are seen as a 1D vector.
return a new empty tensor of the same type
return a new empty tensor of the same type
new tensor
Implements == operator comparing each element in x with y
Implements == operator comparing each element in x with y
current tensor reference
Expanding a tensor allocates new memory, tensor where singleton dimensions can be expanded to multiple ones by setting the stride to 0.
Expanding a tensor allocates new memory, tensor where singleton dimensions can be expanded to multiple ones by setting the stride to 0. Any dimension that has size 1 can be expanded to arbitrary value with new memory allocation. Attempting to expand along a dimension that does not have size 1 will result in an error.
the size that tensor will expend to
This is equivalent to this.
This is equivalent to this.expand(template.size())
the given tensor
Fill with a given value.
Fill with a given value. It will change the value of the current tensor and return itself
value to fill the tensor
current tensor
Replaces all elements in-place with the floor result of elements
Replaces all elements in-place with the floor result of elements
Populate the given tensor with the floor result of elements
Fill with a given value.
Fill with a given value. It will change the value of the current tensor and return itself
Note the value should be an instance of T
value to fill the tensor
current tensor
change this tensor with values from the original tensor by gathering a number of values from each "row", where the rows are along the dimension dim.
change this tensor with values from the original tensor by gathering a number of values from each "row", where the rows are along the dimension dim.
this
Implements >= operator comparing each element in x with value
Implements >= operator comparing each element in x with value
Return tensor numeric
Return tensor numeric
Return tensor type
Return tensor type
Dense / Quant
return the tensor datatype( DoubleType or FloatType)
return the tensor datatype( DoubleType or FloatType)
Implements > operator comparing each element in x with y
Implements > operator comparing each element in x with y
current tensor reference
Accumulate the elements of tensor into the original tensor by adding to the indices in the order given in index.
Accumulate the elements of tensor into the original tensor by adding to the indices in the order given in index. The shape of tensor must exactly match the elements indexed or an error will be thrown.
Accumulate the elements of tensor into the original tensor by adding to the indices in the order given in index.
Accumulate the elements of tensor into the original tensor by adding to the indices in the order given in index. The shape of tensor must exactly match the elements indexed or an error will be thrown.
Check if the tensor is contiguous on the storage
Check if the tensor is contiguous on the storage
true if it's contiguous
whether this tensor is an empty tensor. Note that nDimension == 0 is not sufficient to determine a tensor is empty, because a scalar tensor's nDimension is also 0.
Check if the size is same with the give tensor
Check if the size is same with the give tensor
tensor to be compared
true if they have same size
whether this tensor is a scalar
Implements <= operator comparing each element in x with y
Implements <= operator comparing each element in x with y
current tensor reference
Replaces all elements in-place with the elements of lnx
Replaces all elements in-place with the elements of lnx
current tensor reference
Implements < operator comparing each element in x with y
Implements < operator comparing each element in x with y
current tensor reference
Map value of another tensor to corresponding value of current tensor and apply function on the two value and change the value of the current tensor The another tensor should has the same size of the current tensor
Map value of another tensor to corresponding value of current tensor and apply function on the two value and change the value of the current tensor The another tensor should has the same size of the current tensor
another tensor
applied function
current tensor
Copies the elements of tensor into mask locations of itself.
Copies the elements of tensor into mask locations of itself.
current tensor reference
Fills the masked elements of itself with value val
Fills the masked elements of itself with value val
current tensor reference
Returns a new Tensor which contains all elements aligned to a 1 in the corresponding mask.
Returns a new Tensor which contains all elements aligned to a 1 in the corresponding mask.
current tensor reference
performs the max operation over the dimension n
performs the max operation over the dimension n
returns the single biggest element of x
performs the mean operation over the dimension dim.
returns the mean of all elements of this.
performs the min operation over the dimension n
performs the min operation over the dimension n
returns the single minimum element of x
res = mat1*mat2
res = mat1*mat2
put the result of x * value in current tensor
multiply all elements of this with value in-place.
res = res + (mat * vec2)
res = res + (mat * vec2)
Dimension number of the tensor.
Dimension number of the tensor. For empty tensor, its dimension number is 0
dimension number
Element number
Element number
element number
Get a subset of the tensor on dim-th dimension.
Get a subset of the tensor on dim-th dimension. The offset is given by index, and length is given by size. The important difference with select is that it will not reduce the dimension number. For Instance tensor = 1 2 3 4 5 6 tensor.narrow(1, 1, 1) is [1 2 3] tensor.narrow(2, 2, 2) is 2 3 5 6
Computes numerical negative value element-wise.
Computes numerical negative value element-wise. y = -x
this tensor
returns the sum of the n-norms on the Tensor x
returns the p-norms of the Tensor x computed over the dimension dim.
returns the p-norms of the Tensor x computed over the dimension dim.
result buffer
Replaces all elements in-place with the elements of x to the power of n
Replaces all elements in-place with the elements of x to the power of n
current tensor reference
returns the product of the elements of this
Fill with random value(uniform distribution between [lowerBound, upperBound]) It will change the value of the current tensor and return itself
Fill with random value(uniform distribution between [lowerBound, upperBound]) It will change the value of the current tensor and return itself
current tensor
Fill with random value(uniform distribution).
Fill with random value(uniform distribution). It will change the value of the current tensor and return itself
current tensor
Fill with random value(normal gaussian distribution with the specified mean and stdv).
Fill with random value(normal gaussian distribution with the specified mean and stdv). It will change the value of the current tensor and return itself
current tensor
Fill with random value(normal gaussian distribution).
Fill with random value(normal gaussian distribution). It will change the value of the current tensor and return itself
current tensor
resize this tensor size to floor((xmax - xmin) / step) + 1 and set values from xmin to xmax with step (default to 1).
resize this tensor size to floor((xmax - xmin) / step) + 1 and set values from xmin to xmax with step (default to 1).
this tensor
Repeating a tensor allocates new memory, unless result is provided, in which case its memory is resized.
Repeating a tensor allocates new memory, unless result is provided, in which case its memory is resized. sizes specify the number of times the tensor is repeated in each dimension.
create a new tensor without any change of the tensor
create a new tensor without any change of the tensor
the size of the new Tensor
Resize the current tensor to the give shape
Resize the current tensor to the give shape
Array describe the size
Array describe the jumps
Resize the current tensor to the same size of the given tensor.
Resize the current tensor to the same size of the given tensor. It will still use the same storage if the storage is sufficient for the new size
target tensor
current tensor
Save the tensor to given path
Save the tensor to given path
Writes all values from tensor src into this tensor at the specified indices
Writes all values from tensor src into this tensor at the specified indices
this
Remove the dim-th dimension and return the subset part.
Remove the dim-th dimension and return the subset part. For instance tensor = 1 2 3 4 5 6 tensor.select(1, 1) is [1 2 3] tensor.select(1, 2) is [4 5 6] tensor.select(2, 3) is [3 6]
Shrunk the size of the storage to 0, and also the tensor size
Shrunk the size of the storage to 0, and also the tensor size
The Tensor is now going to "view" the given storage, starting at position storageOffset (>=1) with the given dimension sizes and the optional given strides.
The Tensor is now going to "view" the given storage, starting at position storageOffset (>=1) with the given dimension sizes and the optional given strides. As the result, any modification in the elements of the Storage will have an impact on the elements of the Tensor, and vice-versa. This is an efficient method, as there is no memory copy!
If only storage is provided, the whole storage will be viewed as a 1D Tensor.
current tensor
The Tensor is now going to "view" the same storage as the given tensor.
The Tensor is now going to "view" the same storage as the given tensor. As the result, any modification in the elements of the Tensor will have an impact on the elements of the given tensor, and vice-versa. This is an efficient method, as there is no memory copy!
the given tensor
current tensor
Write the value on a given position.
Write the value on a given position. The number of parameters should be equal to the dimension number of the tensor.
the written value
Set value for a scalar tensor
Set value for a scalar tensor
the written value
returns a new Tensor with the sign (+/- 1 or 0) of the elements of x.
returns a new Tensor with the sign (+/- 1 or 0) of the elements of x.
size of the tensor on the given dimension
size of the tensor on the given dimension
dimension, count from 1
size
Size of tensor.
Size of tensor. Return an array of which each value represents the size on the dimension(i + 1), i is the index of the corresponding value. It will generate a new array each time method is invoked.
size array
spilt one tensor into multi tensor along the dim
dimension
spilt one tensor into multi tensor along the dim
dimension
the specific dimension
Splits current tensor along dimension dim into a result table of Tensors of size size (a number) or less (in the case of the last Tensor).
Splits current tensor along dimension dim into a result table of Tensors of size size (a number) or less (in the case of the last Tensor). The sizes of the non-dim dimensions remain unchanged. Internally, a series of narrows are performed along dimensions dim. Argument dim defaults to 1.
replaces all elements in-place with the square root of the elements of this.
replaces all elements in-place with the square root of the elements of this.
Removes given dimensions of the tensor if it's singleton
Removes given dimensions of the tensor if it's singleton
current tensor
Removes all singleton dimensions of the tensor
Removes all singleton dimensions of the tensor
current tensor
Create a new tensor that removes all singleton dimensions of the tensor
Create a new tensor that removes all singleton dimensions of the tensor
create a new tensor
Get the storage
Get the storage
storage
tensor offset on the storage
tensor offset on the storage
storage offset, count from 1
Jumps between elements on the given dimension in the storage.
Jumps between elements on the given dimension in the storage.
dimension, count from 1
jump
Jumps between elements on the each dimension in the storage.
Jumps between elements on the each dimension in the storage. It will generate a new array each time method is invoked.
strides array
subtracts all elements of y from this
subtracts all elements of y from this
other tensor
current tensor
performs the sum operation over the dimension dim
returns the sum of the elements of this
Shortcut of transpose(1, 2) for 2D tensor
Shortcut of transpose(1, 2) for 2D tensor
transpose()
replaces all elements in-place with the tanh root of the elements of this.
replaces all elements in-place with the tanh root of the elements of this.
convert the tensor to BreezeMatrix, the dimension of the tensor need to be 2.
convert the tensor to BreezeMatrix, the dimension of the tensor need to be 2.
BrzDenseMatrix
convert the tensor to BreezeVector, the dimension of the tensor need to be 1.
convert the tensor to BreezeVector, the dimension of the tensor need to be 1.
BrzDenseVector
convert the tensor to MLlibMatrix, the dimension of the tensor need to be 2, and tensor need to be continuous.
convert the tensor to MLlibMatrix, the dimension of the tensor need to be 2, and tensor need to be continuous.
Matrix
convert the tensor to MLlibVector, the dimension of the tensor need to be 1, and tensor need to be continuous.
convert the tensor to MLlibVector, the dimension of the tensor need to be 1, and tensor need to be continuous.
Vector
Get the top k smallest values and their indices.
Get the top k smallest values and their indices.
dimension, default is the last dimension
sort order, set it to true if you want to get the smallest top k values
result buffer
indices buffer
* Create a new tensor which exchanges the given dimensions of the current tensor
* Create a new tensor which exchanges the given dimensions of the current tensor
dimension to be exchanged, count from one
dimension to be exchanged, count from one
new tensor
Returns a tensor which contains all slices of size @param size in the dimension @param dim.
Returns a tensor which contains all slices of size @param size in the dimension @param dim. Step between two slices is given by @param step.
Step between two slices
new tensor
return pseudo-random numbers, require 0<=args.
return pseudo-random numbers, require 0<=args.length<=2 if args.length = 0, return [0, 1) if args.length = 1, return [1, args(0)] or [args(0), 1] if args.length = 2, return [args(0), args(1)]
Update the value meeting the filter criteria with the give value
Update the value meeting the filter criteria with the give value
filter
value to update
Copy the given tensor values to the selected subset of the current tensor Each element of the given table can be an Int or another Table.
Copy the given tensor values to the selected subset of the current tensor Each element of the given table can be an Int or another Table. An Int means select on current dimension; A table means narrow on current dimension, the table should has two elements, of which the first is start index and the second is the end index. An empty table is equal to Table(1, size_of_current_dimension). If the table's length is smaller than the tensor's dimension, the missing dimension is applied by an empty table.
subset table
tensor to copy
Fill the select subset of the current tensor with the given value.
Fill the select subset of the current tensor with the given value. The element of the given table can be an Int or another Table. An Int means select on current dimension; A table means narrow on the current dimension, the table should has two elements, of which the first is the start index and the second is the end index. An empty table is equal to Table(1, size_of_current_dimension) If the table length is less than the tensor dimension, each missing dimension is applied by an empty table
subset table
value to write
Write the value to the positions indexed by the given index array
Write the value to the positions indexed by the given index array
index array. It should has same length with the tensor dimension
value to write
Copy the give tensor value to the select subset of the current tensor by the given index.
Copy the give tensor value to the select subset of the current tensor by the given index. The subset should have the same size of the given tensor
index
tensor to write
For tensor(i) = value.
For tensor(i) = value. If tensor(i) is another tensor, it will fill the selected subset by the given value
index
value to write
the value of a scalar. Requires the tensor to be a scalar.
Query the value on a given position.
Query the value on a given position. The number of parameters should be equal to the dimension number of the tensor. Tensor should not be empty.
the value on a given position
This function operates with same options and input/output configurations as conv2, but performs cross-correlation of the input with the kernel k.
This function operates with same options and input/output configurations as conv2, but performs cross-correlation of the input with the kernel k.
full ('F') or valid ('V') convolution.
Fill with zero.
Fill with zero. It will change the value of the current tensor and return itself
current tensor
Zip values of two other tensors with applying the function func
on
each two values element-wisely and assign the result value to the
current tensor
Zip values of two other tensors with applying the function func
on
each two values element-wisely and assign the result value to the
current tensor
The two given tensors should has the same size of the current tensor
numeric type of tensor 1
numeric type of tensor 2
tensor 1
tensor 2
zip with the function
self
Compare with other tensor.
Compare with other tensor. The shape of the other tensor must be same with this tensor. If element wise difference is less than delta, return true.
Get a new tensor with same value and different storage
Get a new tensor with same value and different storage
new tensor
Return false because it's not a Table
Return true because it's a Tensor implemented from Activity
Return a new tensor with specified sizes.
Return a new tensor with specified sizes. The input tensor must be contiguous, and the elements number in the given sizes must be equal to the current tensor
new tensor
It is the class for handling numeric data.
should be Double or Float