Tensor Type

Represents a multi-dimensional data type containing elements of a single data type.

Example

A tensor can be constructed from a list or sequence using dsharp.tensor

    let t = dsharp.tensor([[1.; -1.]; [1.; -1.]])

Instance members

Instance member Description

this.GetSlice

Full Usage: this.GetSlice

Parameters:
    bounds : int[,]

Returns: Tensor
bounds : int[,]
Returns: Tensor

this.[index]

Full Usage: this.[index]

Parameters:
    index : int[]

Returns: Tensor

Get the item at the given index as a scalar tensor.

index : int[]
Returns: Tensor

this.abs ()

Full Usage: this.abs ()

Returns: Tensor

Computes the element-wise absolute value of the given input tensor.

Returns: Tensor

this.acos ()

Full Usage: this.acos ()

Returns: Tensor

Returns a new tensor with the arccosine of the elements of input.

Returns: Tensor

this.add b

Full Usage: this.add b

Parameters:
Returns: Tensor

Each element of the object tensor is added to the scalar b. The resulting tensor is returned.

b : scalar
Returns: Tensor

this.add b

Full Usage: this.add b

Parameters:
Returns: Tensor

Each element of the object tensor is added to each corresponding element of the tensor b. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

b : Tensor
Returns: Tensor

this.addSlice (location, b)

Full Usage: this.addSlice (location, b)

Parameters:
    location : seq<int>
    b : Tensor

Returns: Tensor

Add the given tensor as a slice at the given location.

location : seq<int>
b : Tensor
Returns: Tensor

this.allclose (tensor, ?relativeTolerance, ?absoluteTolerance)

Full Usage: this.allclose (tensor, ?relativeTolerance, ?absoluteTolerance)

Parameters:
    tensor : Tensor
    ?relativeTolerance : float
    ?absoluteTolerance : float

Returns: bool

Indicates if two tensors have the same shape and all corresponding elements are equal within the given tolerances.

tensor : Tensor
?relativeTolerance : float
?absoluteTolerance : float
Returns: bool

this.ancestors ()

Full Usage: this.ancestors ()

Returns: Tensor list * string

A debugging routine that returns the ancestors of a tensor involved in reverse-mode automatic differentiation

Returns: Tensor list * string

this.arangeLike (endVal, ?startVal, ?step, ?device, ?dtype, ?backend)

Full Usage: this.arangeLike (endVal, ?startVal, ?step, ?device, ?dtype, ?backend)

Parameters:
    endVal : int
    ?startVal : int
    ?step : int
    ?device : Device
    ?dtype : Dtype
    ?backend : Backend

Returns: Tensor

Returns a tensor in the manner of for the given element type and configuration, defaulting to the element type and configuration of the input tensor.

endVal : int
?startVal : int
?step : int
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.arangeLike (endVal, ?startVal, ?step, ?device, ?dtype, ?backend)

Full Usage: this.arangeLike (endVal, ?startVal, ?step, ?device, ?dtype, ?backend)

Parameters:
    endVal : float
    ?startVal : float
    ?step : float
    ?device : Device
    ?dtype : Dtype
    ?backend : Backend

Returns: Tensor

Returns a tensor in the manner of for the given element type and configuration, defaulting to the element type and configuration of the input tensor.

endVal : float
?startVal : float
?step : float
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.argmax (dim, ?keepDim)

Full Usage: this.argmax (dim, ?keepDim)

Parameters:
    dim : int
    ?keepDim : bool

Returns: Tensor

Returns the indexes of maximum values of the primal of the tensor, reducing the given dimension.

The resulting tensor does not participate in reverse or forward differentiation. It can be used as input to another operation such as dsharp.gather.

dim : int
?keepDim : bool
Returns: Tensor

this.argmax ()

Full Usage: this.argmax ()

Returns: int[]

Gets the index of a maximum value in the tensor.

Returns: int[]

this.argmin (dim, ?keepDim)

Full Usage: this.argmin (dim, ?keepDim)

Parameters:
    dim : int
    ?keepDim : bool

Returns: Tensor

Returns the indexes of minimum values of the primal of the tensor, reducing the given dimension.

The resulting tensor does not participate in reverse or forward differentiation. It can be used as input to another operation such as dsharp.gather.

dim : int
?keepDim : bool
Returns: Tensor

this.argmin ()

Full Usage: this.argmin ()

Returns: int[]

Gets the index of a minimum value in the tensor.

Returns: int[]

this.asin ()

Full Usage: this.asin ()

Returns: Tensor

Returns a new tensor with the arcsine of the elements of input.

Returns: Tensor

this.atan ()

Full Usage: this.atan ()

Returns: Tensor

Returns a new tensor with the arctangent of the elements of input.

Returns: Tensor

this.backend

Full Usage: this.backend

Returns: Backend

Gets the backend of the tensor

Returns: Backend

this.backward value

Full Usage: this.backward value

Parameters:
Modifiers: inline

See reverse

value : Tensor

this.bceLoss (target, ?weight, ?reduction)

Full Usage: this.bceLoss (target, ?weight, ?reduction)

Parameters:
    target : Tensor - The target tensor.
    ?weight : Tensor - A manual rescaling weight given to the loss of each batch element.
    ?reduction : string - Optionally specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': the sum of the output will be divided by the number of elements in the output, 'sum': the output will be summed. Note: size_average and reduce are in the process of being deprecated, and in the meantime, specifying either of those two args will override reduction. Default: 'mean'.

Returns: Tensor

Creates a criterion that measures the Binary Cross Entropy between the target and the output

target : Tensor

The target tensor.

?weight : Tensor

A manual rescaling weight given to the loss of each batch element.

?reduction : string

Optionally specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': the sum of the output will be divided by the number of elements in the output, 'sum': the output will be summed. Note: size_average and reduce are in the process of being deprecated, and in the meantime, specifying either of those two args will override reduction. Default: 'mean'.

Returns: Tensor

this.bernoulli (?device, ?dtype, ?backend)

Full Usage: this.bernoulli (?device, ?dtype, ?backend)

Parameters:
    ?device : Device - The desired device of returned tensor. Default: if None, uses Device.Default.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, uses Dtype.Default.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, uses Backend.Default.

Returns: Tensor

Draws binary random numbers (0 or 1) from a Bernoulli distribution

?device : Device

The desired device of returned tensor. Default: if None, uses Device.Default.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, uses Dtype.Default.

?backend : Backend

The desired backend of returned tensor. Default: if None, uses Backend.Default.

Returns: Tensor

this.bfloat16 ()

Full Usage: this.bfloat16 ()

Returns: Tensor

Returns a new tensor with each element converted to type bfloat16

Returns: Tensor

this.bool ()

Full Usage: this.bool ()

Returns: Tensor

Returns a new tensor with each element converted to type bool

Returns: Tensor

this.byte ()

Full Usage: this.byte ()

Returns: Tensor

Returns a new tensor with each element converted to type float64

Returns: Tensor

this.cast ()

Full Usage: this.cast ()

Returns: Tensor

Converts the tensor to a new tensor with the given system type

Returns: Tensor

this.cast dtype

Full Usage: this.cast dtype

Parameters:
Returns: Tensor

Converts the tensor to a new tensor with the given

dtype : Dtype
Returns: Tensor

this.ceil ()

Full Usage: this.ceil ()

Returns: Tensor

Returns a new tensor with the ceil of the elements of input, the smallest integer greater than or equal to each element.

The tensor will have the same element type as the input tensor.

Returns: Tensor

this.clamp (?low, ?high)

Full Usage: this.clamp (?low, ?high)

Parameters:
    ?low : scalar - The lower-bound of the range to be clamped to.
    ?high : scalar - The upper-bound of the range to be clamped to.

Returns: Tensor

Clamp all elements in input into the range [ low..high] and return a resulting tensor

?low : scalar

The lower-bound of the range to be clamped to.

?high : scalar

The upper-bound of the range to be clamped to.

Returns: Tensor

this.clone ()

Full Usage: this.clone ()

Returns: Tensor

Returns a new tensor with underlying storage copied.

This method discards differentiability and returns a constant tensor.

Returns: Tensor

this.conv1d (filters, ?stride, ?padding, ?dilation)

Full Usage: this.conv1d (filters, ?stride, ?padding, ?dilation)

Parameters:
    filters : Tensor - The filters.
    ?stride : int - The stride of the convolving kernel.
    ?padding : int - The implicit paddings on both sides of the input.
    ?dilation : int - The spacing between kernel elements.

Returns: Tensor

Applies a 1D convolution over an input signal composed of several input planes

filters : Tensor

The filters.

?stride : int

The stride of the convolving kernel.

?padding : int

The implicit paddings on both sides of the input.

?dilation : int

The spacing between kernel elements.

Returns: Tensor

this.conv2d (filters, ?stride, ?padding, ?dilation, ?strides, ?paddings, ?dilations)

Full Usage: this.conv2d (filters, ?stride, ?padding, ?dilation, ?strides, ?paddings, ?dilations)

Parameters:
    filters : Tensor - The filters.
    ?stride : int - The stride of the convolving kernel.
    ?padding : int - The implicit padding on corresponding sides of the input.
    ?dilation : int - The spacing between kernel elements.
    ?strides : seq<int> - The strides of the convolving kernel.
    ?paddings : seq<int> - The implicit paddings on corresponding sides of the input.
    ?dilations : seq<int> - The spacings between kernel elements.

Returns: Tensor

Applies a 2D convolution over an input signal composed of several input planes

filters : Tensor

The filters.

?stride : int

The stride of the convolving kernel.

?padding : int

The implicit padding on corresponding sides of the input.

?dilation : int

The spacing between kernel elements.

?strides : seq<int>

The strides of the convolving kernel.

?paddings : seq<int>

The implicit paddings on corresponding sides of the input.

?dilations : seq<int>

The spacings between kernel elements.

Returns: Tensor

this.conv3d (filters, ?stride, ?padding, ?dilation, ?strides, ?paddings, ?dilations)

Full Usage: this.conv3d (filters, ?stride, ?padding, ?dilation, ?strides, ?paddings, ?dilations)

Parameters:
    filters : Tensor - The filters.
    ?stride : int - The stride of the convolving kernel.
    ?padding : int - The implicit padding on corresponding sides of the input.
    ?dilation : int - The spacing between kernel elements.
    ?strides : seq<int> - The strides of the convolving kernel.
    ?paddings : seq<int> - The implicit paddings on corresponding sides of the input.
    ?dilations : seq<int> - The spacings between kernel elements.

Returns: Tensor

Applies a 3D convolution over an input signal composed of several input planes

filters : Tensor

The filters.

?stride : int

The stride of the convolving kernel.

?padding : int

The implicit padding on corresponding sides of the input.

?dilation : int

The spacing between kernel elements.

?strides : seq<int>

The strides of the convolving kernel.

?paddings : seq<int>

The implicit paddings on corresponding sides of the input.

?dilations : seq<int>

The spacings between kernel elements.

Returns: Tensor

this.convTranspose1d (filters, ?stride, ?padding, ?dilation, ?outputPadding)

Full Usage: this.convTranspose1d (filters, ?stride, ?padding, ?dilation, ?outputPadding)

Parameters:
    filters : Tensor - The filters.
    ?stride : int - The stride of the convolving kernel.
    ?padding : int - The implicit padding on both sides of the input.
    ?dilation : int - The spacing between kernel elements.
    ?outputPadding : int - The additional size added to one side of each dimension in the output shape.

Returns: Tensor

Applies a 1D transposed convolution operator over an input signal composed of several input planes, sometimes also called 'deconvolution'.

filters : Tensor

The filters.

?stride : int

The stride of the convolving kernel.

?padding : int

The implicit padding on both sides of the input.

?dilation : int

The spacing between kernel elements.

?outputPadding : int

The additional size added to one side of each dimension in the output shape.

Returns: Tensor

this.convTranspose2d (filters, ?stride, ?padding, ?dilation, ?outputPadding, ?strides, ?paddings, ?dilations, ?outputPaddings)

Full Usage: this.convTranspose2d (filters, ?stride, ?padding, ?dilation, ?outputPadding, ?strides, ?paddings, ?dilations, ?outputPaddings)

Parameters:
    filters : Tensor - The filters.
    ?stride : int - The stride of the convolving kernel.
    ?padding : int - The implicit padding on both sides of the input.
    ?dilation : int - The spacing between kernel elements.
    ?outputPadding : int - The additional size added to one side of each dimension in the output shape.
    ?strides : seq<int> - The strides of the convolving kernel.
    ?paddings : seq<int> - The implicit paddings on corresponding sides of the input.
    ?dilations : seq<int> - The spacings between kernel elements.
    ?outputPaddings : seq<int> - The additional sizes added to one side of each dimension in the output shape.

Returns: Tensor

Applies a 2D transposed convolution operator over an input signal composed of several input planes, sometimes also called 'deconvolution'.

filters : Tensor

The filters.

?stride : int

The stride of the convolving kernel.

?padding : int

The implicit padding on both sides of the input.

?dilation : int

The spacing between kernel elements.

?outputPadding : int

The additional size added to one side of each dimension in the output shape.

?strides : seq<int>

The strides of the convolving kernel.

?paddings : seq<int>

The implicit paddings on corresponding sides of the input.

?dilations : seq<int>

The spacings between kernel elements.

?outputPaddings : seq<int>

The additional sizes added to one side of each dimension in the output shape.

Returns: Tensor

this.convTranspose3d (filters, ?stride, ?padding, ?dilation, ?outputPadding, ?strides, ?paddings, ?dilations, ?outputPaddings)

Full Usage: this.convTranspose3d (filters, ?stride, ?padding, ?dilation, ?outputPadding, ?strides, ?paddings, ?dilations, ?outputPaddings)

Parameters:
    filters : Tensor - The filters.
    ?stride : int - The stride of the convolving kernel.
    ?padding : int - The implicit padding on both sides of the input.
    ?dilation : int - The spacing between kernel elements.
    ?outputPadding : int - The additional size added to one side of each dimension in the output shape.
    ?strides : seq<int> - The strides of the convolving kernel.
    ?paddings : seq<int> - The implicit paddings on corresponding sides of the input.
    ?dilations : seq<int> - The spacings between kernel elements.
    ?outputPaddings : seq<int> - The additional sizes added to one side of each dimension in the output shape.

Returns: Tensor

Applies a 3D transposed convolution operator over an input signal composed of several input planes, sometimes also called 'deconvolution'.

filters : Tensor

The filters.

?stride : int

The stride of the convolving kernel.

?padding : int

The implicit padding on both sides of the input.

?dilation : int

The spacing between kernel elements.

?outputPadding : int

The additional size added to one side of each dimension in the output shape.

?strides : seq<int>

The strides of the convolving kernel.

?paddings : seq<int>

The implicit paddings on corresponding sides of the input.

?dilations : seq<int>

The spacings between kernel elements.

?outputPaddings : seq<int>

The additional sizes added to one side of each dimension in the output shape.

Returns: Tensor

this.corrcoef ()

Full Usage: this.corrcoef ()

Returns: Tensor The correlation coefficient matrix \(R\) is computed from the covariance matrix Returns a square tensor representing the correlation coefficient matrix. Given a tensor with \(N\) variables \(X=[x_1,x_2,\ldots,x_N]\) the \(R_{i,j}\) entry on the correlation matrix is the correlation between \(x_i\) and \(x_j\).

Estimates the Pearson correlation coefficient matrix for the given tensor. The tensor's first dimension should index variables and the second dimension should index observations for each variable.

The correlation between variables \(x\) and \(y\) is \[cor(x,y)= \frac{\sum^{N}_{i = 1}(x_{i} - \mu_x)(y_{i} - \mu_y)}{\sigma_x \sigma_y (N ~-~1)}\] where \(\mu_x\) and \(\mu_y\) are the sample means and \(\sigma_x\) and \(\sigma_x\) are the sample standard deviations.

Returns: Tensor

The correlation coefficient matrix \(R\) is computed from the covariance matrix Returns a square tensor representing the correlation coefficient matrix. Given a tensor with \(N\) variables \(X=[x_1,x_2,\ldots,x_N]\) the \(R_{i,j}\) entry on the correlation matrix is the correlation between \(x_i\) and \(x_j\).

Example

 let x = dsharp.tensor([-0.2678; -0.0908; -0.3766;  0.2780])
 let y = dsharp.tensor([-0.5812;  0.1535;  0.2387;  0.2350])
 let xy = dsharp.stack([x;y])
 xy.corrcoef()
Evaluates to
 tensor([[1.0000, 0.3582],
         [0.3582, 1.0000]])

this.cos ()

Full Usage: this.cos ()

Returns: Tensor

Returns a new tensor with the cosine of the elements of input

Returns: Tensor

this.cosh ()

Full Usage: this.cosh ()

Returns: Tensor

Returns a new tensor with the hyperbolic cosine of the elements of input.

Returns: Tensor

this.cov (?correction, ?fweights, ?aweights)

Full Usage: this.cov (?correction, ?fweights, ?aweights)

Parameters:
    ?correction : int64 - Difference between the sample size and the sample degrees of freedom. Defaults to 1 (Bessel's correction).
    ?fweights : Tensor - Frequency weights represent the number of times each observation was observed. Should be given as a tensor of integers. Defaults to no weights.
    ?aweights : Tensor - Relative importance weights, larger weights for observations that should have a larger effect on the estimate. Should be given as a tensor of floating point numbers. Defaults to no weights.

Returns: Tensor Returns a square tensor representing the covariance matrix. Given a tensor with \(N\) variables \(X=[x_1,x_2,\ldots,x_N]\) the \(C_{i,j}\) entry on the covariance matrix is the covariance between \(x_i\) and \(x_j\).

Estimates the covariance matrix of the given tensor. The tensor's first dimension should index variables and the second dimension should index observations for each variable.

If no weights are given, the covariance between variables \(x\) and \(y\) is \[cov(x,y)= \frac{\sum^{N}_{i = 1}(x_{i} - \mu_x)(y_{i} - \mu_y)}{N~-~\text{correction}}\] where \(\mu_x\) and \(\mu_y\) are the sample means. If there are fweights or aweights then the covariance is \[cov(x,y)=\frac{\sum^{N}_{i = 1}w_i(x_{i} - \mu_x^*)(y_{i} - \mu_y^*)}{\text{normalization factor}}\] where \(w\) is either fweights or aweights if one weight type is provided. If both weight types are provided \(w=\text{fweights}\times\text{aweights}\). \(\mu_x^* = \frac{\sum^{N}_{i = 1}w_ix_{i} }{\sum^{N}_{i = 1}w_i}\) is the weighted mean of variables. The normalization factor is \(\sum^{N}_{i=1} w_i\) if only fweights are provided or if aweights are provided and correction=0. Otherwise if aweights \(aw\) are provided the normalization factor is \(\sum^N_{i=1} w_i - \text{correction}\times\frac{\sum^N_{i=1} w_i aw_i}{\sum^N_{i=1} w_i}\)

?correction : int64

Difference between the sample size and the sample degrees of freedom. Defaults to 1 (Bessel's correction).

?fweights : Tensor

Frequency weights represent the number of times each observation was observed. Should be given as a tensor of integers. Defaults to no weights.

?aweights : Tensor

Relative importance weights, larger weights for observations that should have a larger effect on the estimate. Should be given as a tensor of floating point numbers. Defaults to no weights.

Returns: Tensor

Returns a square tensor representing the covariance matrix. Given a tensor with \(N\) variables \(X=[x_1,x_2,\ldots,x_N]\) the \(C_{i,j}\) entry on the covariance matrix is the covariance between \(x_i\) and \(x_j\).

Example

 let x = dsharp.tensor([0.0;3.4;5.0])
 let y = dsharp.tensor([1.0;2.3;-3.0])
 let xy = dsharp.stack([x;y])
 xy.cov()
Evaluates to
 tensor([[ 6.5200, -4.0100],
         [-4.0100,  7.6300]])

this.cpu ()

Full Usage: this.cpu ()

Returns: Tensor

Returns a new tensor with the same contents moved to the CPU

Returns: Tensor

this.crossEntropyLoss (target, ?weight, ?reduction)

Full Usage: this.crossEntropyLoss (target, ?weight, ?reduction)

Parameters:
    target : Tensor - The target tensor.
    ?weight : Tensor - A optional manual rescaling weight given to the loss of each batch element.
    ?reduction : string - Optionally specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': the sum of the output will be divided by the number of elements in the output, 'sum': the output will be summed. Note: size_average and reduce are in the process of being deprecated, and in the meantime, specifying either of those two args will override reduction. Default: 'mean'.

Returns: Tensor

This criterion combines logsoftmax and nllLoss in a single function

target : Tensor

The target tensor.

?weight : Tensor

A optional manual rescaling weight given to the loss of each batch element.

?reduction : string

Optionally specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': the sum of the output will be divided by the number of elements in the output, 'sum': the output will be summed. Note: size_average and reduce are in the process of being deprecated, and in the meantime, specifying either of those two args will override reduction. Default: 'mean'.

Returns: Tensor

this.depth

Full Usage: this.depth

Returns: int

Gets the differentiation depth of the tensor

Returns: int

this.derivative

Full Usage: this.derivative

Gets or sets the derivative of a tensor used in differentiation

this.derivativeDeep

Full Usage: this.derivativeDeep

Returns: Tensor
Returns: Tensor

this.device

Full Usage: this.device

Returns: Device

Gets the device of the tensor

Returns: Device

this.deviceType

Full Usage: this.deviceType

Returns: DeviceType

Gets the device type of the tensor

Returns: DeviceType

this.diagonal (?offset, ?dim1, ?dim2)

Full Usage: this.diagonal (?offset, ?dim1, ?dim2)

Parameters:
    ?offset : int
    ?dim1 : int
    ?dim2 : int

Returns: Tensor

Returns a tensor with the diagonal elements with respect to dim1 and dim2. The argument offset controls which diagonal to consider.

?offset : int
?dim1 : int
?dim2 : int
Returns: Tensor

this.dilate dilations

Full Usage: this.dilate dilations

Parameters:
    dilations : seq<int> - The dilations to use.

Returns: Tensor

Dilate the tensor in using the given dilations in each corresponding dimension.

dilations : seq<int>

The dilations to use.

Returns: Tensor

this.dim

Full Usage: this.dim

Returns: int

Gets the number of dimensions of the tensor

Returns: int

this.div b

Full Usage: this.div b

Parameters:
Returns: Tensor

Divides each element of the object tensor by the scalar b. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

b : scalar
Returns: Tensor

this.div b

Full Usage: this.div b

Parameters:
Returns: Tensor

Divides each element of the object tensor by the corresponding element of the tensor b. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

b : Tensor
Returns: Tensor

this.dot b

Full Usage: this.dot b

Parameters:
    b : Tensor - The vector to multiply this tensor by (1d-tensor).

Returns: Tensor

Computes the dot product (inner product) of two vector (1d-tensors).

This function does not broadcast and expects this tensor to be a vector (1d-tensor). The tensors must have the same number of elements.

b : Tensor

The vector to multiply this tensor by (1d-tensor).

Returns: Tensor

this.double ()

Full Usage: this.double ()

Returns: Tensor

Returns a new tensor with each element converted to type float64

Returns: Tensor

this.dropout ?p

Full Usage: this.dropout ?p

Parameters:
    ?p : double - The probability of an element to be zeroed. Default: 0.5.

Returns: Tensor

Randomly zeroes some of the elements of the input tensor with probability p using samples from a Bernoulli distribution

?p : double

The probability of an element to be zeroed. Default: 0.5.

Returns: Tensor

this.dropout2d ?p

Full Usage: this.dropout2d ?p

Parameters:
    ?p : double - The probability of an element to be zeroed. Default: 0.5.

Returns: Tensor

Randomly zero out entire channels (a channel is a 2D feature map, e.g., the jj -th channel of the ii -th sample in the batched input is a 2D tensor \text{input}[i, j]input[i,j] ). Each channel will be zeroed out independently on every forward call with probability p using samples from a Bernoulli distribution

?p : double

The probability of an element to be zeroed. Default: 0.5.

Returns: Tensor

this.dropout3d ?p

Full Usage: this.dropout3d ?p

Parameters:
    ?p : double - The probability of an element to be zeroed. Default: 0.5.

Returns: Tensor

Randomly zero out entire channels (a channel is a 3D feature map, e.g., the jj -th channel of the ii -th sample in the batched input is a 3D tensor \text{input}[i, j]input[i,j] ). Each channel will be zeroed out independently on every forward call with probability p using samples from a Bernoulli distribution.

?p : double

The probability of an element to be zeroed. Default: 0.5.

Returns: Tensor

this.dtype

Full Usage: this.dtype

Returns: Dtype

Gets the element type of the tensor

Returns: Dtype

this.elementSize

Full Usage: this.elementSize

Returns: int

Returns the size in bytes of an individual element in this tensor. Depending on dtype, backend configuration, this is not guaranteed to be correct and can behave differently in different runtime environments.

Returns: int

this.eq b

Full Usage: this.eq b

Parameters:
Returns: Tensor

Computes element-wise \(a = b\), returning a boolean tensor containing a true at each location where the comparison is true

b : Tensor
Returns: Tensor

this.exp ()

Full Usage: this.exp ()

Returns: Tensor

Applies the exp function element-wise.

Returns: Tensor

this.expand newShape

Full Usage: this.expand newShape

Parameters:
    newShape : seq<int>

Returns: Tensor

Returns a new view of the object tensor with singleton dimensions expanded to a larger size.

Passing -1 as the size for a dimension means not changing the size of that dimension.

The tensor can be also expanded to a larger number of dimensions, and the new ones will be appended at the front. For the new dimensions, the size cannot be set to -1.

Expanding a tensor does not allocate new memory, but only creates a new view on the existing tensor where a dimension of size one is expanded to a larger size by setting the stride to 0. Any dimension of size 1 can be expanded to an arbitrary value without allocating new memory.

newShape : seq<int>
Returns: Tensor

this.expandAs b

Full Usage: this.expandAs b

Parameters:
Returns: Tensor

Expand this tensor to the same size as the other.

b : Tensor
Returns: Tensor

this.fanout

Full Usage: this.fanout

Gets the fanout of a tensor used in reverse-mode differentiation

this.flatten (?startDim, ?endDim)

Full Usage: this.flatten (?startDim, ?endDim)

Parameters:
    ?startDim : int - The first dim to flatten.
    ?endDim : int - The last dim to flatten.

Returns: Tensor

Flattens a contiguous range of dims in a tensor.

?startDim : int

The first dim to flatten.

?endDim : int

The last dim to flatten.

Returns: Tensor

this.flip dims

Full Usage: this.flip dims

Parameters:
    dims : seq<int> - The axis to flip on.

Returns: Tensor

Reverse the order of a n-D tensor along given axis in dims

dims : seq<int>

The axis to flip on.

Returns: Tensor

this.float ()

Full Usage: this.float ()

Returns: Tensor

Returns a new tensor with each element converted to type float64

Returns: Tensor

this.float16 ()

Full Usage: this.float16 ()

Returns: Tensor

Returns a new tensor with each element converted to type float16

Returns: Tensor

this.float32 ()

Full Usage: this.float32 ()

Returns: Tensor

Returns a new tensor with each element converted to type float32

Returns: Tensor

this.float64 ()

Full Usage: this.float64 ()

Returns: Tensor

Returns a new tensor with each element converted to type float64

Returns: Tensor

this.floor ()

Full Usage: this.floor ()

Returns: Tensor

Returns a new tensor with the floor of the elements of input, the largest integer less than or equal to each element.

The tensor will have the same element type as the input tensor.

Returns: Tensor

this.forwardDiff (derivative, ?nestingTag)

Full Usage: this.forwardDiff (derivative, ?nestingTag)

Parameters:
    derivative : Tensor
    ?nestingTag : uint32

Returns: Tensor

Returns the input tensor with added support for forward-mode automatic differentiation.

Any tensors produced using this tensor will have attached derivatives for forward mode propagation. The current global nesting level is used for nested differentiation.

derivative : Tensor
?nestingTag : uint32
Returns: Tensor

this.fullLike (value, ?shape, ?device, ?dtype, ?backend)

Full Usage: this.fullLike (value, ?shape, ?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a new tensor filled with the given scalar value for the given shape, element type and configuration, defaulting to the shape and configuration of the input tensor.

value : scalar
?shape : seq<int>
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.gather (dim, indices)

Full Usage: this.gather (dim, indices)

Parameters:
    dim : int - The axis along which to index.
    indices : Tensor - The the indices of elements to gather.

Returns: Tensor

Gathers values along an axis specified by dim.

dim : int

The axis along which to index.

indices : Tensor

The the indices of elements to gather.

Returns: Tensor

this.ge b

Full Usage: this.ge b

Parameters:
Returns: Tensor

Computes element-wise \(a \geq b\), returning a boolean tensor containing a true at each location where the comparison is true

b : Tensor
Returns: Tensor

this.gpu ()

Full Usage: this.gpu ()

Returns: Tensor

Returns a new tensor with the same contents moved to the primary GPU device

Returns: Tensor

this.gt b

Full Usage: this.gt b

Parameters:
Returns: Tensor

Computes element-wise \(a > b\), returning a boolean tensor containing a true at each location where the comparison is true

b : Tensor
Returns: Tensor

this.hasinf ()

Full Usage: this.hasinf ()

Returns: bool

Gets if any value in the tensor is +/- INF.

Returns: bool

this.hasinfnan ()

Full Usage: this.hasinfnan ()

Returns: bool

Gets if any value in the tensor is NaN or +/- INF.

Returns: bool

this.hasnan ()

Full Usage: this.hasnan ()

Returns: bool

Gets if any value in the tensor is NaN.

Returns: bool

this.int ()

Full Usage: this.int ()

Returns: Tensor

Returns a new tensor with each element converted to type int32

Returns: Tensor

this.int16 ()

Full Usage: this.int16 ()

Returns: Tensor

Returns a new tensor with each element converted to type int16

Returns: Tensor

this.int32 ()

Full Usage: this.int32 ()

Returns: Tensor

Returns a new tensor with each element converted to type int32

Returns: Tensor

this.int64 ()

Full Usage: this.int64 ()

Returns: Tensor

Returns a new tensor with each element converted to type int64

Returns: Tensor

this.int8 ()

Full Usage: this.int8 ()

Returns: Tensor

Returns a new tensor with each element converted to type int8

Returns: Tensor

this.isForwardDiff

Full Usage: this.isForwardDiff

Returns: bool

Indicates if a tensor is taking part in forward-mode differentiation

Returns: bool

this.isNoDiff

Full Usage: this.isNoDiff

Returns: bool

Indicates if a tensor is a constant, meaning that it is not taking part in forward or reverse-mode differentiation

Returns: bool

this.isReverseDiff

Full Usage: this.isReverseDiff

Returns: bool

Indicates if a tensor is taking part in reverse-mode differentiation

Returns: bool

this.isSameDiffType t2

Full Usage: this.isSameDiffType t2

Parameters:
Returns: bool

Indicates if two tensors have the same differentiation type

t2 : Tensor
Returns: bool

this.isinf ()

Full Usage: this.isinf ()

Returns: Tensor

Returns a new tensor with boolean elements representing if each element is +/-INF or not.

Returns: Tensor

this.isnan ()

Full Usage: this.isnan ()

Returns: Tensor

Returns a new tensor with boolean elements representing if each element is NaN or not. Complex values are considered NaN when either their real and/or imaginary part is NaN.

Returns: Tensor

this.le b

Full Usage: this.le b

Parameters:
Returns: Tensor

Computes element-wise \(a \leq b\), returning a boolean tensor containing a true at each location where the comparison is true

b : Tensor
Returns: Tensor

this.leakyRelu ?negativeSlope

Full Usage: this.leakyRelu ?negativeSlope

Parameters:
    ?negativeSlope : float - Controls the angle of the negative slope. Default: 0.01.

Returns: Tensor

Applies the leaky rectified linear unit function element-wise

\[\text{leakyRelu}(x) = \max(0, x) + \text{negativeSlope} * \min(0, x)\]

?negativeSlope : float

Controls the angle of the negative slope. Default: 0.01.

Returns: Tensor

this.like (value, ?device, ?dtype, ?backend)

Full Usage: this.like (value, ?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a tensor from the .NET data in value for the given element type and configuration, defaulting to the element type and configuration of the input tensor.

value : obj
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.linspaceLike (startVal, endVal, steps, ?device, ?dtype, ?backend)

Full Usage: this.linspaceLike (startVal, endVal, steps, ?device, ?dtype, ?backend)

Parameters:
    startVal : int
    endVal : int
    steps : int
    ?device : Device
    ?dtype : Dtype
    ?backend : Backend

Returns: Tensor

Returns a tensor in the manner of for the given element type and configuration, defaulting to the element type and configuration of the input tensor.

startVal : int
endVal : int
steps : int
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.linspaceLike (startVal, endVal, steps, ?device, ?dtype, ?backend)

Full Usage: this.linspaceLike (startVal, endVal, steps, ?device, ?dtype, ?backend)

Parameters:
    startVal : float
    endVal : float
    steps : int
    ?device : Device
    ?dtype : Dtype
    ?backend : Backend

Returns: Tensor

Returns a tensor in the manner of for the given element type and configuration, defaulting to the element type and configuration of the input tensor.

startVal : float
endVal : float
steps : int
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.log ()

Full Usage: this.log ()

Returns: Tensor

Returns a new tensor with the natural logarithm of the elements of input.

\[y_{i} = \log_{e} (x_{i})\]

Returns: Tensor

this.log10 ()

Full Usage: this.log10 ()

Returns: Tensor

Returns a new tensor with the logarithm to the base 10 of the elements of input.

\[y_{i} = \log_{10} (x_{i})\]

Returns: Tensor

this.logsoftmax dim

Full Usage: this.logsoftmax dim

Parameters:
    dim : int - A dimension along which softmax will be computed.

Returns: Tensor

Applies a softmax followed by a logarithm.

dim : int

A dimension along which softmax will be computed.

Returns: Tensor

this.logspaceLike (startVal, endVal, steps, ?baseVal, ?device, ?dtype, ?backend)

Full Usage: this.logspaceLike (startVal, endVal, steps, ?baseVal, ?device, ?dtype, ?backend)

Parameters:
    startVal : int
    endVal : int
    steps : int
    ?baseVal : int
    ?device : Device
    ?dtype : Dtype
    ?backend : Backend

Returns: Tensor

Returns a tensor in the manner of for the given element type and configuration, defaulting to the element type and configuration of the input tensor.

startVal : int
endVal : int
steps : int
?baseVal : int
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.logspaceLike (startVal, endVal, steps, ?baseVal, ?device, ?dtype, ?backend)

Full Usage: this.logspaceLike (startVal, endVal, steps, ?baseVal, ?device, ?dtype, ?backend)

Parameters:
    startVal : float
    endVal : float
    steps : int
    ?baseVal : float
    ?device : Device
    ?dtype : Dtype
    ?backend : Backend

Returns: Tensor

Returns a tensor in the manner of for the given element type and configuration, defaulting to the element type and configuration of the input tensor.

startVal : float
endVal : float
steps : int
?baseVal : float
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.logsumexp (dim, ?keepDim)

Full Usage: this.logsumexp (dim, ?keepDim)

Parameters:
    dim : int - The dimension to reduce.
    ?keepDim : bool - Whether the output tensor has dim retained or not.

Returns: Tensor

Applies a logsumexp.

dim : int

The dimension to reduce.

?keepDim : bool

Whether the output tensor has dim retained or not.

Returns: Tensor

this.lt b

Full Usage: this.lt b

Parameters:
Returns: Tensor

Computes element-wise \(a < b\), returning a boolean tensor containing a true at each location where the comparison is true

b : Tensor
Returns: Tensor

this.matmul b

Full Usage: this.matmul b

Parameters:
Returns: Tensor

Matrix product of two tensors.

The behavior depends on the dimensionality of the tensors as follows:

If both tensors are 1-dimensional, the dot product (scalar) is returned.

If both arguments are 2-dimensional, the matrix-matrix product is returned.

If the first argument is 1-dimensional and the second argument is 2-dimensional, a 1 is prepended to its dimension for the purpose of the matrix multiply. After the matrix multiply, the prepended dimension is removed.

If the first argument is 2-dimensional and the second argument is 1-dimensional, the matrix-vector product is returned.

If both arguments are at least 1-dimensional and at least one argument is N-dimensional (where N > 2), then a batched matrix multiply is returned. If the first argument is 1-dimensional, a 1 is prepended to its dimension for the purpose of the batched matrix multiply and removed after. If the second argument is 1-dimensional, a 1 is appended to its dimension for the purpose of the batched matrix multiple and removed after. The non-matrix (i.e. batch) dimensions are broadcasted (and thus must be broadcastable). For example, if input is a (j \times 1 \times n \times m)(j×1×n×m) tensor and other is a (k \times m \times p)(k×m×p) tensor, out will be an (j \times k \times n \times p)(j×k×n×p) tensor.

b : Tensor
Returns: Tensor

this.max b

Full Usage: this.max b

Parameters:
Returns: Tensor

Returns the element-wise maximum of the elements in the two tensors.

b : Tensor
Returns: Tensor

this.max ()

Full Usage: this.max ()

Returns: Tensor

Returns the maximum value of all elements in the input tensor.

Returns: Tensor

this.max (dim, ?keepDim)

Full Usage: this.max (dim, ?keepDim)

Parameters:
    dim : int
    ?keepDim : bool

Returns: Tensor

Returns the maximum value along the given dimension of all elements in the input tensor.

dim : int
?keepDim : bool
Returns: Tensor

this.maxpool1d (kernelSize, ?stride, ?padding)

Full Usage: this.maxpool1d (kernelSize, ?stride, ?padding)

Parameters:
    kernelSize : int - The size of the window to take a max over.
    ?stride : int - The stride of the window. Default value is kernelSize.
    ?padding : int - The implicit zero padding to be added on both sides.

Returns: Tensor

Applies a 1D max pooling over an input signal composed of several input planes.

kernelSize : int

The size of the window to take a max over.

?stride : int

The stride of the window. Default value is kernelSize.

?padding : int

The implicit zero padding to be added on both sides.

Returns: Tensor

this.maxpool1di (kernelSize, ?stride, ?padding)

Full Usage: this.maxpool1di (kernelSize, ?stride, ?padding)

Parameters:
    kernelSize : int - The size of the window to take a max over.
    ?stride : int - The stride of the window. Default value is kernelSize.
    ?padding : int - The implicit zero padding to be added on both sides.

Returns: Tensor * Tensor

Applies a 1D max pooling over an input signal composed of several input planes, returning the max indices along with the outputs.

kernelSize : int

The size of the window to take a max over.

?stride : int

The stride of the window. Default value is kernelSize.

?padding : int

The implicit zero padding to be added on both sides.

Returns: Tensor * Tensor

this.maxpool2d (?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings)

Full Usage: this.maxpool2d (?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings)

Parameters:
    ?kernelSize : int - The size of the window to take a max over.
    ?stride : int - The stride of the window. Default value is kernelSize.
    ?padding : int - The implicit zero padding to be added on both sides.
    ?kernelSizes : seq<int> - The sizes of the window to take a max over.
    ?strides : seq<int> - The strides of the window. Default value is kernelSize.
    ?paddings : seq<int> - The implicit zero paddings to be added on corresponding sides.

Returns: Tensor

Applies a 2D max pooling over an input signal composed of several input planes.

?kernelSize : int

The size of the window to take a max over.

?stride : int

The stride of the window. Default value is kernelSize.

?padding : int

The implicit zero padding to be added on both sides.

?kernelSizes : seq<int>

The sizes of the window to take a max over.

?strides : seq<int>

The strides of the window. Default value is kernelSize.

?paddings : seq<int>

The implicit zero paddings to be added on corresponding sides.

Returns: Tensor

this.maxpool2di (?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings)

Full Usage: this.maxpool2di (?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings)

Parameters:
    ?kernelSize : int - The size of the window to take a max over.
    ?stride : int - The stride of the window. Default value is kernelSize.
    ?padding : int - The implicit zero padding to be added on both sides.
    ?kernelSizes : seq<int> - The sizes of the window to take a max over.
    ?strides : seq<int> - The strides of the window. Default value is kernelSize.
    ?paddings : seq<int> - The implicit zero paddings to be added on corresponding sides.

Returns: Tensor * Tensor

Applies a 2D max pooling over an input signal composed of several input planes, returning the max indices along with the outputs.

?kernelSize : int

The size of the window to take a max over.

?stride : int

The stride of the window. Default value is kernelSize.

?padding : int

The implicit zero padding to be added on both sides.

?kernelSizes : seq<int>

The sizes of the window to take a max over.

?strides : seq<int>

The strides of the window. Default value is kernelSize.

?paddings : seq<int>

The implicit zero paddings to be added on corresponding sides.

Returns: Tensor * Tensor

this.maxpool3d (?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings)

Full Usage: this.maxpool3d (?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings)

Parameters:
    ?kernelSize : int - The size of the window to take a max over.
    ?stride : int - The stride of the window. Default value is kernelSize.
    ?padding : int - The implicit zero padding to be added on both sides.
    ?kernelSizes : seq<int> - The sizes of the window to take a max over.
    ?strides : seq<int> - The strides of the window. Default value is kernelSizes.
    ?paddings : seq<int> - The implicit zero paddings to be added on corresponding sides.

Returns: Tensor

Applies a 3D max pooling over an input signal composed of several input planes.

?kernelSize : int

The size of the window to take a max over.

?stride : int

The stride of the window. Default value is kernelSize.

?padding : int

The implicit zero padding to be added on both sides.

?kernelSizes : seq<int>

The sizes of the window to take a max over.

?strides : seq<int>

The strides of the window. Default value is kernelSizes.

?paddings : seq<int>

The implicit zero paddings to be added on corresponding sides.

Returns: Tensor

this.maxpool3di (?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings)

Full Usage: this.maxpool3di (?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings)

Parameters:
    ?kernelSize : int - The size of the window to take a max over.
    ?stride : int - The stride of the window. Default value is kernelSize.
    ?padding : int - The implicit zero padding to be added on both sides.
    ?kernelSizes : seq<int> - The sizes of the window to take a max over.
    ?strides : seq<int> - The strides of the window. Default value is kernelSize.
    ?paddings : seq<int> - The implicit zero paddings to be added on corresponding sides.

Returns: Tensor * Tensor

Applies a 3D max pooling over an input signal composed of several input planes, returning the max indices along with the outputs.

?kernelSize : int

The size of the window to take a max over.

?stride : int

The stride of the window. Default value is kernelSize.

?padding : int

The implicit zero padding to be added on both sides.

?kernelSizes : seq<int>

The sizes of the window to take a max over.

?strides : seq<int>

The strides of the window. Default value is kernelSize.

?paddings : seq<int>

The implicit zero paddings to be added on corresponding sides.

Returns: Tensor * Tensor

this.maxunpool1d (indices, kernelSize, ?stride, ?padding, ?outputSize)

Full Usage: this.maxunpool1d (indices, kernelSize, ?stride, ?padding, ?outputSize)

Parameters:
    indices : Tensor - The indices selected by maxpool1di.
    kernelSize : int - The size of the window to take a max over.
    ?stride : int - The stride of the window. Default value is kernelSize.
    ?padding : int - The implicit zero padding to be added on both sides.
    ?outputSize : seq<int> - The targeted output size.

Returns: Tensor

Computes a partial inverse of maxpool1di

indices : Tensor

The indices selected by maxpool1di.

kernelSize : int

The size of the window to take a max over.

?stride : int

The stride of the window. Default value is kernelSize.

?padding : int

The implicit zero padding to be added on both sides.

?outputSize : seq<int>

The targeted output size.

Returns: Tensor

this.maxunpool2d (indices, ?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings, ?outputSize)

Full Usage: this.maxunpool2d (indices, ?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings, ?outputSize)

Parameters:
    indices : Tensor - The indices selected by maxpool2di.
    ?kernelSize : int - The size of the window to take a max over.
    ?stride : int - The stride of the window. Default value is kernelSize.
    ?padding : int - The implicit zero padding to be added on both sides.
    ?kernelSizes : seq<int> - The sizes of the window to take a max over.
    ?strides : seq<int> - The strides of the window. Default value is kernelSizes.
    ?paddings : seq<int> - The implicit zero paddings to be added on corresponding sides.
    ?outputSize : seq<int> - The targeted output size.

Returns: Tensor

Computes a partial inverse of maxpool2di

indices : Tensor

The indices selected by maxpool2di.

?kernelSize : int

The size of the window to take a max over.

?stride : int

The stride of the window. Default value is kernelSize.

?padding : int

The implicit zero padding to be added on both sides.

?kernelSizes : seq<int>

The sizes of the window to take a max over.

?strides : seq<int>

The strides of the window. Default value is kernelSizes.

?paddings : seq<int>

The implicit zero paddings to be added on corresponding sides.

?outputSize : seq<int>

The targeted output size.

Returns: Tensor

this.maxunpool3d (indices, ?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings, ?outputSize)

Full Usage: this.maxunpool3d (indices, ?kernelSize, ?stride, ?padding, ?kernelSizes, ?strides, ?paddings, ?outputSize)

Parameters:
    indices : Tensor - The indices selected by maxpool3di.
    ?kernelSize : int - The size of the window to take a max over.
    ?stride : int - The stride of the window. Default value is kernelSize.
    ?padding : int - The implicit zero padding to be added on both sides.
    ?kernelSizes : seq<int> - The sizes of the window to take a max over.
    ?strides : seq<int> - The strides of the window. Default value is kernelSizes.
    ?paddings : seq<int> - The implicit zero paddings to be added on corresponding sides.
    ?outputSize : seq<int> - The targeted output size.

Returns: Tensor

Computes a partial inverse of maxpool3di

indices : Tensor

The indices selected by maxpool3di.

?kernelSize : int

The size of the window to take a max over.

?stride : int

The stride of the window. Default value is kernelSize.

?padding : int

The implicit zero padding to be added on both sides.

?kernelSizes : seq<int>

The sizes of the window to take a max over.

?strides : seq<int>

The strides of the window. Default value is kernelSizes.

?paddings : seq<int>

The implicit zero paddings to be added on corresponding sides.

?outputSize : seq<int>

The targeted output size.

Returns: Tensor

this.mean (dim, ?keepDim)

Full Usage: this.mean (dim, ?keepDim)

Parameters:
    dim : int - The dimension to reduce.
    ?keepDim : bool - Whether the output tensor has dim retained or not.

Returns: Tensor

Returns the mean value of each row of the input tensor in the given dimension dim.

If keepdim is True, the output tensor is of the same size as input except in the dimension dim where it is of size 1. Otherwise, dim is squeezed, resulting in the output tensor having 1 fewer dimension.

dim : int

The dimension to reduce.

?keepDim : bool

Whether the output tensor has dim retained or not.

Returns: Tensor

this.mean ()

Full Usage: this.mean ()

Returns: Tensor

Returns the mean value of all elements in the input tensor

Returns: Tensor

this.memorySize

Full Usage: this.memorySize

Returns: int64

Returns the size in bytes of the total memory used by this tensor. Depending on dtype, backend configuration, this is not guaranteed to be correct and can behave differently in different runtime environments.

Returns: int64

this.min b

Full Usage: this.min b

Parameters:
Returns: Tensor

Returns the element-wise minimum of the elements in the two tensors.

b : Tensor
Returns: Tensor

this.min ()

Full Usage: this.min ()

Returns: Tensor

Returns the minimum value of all elements in the input tensor.

Returns: Tensor

this.min (dim, ?keepDim)

Full Usage: this.min (dim, ?keepDim)

Parameters:
    dim : int
    ?keepDim : bool

Returns: Tensor

Returns the minimum value along the given dimension of all elements in the input tensor.

dim : int
?keepDim : bool
Returns: Tensor

this.move (?device, ?dtype, ?backend)

Full Usage: this.move (?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a new tensor with the same contents moved to the given configuration

?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.move device

Full Usage: this.move device

Parameters:
Returns: Tensor

Returns a new tensor with the same contents moved to the given device

device : Device
Returns: Tensor

this.move backend

Full Usage: this.move backend

Parameters:
Returns: Tensor

Returns a new tensor with the same contents moved to the given backend

backend : Backend
Returns: Tensor

this.mseLoss (target, ?reduction)

Full Usage: this.mseLoss (target, ?reduction)

Parameters:
    target : Tensor - The target tensor.
    ?reduction : string - Optionally specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': the sum of the output will be divided by the number of elements in the output, 'sum': the output will be summed. Note: size_average and reduce are in the process of being deprecated, and in the meantime, specifying either of those two args will override reduction. Default: 'mean'.

Returns: Tensor

Creates a criterion that measures the mean squared error (squared L2 norm) between each element in the input and the target.

target : Tensor

The target tensor.

?reduction : string

Optionally specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': the sum of the output will be divided by the number of elements in the output, 'sum': the output will be summed. Note: size_average and reduce are in the process of being deprecated, and in the meantime, specifying either of those two args will override reduction. Default: 'mean'.

Returns: Tensor

this.mul b

Full Usage: this.mul b

Parameters:
Returns: Tensor

Multiplies each element of the object tensor by the scalar b. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

b : scalar
Returns: Tensor

this.mul b

Full Usage: this.mul b

Parameters:
Returns: Tensor

Multiplies each element of the object tensor by the corresponding element of the tensor b. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

b : Tensor
Returns: Tensor

this.multinomial (numSamples, ?normalize, ?device, ?dtype, ?backend)

Full Usage: this.multinomial (numSamples, ?normalize, ?device, ?dtype, ?backend)

Parameters:
    numSamples : int - The number of samples to draw.
    ?normalize : bool - Indicates where the probabilities should first be normalized by their sum.
    ?device : Device - The desired device of returned tensor. Default: if None, uses Device.Default.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, uses Dtype.Default.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, uses Backend.Default.

Returns: Tensor

Returns a tensor where each row contains numSamples indices sampled from the multinomial probability distribution located in the corresponding row of tensor input.

numSamples : int

The number of samples to draw.

?normalize : bool

Indicates where the probabilities should first be normalized by their sum.

?device : Device

The desired device of returned tensor. Default: if None, uses Device.Default.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, uses Dtype.Default.

?backend : Backend

The desired backend of returned tensor. Default: if None, uses Backend.Default.

Returns: Tensor

this.ne b

Full Usage: this.ne b

Parameters:
Returns: Tensor

Computes element-wise \(a \neq b\), returning a boolean tensor containing a true at each location where the comparison is true

b : Tensor
Returns: Tensor

this.neg ()

Full Usage: this.neg ()

Returns: Tensor

Returns a new tensor with the negative of the elements of the object tensor.

Returns: Tensor

this.nelement

Full Usage: this.nelement

Returns: int

Gets the number of elements in the tensor

Returns: int

this.nestingTag

Full Usage: this.nestingTag

Returns: uint32

Gets the differentiation nesting tag of the tensor

Returns: uint32

this.nllLoss (target, ?weight, ?reduction)

Full Usage: this.nllLoss (target, ?weight, ?reduction)

Parameters:
    target : Tensor - The target tensor.
    ?weight : Tensor - A optional manual rescaling weight given to the loss of each batch element.
    ?reduction : string - Optionally specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': the sum of the output will be divided by the number of elements in the output, 'sum': the output will be summed. Note: size_average and reduce are in the process of being deprecated, and in the meantime, specifying either of those two args will override reduction. Default: 'mean'.

Returns: Tensor

The negative log likelihood loss.

target : Tensor

The target tensor.

?weight : Tensor

A optional manual rescaling weight given to the loss of each batch element.

?reduction : string

Optionally specifies the reduction to apply to the output: 'none' | 'mean' | 'sum'. 'none': no reduction will be applied, 'mean': the sum of the output will be divided by the number of elements in the output, 'sum': the output will be summed. Note: size_average and reduce are in the process of being deprecated, and in the meantime, specifying either of those two args will override reduction. Default: 'mean'.

Returns: Tensor

this.noDiff ()

Full Usage: this.noDiff ()

Returns: Tensor

Returns the input tensor but with any support for automatic differentiation removed.

Returns: Tensor

this.normalize ()

Full Usage: this.normalize ()

Returns: Tensor

Returns the tensor after min-max scaling

Returns: Tensor

this.oneLike (?device, ?dtype, ?backend)

Full Usage: this.oneLike (?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a scalar '1' tensor for the given element type and configuration, defaulting to the element type and configuration of the input tensor.

?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.onehotLike (length, hot, ?device, ?dtype, ?backend)

Full Usage: this.onehotLike (length, hot, ?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a tensor in the manner of for the given element type and configuration, defaulting to the element type and configuration of the input tensor.

length : int
hot : int
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.onesLike (?shape, ?device, ?dtype, ?backend)

Full Usage: this.onesLike (?shape, ?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a new tensor filled with '1' values for the given shape, element type and configuration, defaulting to the shape and configuration of the input tensor.

?shape : seq<int>
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.pad paddings

Full Usage: this.pad paddings

Parameters:
    paddings : seq<int> - The implicit paddings on corresponding sides of the input.

Returns: Tensor

Add zero padding to each side of a tensor

paddings : seq<int>

The implicit paddings on corresponding sides of the input.

Returns: Tensor

this.parentOp

Full Usage: this.parentOp

Returns: TensorOp

Gets the parent operation of a tensor used in reverse-mode differentiation

Returns: TensorOp

this.permute permutation

Full Usage: this.permute permutation

Parameters:
    permutation : seq<int> - The desired ordering of dimensions.

Returns: Tensor

Returns the original tensor with its dimensions permuted.

permutation : seq<int>

The desired ordering of dimensions.

Returns: Tensor

this.pow b

Full Usage: this.pow b

Parameters:
Returns: Tensor

Raises each element of the self tensor to the power of the scalar b. The resulting tensor is returned.

b : scalar
Returns: Tensor

this.pow b

Full Usage: this.pow b

Parameters:
Returns: Tensor

Raises each element of the self tensor to the power of each corresponding element of the tensor b. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

b : Tensor
Returns: Tensor

this.primal

Full Usage: this.primal

Returns: Tensor

Gets the value of the tensor ignoring its first derivative

Returns: Tensor

this.primalDeep

Full Usage: this.primalDeep

Returns: Tensor

Gets the value of the tensor ignoring all its derivatives

Returns: Tensor

this.primalRaw

Full Usage: this.primalRaw

Returns: RawTensor

Gets the raw value of the tensor ignoring all its derivatives

Returns: RawTensor

this.randLike (?shape, ?device, ?dtype, ?backend)

Full Usage: this.randLike (?shape, ?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a new tensor with random values drawn from the uniform distribution [0,1) for the given shape, element type and configuration, defaulting to the shape and configuration of the input tensor.

?shape : seq<int>
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.randintLike (low, high, ?shape, ?device, ?dtype, ?backend)

Full Usage: this.randintLike (low, high, ?shape, ?device, ?dtype, ?backend)

Parameters:
    low : int
    high : int
    ?shape : seq<int>
    ?device : Device
    ?dtype : Dtype
    ?backend : Backend

Returns: Tensor

Returns a new tensor with random integer values drawn from the given range, for the given shape, element type and configuration, defaulting to the shape and configuration of the input tensor.

low : int
high : int
?shape : seq<int>
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.randnLike (?shape, ?device, ?dtype, ?backend)

Full Usage: this.randnLike (?shape, ?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a new tensor with random values drawn from the standard normal distribution, for the given shape, element type and configuration, defaulting to the shape and configuration of the input tensor.

?shape : seq<int>
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.relu ()

Full Usage: this.relu ()

Returns: Tensor

Applies the rectified linear unit function element-wise.

Returns: Tensor

this.repeat (dim, times)

Full Usage: this.repeat (dim, times)

Parameters:
    dim : int - The dimension along which to repeat values.
    times : int - The number of repetitions for each element.

Returns: Tensor

Repeat elements of a tensor

dim : int

The dimension along which to repeat values.

times : int

The number of repetitions for each element.

Returns: Tensor

this.reverse (?value, ?zeroDerivatives)

Full Usage: this.reverse (?value, ?zeroDerivatives)

Parameters:
    ?value : Tensor - The derivative value to propagate backwards. Should have the same shape with this tensor.
    ?zeroDerivatives : bool - Indicates whether any existing derivatives in the computation graph (for example from a previous reverse propagation that was executed) should be zeroed or not before starting this propagation. Default: true

Propagate the reverse-mode derivative backwards in the computation graph, starting from this tensor.

?value : Tensor

The derivative value to propagate backwards. Should have the same shape with this tensor.

?zeroDerivatives : bool

Indicates whether any existing derivatives in the computation graph (for example from a previous reverse propagation that was executed) should be zeroed or not before starting this propagation. Default: true

this.reverseDiff (?derivative, ?nestingTag)

Full Usage: this.reverseDiff (?derivative, ?nestingTag)

Parameters:
    ?derivative : Tensor - The derivative (adjoint) to assign to the new reverse-mode tensor. Defaults to an empty placeholder tensor.
    ?nestingTag : uint32 - The level nestingTag for nested differentiation. Defaults to the current global nesting level

Returns: Tensor

Returns the input tensor with added support for reverse-mode automatic differentiation.

Any tensors produced using this tensor will also support reverse-mode propagation. After the completion of the corresponding reverse operation on the overall result tensor, the computed derivative will be available.

?derivative : Tensor

The derivative (adjoint) to assign to the new reverse-mode tensor. Defaults to an empty placeholder tensor.

?nestingTag : uint32

The level nestingTag for nested differentiation. Defaults to the current global nesting level

Returns: Tensor

this.reversePush value

Full Usage: this.reversePush value

Parameters:
    value : Tensor - The value to apply.

Push the given value as part of the reverse-mode computation at the given output tensor.

value : Tensor

The value to apply.

this.reverseReset zeroDerivatives

Full Usage: this.reverseReset zeroDerivatives

Parameters:
    zeroDerivatives : bool

Reset the reverse mode computation graph associated with the given output tensor.

zeroDerivatives : bool

this.round ()

Full Usage: this.round ()

Returns: Tensor

Returns a new tensor with each of the elements of input rounded to the closest integer.

The tensor will have the same element type as the input tensor.

Returns: Tensor

this.safelog ?epsilon

Full Usage: this.safelog ?epsilon

Parameters:
    ?epsilon : float

Returns: Tensor

Returns the logarithm of the tensor after clamping the tensor so that all its elements are greater than epsilon. This is to avoid a -inf result for elements equal to zero.

?epsilon : float
Returns: Tensor

this.save fileName

Full Usage: this.save fileName

Parameters:
    fileName : string

Saves the tensor to the given file using a bespoke binary format.

The binary format records the elements, backend, element type and shape. It does not record the device. The format used may change from version to version of DiffSharp.

fileName : string

this.scalarLike (scalar, ?device, ?dtype, ?backend)

Full Usage: this.scalarLike (scalar, ?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a new scalar tensor for the given shape, element type and configuration, defaulting to the shape and configuration of the input tensor.

scalar : scalar
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.scatter (dim, indices, destinationShape)

Full Usage: this.scatter (dim, indices, destinationShape)

Parameters:
    dim : int - The axis along which to index.
    indices : Tensor - The the indices of elements to gather.
    destinationShape : seq<int> - The destination shape.

Returns: Tensor

Scatter values along an axis specified by dim.

dim : int

The axis along which to index.

indices : Tensor

The the indices of elements to gather.

destinationShape : seq<int>

The destination shape.

Returns: Tensor

this.shape

Full Usage: this.shape

Returns: Shape

Gets the shape of the tensor

Returns: Shape

this.sigmoid ()

Full Usage: this.sigmoid ()

Returns: Tensor

Applies the sigmoid element-wise function

\[\text{sigmoid}(x) = \frac{1}{1 + \exp(-x)}\]

Returns: Tensor

this.sign ()

Full Usage: this.sign ()

Returns: Tensor

Returns a new tensor with the signs of the elements of input.

The tensor will have the same element type as the input tensor.

Returns: Tensor

this.sin ()

Full Usage: this.sin ()

Returns: Tensor

Returns a new tensor with the sine of the elements of input

Returns: Tensor

this.sinh ()

Full Usage: this.sinh ()

Returns: Tensor

Returns a new tensor with the hyperbolic sine of the elements of input.

Returns: Tensor

this.softmax dim

Full Usage: this.softmax dim

Parameters:
    dim : int - A dimension along which softmax will be computed.

Returns: Tensor

Applies a softmax function.

Softmax is defined as: \text{softmax}(x_{i}) = \frac{\exp(x_i)}{\sum_j \exp(x_j)}.

dim : int

A dimension along which softmax will be computed.

Returns: Tensor

this.softplus ()

Full Usage: this.softplus ()

Returns: Tensor

Applies the softplus function element-wise.

\[\text{softplus}(x) = \frac{1}{\beta} * \log(1 + \exp(\beta * x))\]

Returns: Tensor

this.split (sizes, ?dim)

Full Usage: this.split (sizes, ?dim)

Parameters:
    sizes : seq<int> - List of sizes for each chunk
    ?dim : int - The dimension along which to split the tensor, defaults to 0.

Returns: Tensor[]

Splits the tensor into chunks. Each chunk is a view of the original tensor.

sizes : seq<int>

List of sizes for each chunk

?dim : int

The dimension along which to split the tensor, defaults to 0.

Returns: Tensor[]

this.sqrt ()

Full Usage: this.sqrt ()

Returns: Tensor

Returns a new tensor with the square-root of the elements of input.

Returns: Tensor

this.squeeze ?dim

Full Usage: this.squeeze ?dim

Parameters:
    ?dim : int - If given, the input will be squeezed only in this dimension.

Returns: Tensor

Returns a tensor with all the dimensions of input of size 1 removed.

If the tensor has a batch dimension of size 1, then squeeze(input) will also remove the batch dimension, which can lead to unexpected errors.

?dim : int

If given, the input will be squeezed only in this dimension.

Returns: Tensor

this.standardize ()

Full Usage: this.standardize ()

Returns: Tensor

Returns the tensor after standardization (z-score normalization)

Returns: Tensor

this.std ?unbiased

Full Usage: this.std ?unbiased

Parameters:
    ?unbiased : bool - Whether to use the unbiased estimation or not.

Returns: Tensor

Returns the standard deviation of all elements in the input tensor.

If unbiased is False, then the standard deviation will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.

?unbiased : bool

Whether to use the unbiased estimation or not.

Returns: Tensor

this.std (dim, ?keepDim, ?unbiased)

Full Usage: this.std (dim, ?keepDim, ?unbiased)

Parameters:
    dim : int - The dimension to reduce.
    ?keepDim : bool - Whether the output tensor has dim retained or not.
    ?unbiased : bool - Whether to use the unbiased estimation or not.

Returns: Tensor

Returns the standard deviation of each row of the input tensor in the given dimension dim.

If keepdim is True, the output tensor is of the same size as input except in the dimension dim where it is of size 1. Otherwise, dim is squeezed, resulting in the output tensor having 1 fewer dimension(s).

If unbiased is False, then the standard deviation will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.

dim : int

The dimension to reduce.

?keepDim : bool

Whether the output tensor has dim retained or not.

?unbiased : bool

Whether to use the unbiased estimation or not.

Returns: Tensor

this.sub b

Full Usage: this.sub b

Parameters:
Returns: Tensor

Subtracts the scalar b from the corresponding element of the object tensor. The resulting tensor is returned.

b : scalar
Returns: Tensor

this.sub b

Full Usage: this.sub b

Parameters:
Returns: Tensor

Subtracts each element of the object tensor from the corresponding element of the self tensor. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

b : Tensor
Returns: Tensor

this.sum (dim, ?keepDim, ?dtype)

Full Usage: this.sum (dim, ?keepDim, ?dtype)

Parameters:
    dim : int - The dimension to reduce.
    ?keepDim : bool - Whether the output tensor has dim retained or not.
    ?dtype : Dtype - The desired data type of returned tensor.

Returns: Tensor

Returns the sum of each row of the input tensor in the given dimension dim. If dim is a list of dimensions, reduce over all of them.

If keepdim is true, the output tensor is of the same size as input except in the dimension dim where it is of size 1. Otherwise, dim is squeezed, resulting in the output tensor having 1 fewer dimension.

dim : int

The dimension to reduce.

?keepDim : bool

Whether the output tensor has dim retained or not.

?dtype : Dtype

The desired data type of returned tensor.

Returns: Tensor

this.sum ?dtype

Full Usage: this.sum ?dtype

Parameters:
    ?dtype : Dtype - The desired data type of returned tensor.

Returns: Tensor

Returns the sum of all elements in the input tensor.

?dtype : Dtype

The desired data type of returned tensor.

Returns: Tensor

this.sumToSize (newShape, ?dtype)

Full Usage: this.sumToSize (newShape, ?dtype)

Parameters:
    newShape : int[]
    ?dtype : Dtype

Returns: Tensor

Sum this tensor to size newShape, which must be broadcastable to this tensor size.

newShape : int[]
?dtype : Dtype
Returns: Tensor

this.summary ()

Full Usage: this.summary ()

Returns: string

Returns a string summarising the tensor

Returns: string

this.tan ()

Full Usage: this.tan ()

Returns: Tensor

Returns a new tensor with the tangent of the elements of input

Returns: Tensor

this.tanh ()

Full Usage: this.tanh ()

Returns: Tensor

Returns a new tensor with the hyperbolic tangent of the elements of input.

Returns: Tensor

this.toArray ()

Full Usage: this.toArray ()

Returns: Array

Returns the value of a (non-scalar) tensor as an array

Returns: Array

this.toArray1D ()

Full Usage: this.toArray1D ()

Returns: 'T[]

Returns the value of a 1D tensor as a 1D array

Returns: 'T[]

this.toArray2D ()

Full Usage: this.toArray2D ()

Returns: 'T[,]

Returns the value of a 2D tensor as a 2D array

Returns: 'T[,]

this.toArray3D ()

Full Usage: this.toArray3D ()

Returns: 'T[,,]

Returns the value of a 3D tensor as a 3D array

Returns: 'T[,,]

this.toArray4D ()

Full Usage: this.toArray4D ()

Returns: 'T[,,,]

Returns the value of a 4D tensor as a 4D array

Returns: 'T[,,,]

this.toArray5D ()

Full Usage: this.toArray5D ()

Returns: Array

Returns the value of a 5D tensor as a 5D array

Returns: Array

this.toArray6D ()

Full Usage: this.toArray6D ()

Returns: Array

Returns the value of a 6D tensor as a 6D array

Returns: Array

this.toBool ()

Full Usage: this.toBool ()

Returns: bool

Convert a scalar tensor to a boolean value

Returns: bool

this.toByte ()

Full Usage: this.toByte ()

Returns: byte

Convert a scalar tensor to a byte value

Returns: byte

this.toDouble ()

Full Usage: this.toDouble ()

Returns: float

Convert a scalar tensor to a float64 value

Returns: float

this.toImage (?pixelMin, ?pixelMax, ?normalize, ?gridCols)

Full Usage: this.toImage (?pixelMin, ?pixelMax, ?normalize, ?gridCols)

Parameters:
    ?pixelMin : double
    ?pixelMax : double
    ?normalize : bool
    ?gridCols : int

Returns: Tensor

Convert tensor to an image tensor with shape Channels x Height x Width

?pixelMin : double
?pixelMax : double
?normalize : bool
?gridCols : int
Returns: Tensor

this.toImageString (?pixelMin, ?pixelMax, ?normalize, ?gridCols, ?asciiPalette)

Full Usage: this.toImageString (?pixelMin, ?pixelMax, ?normalize, ?gridCols, ?asciiPalette)

Parameters:
    ?pixelMin : double
    ?pixelMax : double
    ?normalize : bool
    ?gridCols : int
    ?asciiPalette : string

Returns: string

Convert tensor to a grayscale image tensor and return a string representation approximating grayscale values

?pixelMin : double
?pixelMax : double
?normalize : bool
?gridCols : int
?asciiPalette : string
Returns: string

this.toInt16 ()

Full Usage: this.toInt16 ()

Returns: int16

Convert a scalar tensor to an int16 value

Returns: int16

this.toInt32 ()

Full Usage: this.toInt32 ()

Returns: int

Convert a scalar tensor to an int32 value

Returns: int

this.toInt64 ()

Full Usage: this.toInt64 ()

Returns: int64

Convert a scalar tensor to an int64 value

Returns: int64

this.toSByte ()

Full Usage: this.toSByte ()

Returns: sbyte

Convert a scalar tensor to a signed byte value

Returns: sbyte

this.toScalar ()

Full Usage: this.toScalar ()

Returns: scalar

Returns the value of a scalar tensor as an object

Returns: scalar

this.toSingle ()

Full Usage: this.toSingle ()

Returns: float32

Convert a scalar tensor to a float32 value

Returns: float32

this.trace ()

Full Usage: this.trace ()

Returns: Tensor

Returns the sum of the elements of the diagonal of the input 2-D matrix.

Returns: Tensor

this.transpose ()

Full Usage: this.transpose ()

Returns: Tensor

Returns a tensor that is a transposed version of input with dimensions 0 and 1 swapped.

Returns: Tensor

this.transpose (dim0, dim1)

Full Usage: this.transpose (dim0, dim1)

Parameters:
    dim0 : int - The first dimension to be transposed.
    dim1 : int - The second dimension to be transposed.

Returns: Tensor

Returns a tensor that is a transposed version of input. The given dimensions dim0 and dim1 are swapped.

dim0 : int

The first dimension to be transposed.

dim1 : int

The second dimension to be transposed.

Returns: Tensor

this.undilate dilations

Full Usage: this.undilate dilations

Parameters:
    dilations : seq<int> - The dilations to use.

Returns: Tensor

Reverse the dilation of the tensor in using the given dilations in each corresponding dimension.

dilations : seq<int>

The dilations to use.

Returns: Tensor

this.unflatten (dim, unflattenedShape)

Full Usage: this.unflatten (dim, unflattenedShape)

Parameters:
    dim : int - The dimension to unflatten.
    unflattenedShape : seq<int> - New shape of the unflattened dimenension.

Returns: Tensor

Unflattens a tensor dimension by expanding it to the given shape.

dim : int

The dimension to unflatten.

unflattenedShape : seq<int>

New shape of the unflattened dimenension.

Returns: Tensor

this.unsqueeze dim

Full Usage: this.unsqueeze dim

Parameters:
    dim : int - The index at which to insert the singleton dimension.

Returns: Tensor

Returns a new tensor with a dimension of size one inserted at the specified position

dim : int

The index at which to insert the singleton dimension.

Returns: Tensor

this.unsqueezeAs other

Full Usage: this.unsqueezeAs other

Parameters:
    other : Tensor - The other tensor.

Returns: Tensor

Returns a new tensor with dimensions of size one appended to the end until the number of dimensions is the same as the other tensor.

other : Tensor

The other tensor.

Returns: Tensor

this.unstack ?dim

Full Usage: this.unstack ?dim

Parameters:
    ?dim : int - The dimension to remove, defaults to 0.

Returns: Tensor[] Returns an array of all slices along a given dimension.

Removes a tensor dimension.

?dim : int

The dimension to remove, defaults to 0.

Returns: Tensor[]

Returns an array of all slices along a given dimension.

this.var (dim, ?keepDim, ?unbiased)

Full Usage: this.var (dim, ?keepDim, ?unbiased)

Parameters:
    dim : int - The dimension to reduce.
    ?keepDim : bool - Whether the output tensor has dim retained or not.
    ?unbiased : bool - Whether to use the unbiased estimation or not.

Returns: Tensor

Returns the variance of each row of the input tensor in the given dimension dim.

If keepdim is True, the output tensor is of the same size as input except in the dimension dim where it is of size 1. Otherwise, dim is squeezed, resulting in the output tensor having 1 fewer dimension(s).

If unbiased is False, then the variance will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.

dim : int

The dimension to reduce.

?keepDim : bool

Whether the output tensor has dim retained or not.

?unbiased : bool

Whether to use the unbiased estimation or not.

Returns: Tensor

this.var ?unbiased

Full Usage: this.var ?unbiased

Parameters:
    ?unbiased : bool - Whether to use the unbiased estimation or not.

Returns: Tensor

Returns the variance of all elements in the input tensor.

If unbiased is False, then the variance will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.

?unbiased : bool

Whether to use the unbiased estimation or not.

Returns: Tensor

this.view shape

Full Usage: this.view shape

Parameters:
    shape : int - the desired shape

Returns: Tensor

Returns a new tensor with the same data as the object tensor but of a different shape.

The returned tensor shares the same data and must have the same number of elements, but may have a different size. For a tensor to be viewed, the new view size must be compatible with its original size and stride, i.e., each new view dimension must either be a subspace of an original dimension, or only span across original dimensions \(d, d+1, \dots, d+kd,d+1,…,d+k\) that satisfy the following contiguity-like condition that \(\forall i = d, \dots, d+k-1∀i=d,…,d+k−1 ,\) \[\text{stride}[i] = \text{stride}[i+1] \times \text{size}[i+1]\]

shape : int

the desired shape

Returns: Tensor

this.view shape

Full Usage: this.view shape

Parameters:
    shape : seq<int> - The desired shape of returned tensor.

Returns: Tensor

Returns a new tensor with the same data as the self tensor but of a different shape.

The returned tensor shares the same data and must have the same number of elements, but may have a different size. For a tensor to be viewed, the new view size must be compatible with its original size and stride, i.e., each new view dimension must either be a subspace of an original dimension, or only span across original dimensions \(d, d+1, \dots, d+kd,d+1,…,d+k\) that satisfy the following contiguity-like condition that \(\forall i = d, \dots, d+k-1∀i=d,…,d+k−1 ,\) \[\text{stride}[i] = \text{stride}[i+1] \times \text{size}[i+1]\]

shape : seq<int>

The desired shape of returned tensor.

Returns: Tensor

this.viewAs other

Full Usage: this.viewAs other

Parameters:
    other : Tensor - The result tensor has the same size as other.

Returns: Tensor

View this tensor as the same size as other.

The returned tensor shares the same data and must have the same number of elements, but may have a different size. For a tensor to be viewed, the new view size must be compatible with its original size. The returned tensor shares the same data and must have the same number of elements, but may have a different size. For a tensor to be viewed, the new view size must be compatible with its original size and stride, i.e., each new view dimension must either be a subspace of an original dimension, or only span across original dimensions \(d, d+1, \dots, d+kd,d+1,…,d+k\) that satisfy the following contiguity-like condition that \(\forall i = d, \dots, d+k-1∀i=d,…,d+k−1 ,\) \[\text{stride}[i] = \text{stride}[i+1] \times \text{size}[i+1]\]

other : Tensor

The result tensor has the same size as other.

Returns: Tensor

this.zeroLike (?device, ?dtype, ?backend)

Full Usage: this.zeroLike (?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a scalar '0' tensor for the given element type and configuration, defaulting to the element type and configuration of the input tensor.

?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

this.zerosLike (?shape, ?device, ?dtype, ?backend)

Full Usage: this.zerosLike (?shape, ?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a new tensor filled with '0' values for the given shape, element type and configuration, defaulting to the shape and configuration of the input tensor.

?shape : seq<int>
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

Static members

Static member Description

a * b

Full Usage: a * b

Parameters:
Returns: Tensor

Multiplies the scalar a by each element of the tensor b. The resulting tensor is returned.

a : scalar
b : Tensor
Returns: Tensor

a * b

Full Usage: a * b

Parameters:
Returns: Tensor

Multiplies each element of the tensor a by the scalar b. The resulting tensor is returned.

a : Tensor
b : scalar
Returns: Tensor

a * b

Full Usage: a * b

Parameters:
Returns: Tensor

Multiplies each element of the tensor a by the corresponding element of the tensor b. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

a : Tensor
b : Tensor
Returns: Tensor

a + b

Full Usage: a + b

Parameters:
Returns: Tensor

The scalar a is added to each element of the tensor b. The resulting tensor is returned.

a : scalar
b : Tensor
Returns: Tensor

a + b

Full Usage: a + b

Parameters:
Returns: Tensor

Each element of the tensor a is added to the scalar b. The resulting tensor is returned.

a : Tensor
b : scalar
Returns: Tensor

a + b

Full Usage: a + b

Parameters:
Returns: Tensor

Each element of the tensor a is added to each corresponding element of the tensor b. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

a : Tensor
b : Tensor
Returns: Tensor

a - b

Full Usage: a - b

Parameters:
Returns: Tensor

Subtracts each element of the tensore b from the scalar a. The resulting tensor is returned.

a : scalar
b : Tensor
Returns: Tensor

a - b

Full Usage: a - b

Parameters:
Returns: Tensor

Subtracts the scalar b from the corresponding element of the tensor a. The resulting tensor is returned.

a : Tensor
b : scalar
Returns: Tensor

a - b

Full Usage: a - b

Parameters:
Returns: Tensor

Subtracts each element of the tensor b from the corresponding element of the tensor a. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

a : Tensor
b : Tensor
Returns: Tensor

t --> f

Full Usage: t --> f

Parameters:
Returns: ^a
Modifiers: inline
Type parameters: ^a

Pipeline the tensor into a function.

t : Tensor
f : Tensor -> ^a
Returns: ^a

a / b

Full Usage: a / b

Parameters:
Returns: Tensor

Divides the scalar a by the each element of the tensor b. The resulting tensor is returned.

a : scalar
b : Tensor
Returns: Tensor

a / b

Full Usage: a / b

Parameters:
Returns: Tensor

Divides each element of the tensor a by the scalar b. The resulting tensor is returned.

a : Tensor
b : scalar
Returns: Tensor

a / b

Full Usage: a / b

Parameters:
Returns: Tensor

Divides each element of the tensor a by the corresponding element of the tensor b. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

a : Tensor
b : Tensor
Returns: Tensor

~-a

Full Usage: ~-a

Parameters:
Returns: Tensor

Returns a new tensor with the negative of the elements of a.

a : Tensor
Returns: Tensor

Tensor.Abs(a)

Full Usage: Tensor.Abs(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function abs.

a : Tensor
Returns: Tensor

Tensor.Acos(t)

Full Usage: Tensor.Acos(t)

Parameters:
Returns: Tensor

A method to enable the use of the F# function acos.

t : Tensor
Returns: Tensor

Tensor.Asin(t)

Full Usage: Tensor.Asin(t)

Parameters:
Returns: Tensor

A method to enable the use of the F# function asin.

t : Tensor
Returns: Tensor

Tensor.Atan(t)

Full Usage: Tensor.Atan(t)

Parameters:
Returns: Tensor

A method to enable the use of the F# function atan.

t : Tensor
Returns: Tensor

Tensor.Ceiling(a)

Full Usage: Tensor.Ceiling(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function ceil.

a : Tensor
Returns: Tensor

Tensor.Cos(a)

Full Usage: Tensor.Cos(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function cos.

a : Tensor
Returns: Tensor

Tensor.Cosh(t)

Full Usage: Tensor.Cosh(t)

Parameters:
Returns: Tensor

A method to enable the use of the F# function cosh.

t : Tensor
Returns: Tensor

Tensor.Exp(a)

Full Usage: Tensor.Exp(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function exp.

a : Tensor
Returns: Tensor

Tensor.Floor(a)

Full Usage: Tensor.Floor(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function floor.

a : Tensor
Returns: Tensor

Tensor.Log(a)

Full Usage: Tensor.Log(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function log.

a : Tensor
Returns: Tensor

Tensor.Log10(a)

Full Usage: Tensor.Log10(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function log10.

a : Tensor
Returns: Tensor

Tensor.One

Full Usage: Tensor.One

Returns: Tensor

Get the scalar one tensor for the current configuration

Returns: Tensor

Tensor.Op(ext)

Full Usage: Tensor.Op(ext)

Parameters:
    ext : BinaryOp - The definition of the new op.

Returns: Tensor * Tensor -> Tensor The new op.

Allows the definition of a new binary tensor op.

ext : BinaryOp

The definition of the new op.

Returns: Tensor * Tensor -> Tensor

The new op.

Tensor.Op(ext)

Full Usage: Tensor.Op(ext)

Parameters:
    ext : UnaryOp - The definition of the new op.

Returns: Tensor -> Tensor The new op.

Allows the definition of a new unary tensor op.

ext : UnaryOp

The definition of the new op.

Returns: Tensor -> Tensor

The new op.

Tensor.Pow(a, b)

Full Usage: Tensor.Pow(a, b)

Parameters:
Returns: Tensor

Raises the scalar a to the power of each element of the tensor b. The resulting tensor is returned.

a : int
b : Tensor
Returns: Tensor

Tensor.Pow(a, b)

Full Usage: Tensor.Pow(a, b)

Parameters:
Returns: Tensor

Raises the scalar a to the power of each element of the tensor b. The resulting tensor is returned.

a : float
b : Tensor
Returns: Tensor

Tensor.Pow(a, b)

Full Usage: Tensor.Pow(a, b)

Parameters:
Returns: Tensor

Raises the scalar a to the power of each element of the tensor b. The resulting tensor is returned.

a : scalar
b : Tensor
Returns: Tensor

Tensor.Pow(a, b)

Full Usage: Tensor.Pow(a, b)

Parameters:
Returns: Tensor

Raises each element of the tensor a to the power of the scalar b. The resulting tensor is returned.

a : Tensor
b : int
Returns: Tensor

Tensor.Pow(a, b)

Full Usage: Tensor.Pow(a, b)

Parameters:
Returns: Tensor

Raises each element of the tensor a to the power of the scalar b. The resulting tensor is returned.

a : Tensor
b : float
Returns: Tensor

Tensor.Pow(a, b)

Full Usage: Tensor.Pow(a, b)

Parameters:
Returns: Tensor

Raises each element of the tensor a to the power of the scalar b. The resulting tensor is returned.

a : Tensor
b : scalar
Returns: Tensor

Tensor.Pow(a, b)

Full Usage: Tensor.Pow(a, b)

Parameters:
Returns: Tensor

Raises each element of the tensor a to the power of the corresponding element of the tensor b. The resulting tensor is returned.

The shapes of the two tensors must be broadcastable.

a : Tensor
b : Tensor
Returns: Tensor

Tensor.Round(a)

Full Usage: Tensor.Round(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function round.

a : Tensor
Returns: Tensor

Tensor.Sin(a)

Full Usage: Tensor.Sin(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function sin.

a : Tensor
Returns: Tensor

Tensor.Sinh(a)

Full Usage: Tensor.Sinh(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function sinh.

a : Tensor
Returns: Tensor

Tensor.Sqrt(a)

Full Usage: Tensor.Sqrt(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function sqrt.

a : Tensor
Returns: Tensor

Tensor.Tan(a)

Full Usage: Tensor.Tan(a)

Parameters:
Returns: Tensor

A method to enable the use of the F# function tan.

a : Tensor
Returns: Tensor

Tensor.Tanh(t)

Full Usage: Tensor.Tanh(t)

Parameters:
Returns: Tensor

A method to enable the use of the F# function tanh.

t : Tensor
Returns: Tensor

Tensor.Zero

Full Usage: Tensor.Zero

Returns: Tensor

Get the scalar zero tensor for the current configuration

Returns: Tensor

Tensor.cat (tensors, ?dim)

Full Usage: Tensor.cat (tensors, ?dim)

Parameters:
    tensors : seq<Tensor> - The tensors to concatenate.
    ?dim : int - The dimension over which the tensors are concatenated, defaults to 0.

Returns: Tensor

Concatenates the given sequence of seq tensors in the given dimension.

All tensors must either have the same shape (except in the concatenating dimension) or be empty.

tensors : seq<Tensor>

The tensors to concatenate.

?dim : int

The dimension over which the tensors are concatenated, defaults to 0.

Returns: Tensor

Tensor.create (value, ?device, ?dtype, ?backend)

Full Usage: Tensor.create (value, ?device, ?dtype, ?backend)

Parameters:
    value : obj - The .NET object used to form the initial values for the tensor.
    ?device : Device - The desired device of returned tensor. Default: if None, uses Device.Default.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, uses Dtype.Default.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, uses Backend.Default.

Returns: Tensor

Creates a new tensor from the given data, using the given element type and configuration.

The fastest creation technique is a one dimensional array matching the desired dtype. Then use 'view' to reshape.

value : obj

The .NET object used to form the initial values for the tensor.

?device : Device

The desired device of returned tensor. Default: if None, uses Device.Default.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, uses Dtype.Default.

?backend : Backend

The desired backend of returned tensor. Default: if None, uses Backend.Default.

Returns: Tensor

Tensor.eye (rows, ?cols, ?device, ?dtype, ?backend)

Full Usage: Tensor.eye (rows, ?cols, ?device, ?dtype, ?backend)

Parameters:
Returns: Tensor

Returns a 2-D tensor with ones on the diagonal and zeros elsewhere.

rows : int
?cols : int
?device : Device
?dtype : Dtype
?backend : Backend
Returns: Tensor

Tensor.load (fileName, ?device, ?dtype, ?backend)

Full Usage: Tensor.load (fileName, ?device, ?dtype, ?backend)

Parameters:
    fileName : string - The file from which to load the tensor.
    ?device : Device - The device of the resulting tensor. Defaults to the current default device.
    ?dtype : Dtype - The element type of the resulting tensor. Defaults to the element type of the saved tensor.
    ?backend : Backend - The device of the resulting tensor. Defaults to the current default backend.

Returns: Tensor

Loads the tensor from the given file using the given element type and configuration.

The backend at the time of saving the tensor must be available when the tensor is reloaded. The tensor is first loaded into that backend and then moved. As a result, intermediate tensors may be created in the process of reloading.

fileName : string

The file from which to load the tensor.

?device : Device

The device of the resulting tensor. Defaults to the current default device.

?dtype : Dtype

The element type of the resulting tensor. Defaults to the element type of the saved tensor.

?backend : Backend

The device of the resulting tensor. Defaults to the current default backend.

Returns: Tensor

Tensor.ofRawTensor rawTensor

Full Usage: Tensor.ofRawTensor rawTensor

Parameters:
    rawTensor : RawTensor - The given raw tensor.

Returns: Tensor

Creates a new tensor from the raw tensor.

rawTensor : RawTensor

The given raw tensor.

Returns: Tensor

op_Explicittensor

Full Usage: op_Explicittensor

Parameters:
Returns: bool

Convert a scalar tensor to a float32 value

tensor : Tensor
Returns: bool

op_Explicittensor

Full Usage: op_Explicittensor

Parameters:
Returns: int64

Convert a scalar tensor to a float32 value

tensor : Tensor
Returns: int64

op_Explicittensor

Full Usage: op_Explicittensor

Parameters:
Returns: int32

Convert a scalar tensor to a float32 value

tensor : Tensor
Returns: int32

op_Explicittensor

Full Usage: op_Explicittensor

Parameters:
Returns: int16

Convert a scalar tensor to a float32 value

tensor : Tensor
Returns: int16

op_Explicittensor

Full Usage: op_Explicittensor

Parameters:
Returns: int8

Convert a scalar tensor to a float32 value

tensor : Tensor
Returns: int8

op_Explicittensor

Full Usage: op_Explicittensor

Parameters:
Returns: byte

Convert a scalar tensor to a float32 value

tensor : Tensor
Returns: byte

op_Explicittensor

Full Usage: op_Explicittensor

Parameters:
Returns: double

Convert a scalar tensor to a float32 value

tensor : Tensor
Returns: double

op_Explicittensor

Full Usage: op_Explicittensor

Parameters:
Returns: single

Convert a scalar tensor to a float32 value

tensor : Tensor
Returns: single

Tensor.stack (tensors, ?dim)

Full Usage: Tensor.stack (tensors, ?dim)

Parameters:
    tensors : seq<Tensor> - sequence of tensors to concatenate
    ?dim : int - dimension to insert. Has to be between 0 and the number of dimensions of concatenated tensors (inclusive)

Returns: Tensor

Concatenates sequence of tensors along a new dimension.

All tensors need to be of the same shape.

tensors : seq<Tensor>

sequence of tensors to concatenate

?dim : int

dimension to insert. Has to be between 0 and the number of dimensions of concatenated tensors (inclusive)

Returns: Tensor

© Copyright 2021, DiffSharp Contributors.