dsharp Type

Tensor operations

Static members

Static member Description

dsharp.abs input

Full Usage: dsharp.abs input

Parameters:
Returns: Tensor

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

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

input : Tensor
Returns: Tensor

dsharp.acos input

Full Usage: dsharp.acos input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.add (a, b)

Full Usage: dsharp.add (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Return the element-wise addition of the two tensors.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.arange (endVal, ?startVal, ?step, ?device, ?dtype, ?backend)

Full Usage: dsharp.arange (endVal, ?startVal, ?step, ?device, ?dtype, ?backend)

Parameters:
    endVal : int - The ending value for the set of points.
    ?startVal : int - The starting value for the set of points. Default: 0.
    ?step : int - The gap between each pair of adjacent points. Default: 1.
    ?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 1-D tensor of size \(\left\lceil \frac{\text{end} - \text{start}}{\text{step}} \right\rceil\) with values from the interval [start, end) taken with common difference step beginning from start.

endVal : int

The ending value for the set of points.

?startVal : int

The starting value for the set of points. Default: 0.

?step : int

The gap between each pair of adjacent points. Default: 1.

?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

dsharp.arange (endVal, ?startVal, ?step, ?device, ?dtype, ?backend)

Full Usage: dsharp.arange (endVal, ?startVal, ?step, ?device, ?dtype, ?backend)

Parameters:
    endVal : float - The ending value for the set of points.
    ?startVal : float - The starting value for the set of points. Default: 0.
    ?step : float - The gap between each pair of adjacent points. Default: 1.
    ?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 1-D tensor of size \(\left\lceil \frac{\text{end} - \text{start}}{\text{step}} \right\rceil\) with values from the interval [start, end) taken with common difference step beginning from start.

Non-integer steps may be subject to floating point rounding errors when comparing against end.

endVal : float

The ending value for the set of points.

?startVal : float

The starting value for the set of points. Default: 0.

?step : float

The gap between each pair of adjacent points. Default: 1.

?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

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

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    endVal : int - The ending value for the set of points.
    ?startVal : int - The starting value for the set of points. Default: 0.
    ?step : int - The gap between each pair of adjacent points. Default: 1.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

A version of dsharp.arange with characteristics based on the input tensor.

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

endVal : int

The ending value for the set of points.

?startVal : int

The starting value for the set of points. Default: 0.

?step : int

The gap between each pair of adjacent points. Default: 1.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

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

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    endVal : float - The ending value for the set of points.
    ?startVal : float - The starting value for the set of points. Default: 0.
    ?step : float - The gap between each pair of adjacent points. Default: 1.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

A version of dsharp.arange with characteristics based on the input tensor.

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

endVal : float

The ending value for the set of points.

?startVal : float

The starting value for the set of points. Default: 0.

?step : float

The gap between each pair of adjacent points. Default: 1.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

dsharp.argmax (input, dim, ?keepDim)

Full Usage: dsharp.argmax (input, dim, ?keepDim)

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

Returns: Tensor

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

input : Tensor

The input tensor.

dim : int

The dimension.

?keepDim : bool

Whether the output tensor has dim retained or not.

Returns: Tensor

dsharp.argmax input

Full Usage: dsharp.argmax input

Parameters:
    input : Tensor - The input tensor.

Returns: int[]

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

input : Tensor

The input tensor.

Returns: int[]

dsharp.argmin (input, dim, ?keepDim)

Full Usage: dsharp.argmin (input, dim, ?keepDim)

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

Returns: Tensor

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

input : Tensor

The input tensor.

dim : int

The dimension.

?keepDim : bool

Whether the output tensor has dim retained or not.

Returns: Tensor

dsharp.argmin input

Full Usage: dsharp.argmin input

Parameters:
    input : Tensor - The input tensor.

Returns: int[]

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

input : Tensor

The input tensor.

Returns: int[]

dsharp.asin input

Full Usage: dsharp.asin input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.atan input

Full Usage: dsharp.atan input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.backends ()

Full Usage: dsharp.backends ()

Returns: Backend list

Returns the list of available backends.

Returns: Backend list

dsharp.backendsAndDevices ()

Full Usage: dsharp.backendsAndDevices ()

Returns: (Backend * Device list) list

Returns the list of available backends and devices available for each backend.

Returns: (Backend * Device list) list

dsharp.bceLoss (input, target, ?weight, ?reduction)

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

Parameters:
    input : Tensor - The input tensor.
    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

input : Tensor

The input tensor.

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

dsharp.bernoulli (probs, ?device, ?dtype, ?backend)

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

Parameters:
    probs : Tensor - The input tensor of probability values for the 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

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

probs : Tensor

The input tensor of probability values for the 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

dsharp.cast (input, dtype)

Full Usage: dsharp.cast (input, dtype)

Parameters:
    input : Tensor - The input tensor.
    dtype : Dtype - The desired element type of returned tensor.

Returns: Tensor

Convert the tensor to one with the given element type.

If the element type is unchanged the input tensor will be returned.

input : Tensor

The input tensor.

dtype : Dtype

The desired element type of returned tensor.

Returns: Tensor

dsharp.cat (tensors, ?dim)

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

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

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 sequence of tensors to concatenate.

?dim : int

The the dimension over which the tensors are concatenated.

Returns: Tensor

dsharp.ceil input

Full Usage: dsharp.ceil input

Parameters:
    input : Tensor - The input tensor.

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.

input : Tensor

The input tensor.

Returns: Tensor

dsharp.clamp (input, ?low, ?high)

Full Usage: dsharp.clamp (input, ?low, ?high)

Parameters:
    input : Tensor - The input 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

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

input : Tensor

The input 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

dsharp.clone input

Full Usage: dsharp.clone input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

Returns a new tensor with the same characteristics and storage cloned.

input : Tensor

The input tensor.

Returns: Tensor

dsharp.config configuration

Full Usage: dsharp.config configuration

Parameters:
    configuration : Device * Dtype * Backend * Printer - A tuple of the new default device, default element type, default backend, and default printer.

Configure the default device, element type, backend, printer. Only floating point dtypes are supported as the default.

configuration : Device * Dtype * Backend * Printer

A tuple of the new default device, default element type, default backend, and default printer.

dsharp.config ()

Full Usage: dsharp.config ()

Returns: Device * Dtype * Backend * Printer

Return the current default device, element type, backend, and printer.

Returns: Device * Dtype * Backend * Printer

dsharp.config (?device, ?dtype, ?backend, ?printer)

Full Usage: dsharp.config (?device, ?dtype, ?backend, ?printer)

Parameters:
    ?device : Device - The new default device.
    ?dtype : Dtype - The new default element type. Only floating point dtypes are supported as the default.
    ?backend : Backend - The new default backend.
    ?printer : Printer - The new default printer.

Configure the default device, dtype, and/or backend.

?device : Device

The new default device.

?dtype : Dtype

The new default element type. Only floating point dtypes are supported as the default.

?backend : Backend

The new default backend.

?printer : Printer

The new default printer.

dsharp.conv1d (input, filters, ?stride, ?padding, ?dilation)

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

Parameters:
    input : Tensor - The input tensor.
    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

input : Tensor

The input tensor.

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

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

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

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

Returns: Tensor

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

input : Tensor

The input tensor.

filters : Tensor

The filters.

?stride : int

The stride of the convolving kernel.

?strides : seq<int>

The strides of the convolving kernel.

?padding : int

The implicit padding on corresponding sides of the input.

?paddings : seq<int>

The implicit paddings on corresponding sides of the input.

?dilation : int

The spacing between kernel elements.

?dilations : seq<int>

The spacings between kernel elements.

Returns: Tensor

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

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

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

Returns: Tensor

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

input : Tensor

The input tensor.

filters : Tensor

The filters.

?stride : int

The stride of the convolving kernel.

?strides : seq<int>

The strides of the convolving kernel.

?padding : int

The implicit padding on corresponding sides of the input.

?paddings : seq<int>

The implicit paddings on corresponding sides of the input.

?dilation : int

The spacing between kernel elements.

?dilations : seq<int>

The spacings between kernel elements.

Returns: Tensor

dsharp.convTranspose1d (input, filters, ?stride, ?padding, ?dilation, ?outputPadding)

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

Parameters:
    input : Tensor - The input tensor.
    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'.

input : Tensor

The input tensor.

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

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

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

Parameters:
    input : Tensor - The input tensor.
    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'.

input : Tensor

The input tensor.

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

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

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

Parameters:
    input : Tensor - The input tensor.
    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'.

input : Tensor

The input tensor.

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

dsharp.corrcoef input

Full Usage: dsharp.corrcoef input

Parameters:
    input : Tensor - The input tensor.

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.

input : Tensor

The input tensor.

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])
 dsharp.corrcoef(xy)
Evaluates to
 tensor([[1.0000, 0.3582],
         [0.3582, 1.0000]])

dsharp.cos input

Full Usage: dsharp.cos input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.cosh input

Full Usage: dsharp.cosh input

Parameters:
Returns: Tensor

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

input : Tensor
Returns: Tensor

dsharp.cov (input, ?correction, ?fweights, ?aweights)

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

Parameters:
    input : Tensor - The input tensor.
    ?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}\)

input : Tensor

The input tensor.

?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]])

dsharp.create count value

Full Usage: dsharp.create count value

Parameters:
    count : int - The number of elements in the tensor.
    value : 'a - The initial value for each element of the tensor.

Returns: Tensor

Create a new 1D tensor using the given value for each element.

count : int

The number of elements in the tensor.

value : 'a

The initial value for each element of the tensor.

Returns: Tensor

dsharp.crossEntropyLoss (input, target, ?weight, ?reduction)

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

Parameters:
    input : Tensor - The input tensor.
    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

input : Tensor

The input tensor.

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

dsharp.curl f x

Full Usage: dsharp.curl f x

Parameters:
Returns: Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor

dsharp.curldivergence f x

Full Usage: dsharp.curldivergence f x

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor

dsharp.derivative tensor

Full Usage: dsharp.derivative tensor

Parameters:
Returns: Tensor

Get the derivative value of the tensor.

tensor : Tensor
Returns: Tensor

dsharp.devices (?backend, ?deviceType)

Full Usage: dsharp.devices (?backend, ?deviceType)

Parameters:
    ?backend : Backend - Return information for this backend. Defaults to Backend.Default.
    ?deviceType : DeviceType - If given, only return devices for this device type.

Returns: Device list

Returns the list of available devices for a given backend.

?backend : Backend

Return information for this backend. Defaults to Backend.Default.

?deviceType : DeviceType

If given, only return devices for this device type.

Returns: Device list

dsharp.diagonal (input, ?offset, ?dim1, ?dim2)

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

Parameters:
    input : Tensor - The input tensor. Must be at least 2-dimensional.
    ?offset : int - Which diagonal to consider. Default: 0.
    ?dim1 : int - The first dimension with respect to which to take diagonal. Default: 0..
    ?dim2 : int - The second dimension with respect to which to take diagonal. Default: 1.

Returns: Tensor

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

input : Tensor

The input tensor. Must be at least 2-dimensional.

?offset : int

Which diagonal to consider. Default: 0.

?dim1 : int

The first dimension with respect to which to take diagonal. Default: 0..

?dim2 : int

The second dimension with respect to which to take diagonal. Default: 1.

Returns: Tensor

dsharp.diff f x

Full Usage: dsharp.diff f x

Parameters:
Returns: Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor

dsharp.diff2 f x

Full Usage: dsharp.diff2 f x

Parameters:
Returns: Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor

dsharp.diffn n f x

Full Usage: dsharp.diffn n f x

Parameters:
Returns: Tensor

TBD

n : int
f : Tensor -> Tensor
x : Tensor
Returns: Tensor

dsharp.dilate (input, dilations)

Full Usage: dsharp.dilate (input, dilations)

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

Returns: Tensor

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

input : Tensor

The input tensor.

dilations : seq<int>

The dilations to use.

Returns: Tensor

dsharp.div (a, b)

Full Usage: dsharp.div (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Return the element-wise division of the two tensors.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.divergence f x

Full Usage: dsharp.divergence f x

Parameters:
Returns: Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor

dsharp.dot (a, b)

Full Usage: dsharp.dot (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Computes the dot product (inner product) of two tensors.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.dropout (input, ?p)

Full Usage: dsharp.dropout (input, ?p)

Parameters:
    input : Tensor - The input tensor.
    ?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

input : Tensor

The input tensor.

?p : double

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

Returns: Tensor

dsharp.dropout2d (input, ?p)

Full Usage: dsharp.dropout2d (input, ?p)

Parameters:
    input : Tensor - The input tensor.
    ?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

input : Tensor

The input tensor.

?p : double

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

Returns: Tensor

dsharp.dropout3d (input, ?p)

Full Usage: dsharp.dropout3d (input, ?p)

Parameters:
    input : Tensor - The input tensor.
    ?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.

input : Tensor

The input tensor.

?p : double

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

Returns: Tensor

dsharp.empty (?device, ?dtype, ?backend)

Full Usage: dsharp.empty (?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

Returns a new empty tensor holding no data, for the given element type and configuration

?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

dsharp.empty (length, ?device, ?dtype, ?backend)

Full Usage: dsharp.empty (length, ?device, ?dtype, ?backend)

Parameters:
    length : int - The length of the returned 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

Returns a new uninitialized tensor filled with arbitrary values for the given length, element type and configuration

length : int

The length of the returned 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

dsharp.empty (shape, ?device, ?dtype, ?backend)

Full Usage: dsharp.empty (shape, ?device, ?dtype, ?backend)

Parameters:
    shape : seq<int> - The desired shape of returned 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

Returns a new uninitialized tensor filled with arbitrary values for the given shape, element type and configuration

shape : seq<int>

The desired shape of returned 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

dsharp.eq (a, b)

Full Usage: dsharp.eq (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Returns a boolean tensor for the element-wise equality comparison of the elements in the two tensors.

The shapes of input and other don’t need to match, but they must be broadcastable.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.evalForwardDiff f x v

Full Usage: dsharp.evalForwardDiff f x v

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
v : Tensor
Returns: Tensor * Tensor

dsharp.evalForwardDiffs f x v

Full Usage: dsharp.evalForwardDiffs f x v

Parameters:
Returns: Tensor[]

TBD

f : Tensor -> Tensor
x : Tensor
v : Tensor[]
Returns: Tensor[]

dsharp.evalReverseDiff f x

Full Usage: dsharp.evalReverseDiff f x

Parameters:
Returns: Tensor * (Tensor -> Tensor)

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * (Tensor -> Tensor)

dsharp.exp input

Full Usage: dsharp.exp input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

Applies the exp function element-wise.

input : Tensor

The input tensor.

Returns: Tensor

dsharp.expand (input, shape)

Full Usage: dsharp.expand (input, shape)

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

Returns: Tensor

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

input : Tensor

The input tensor.

shape : seq<int>

The desired shape of returned tensor.

Returns: Tensor

dsharp.expandAs (input, other)

Full Usage: dsharp.expandAs (input, other)

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

Returns: Tensor

Expand the input tensor to the same size as other tensor

input : Tensor

The input tensor.

other : Tensor

The result tensor has the same size as other.

Returns: Tensor

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

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

Parameters:
    rows : int - The number of rows
    ?cols : int - The number of columns with default being n
    ?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 2-D tensor with ones on the diagonal and zeros elsewhere.

rows : int

The number of rows

?cols : int

The number of columns with default being n

?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

dsharp.fcurl f x

Full Usage: dsharp.fcurl f x

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor

dsharp.fcurldivergence f x

Full Usage: dsharp.fcurldivergence f x

Parameters:
Returns: Tensor * Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor * Tensor

dsharp.fdiff f x

Full Usage: dsharp.fdiff f x

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor

dsharp.fdiff2 f x

Full Usage: dsharp.fdiff2 f x

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor

dsharp.fdiffn n f x

Full Usage: dsharp.fdiffn n f x

Parameters:
Returns: Tensor * Tensor

TBD

n : int
f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor

dsharp.fdivergence f x

Full Usage: dsharp.fdivergence f x

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor

dsharp.ffdiffn n f x

Full Usage: dsharp.ffdiffn n f x

Parameters:
Returns: Tensor[]

TBD

n : int
f : Tensor -> Tensor
x : Tensor
Returns: Tensor[]

dsharp.fgrad f x

Full Usage: dsharp.fgrad f x

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor

dsharp.fgradhessian f x

Full Usage: dsharp.fgradhessian f x

Parameters:
Returns: Tensor * Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor * Tensor

dsharp.fgradhessianv f x v

Full Usage: dsharp.fgradhessianv f x v

Parameters:
Returns: Tensor * Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
v : Tensor
Returns: Tensor * Tensor * Tensor

dsharp.fgradv f x v

Full Usage: dsharp.fgradv f x v

Parameters:
Returns: Tensor * Tensor

TBD

The x and v tensors should have the same number of elements.

f : Tensor -> Tensor

TBD

x : Tensor

TBD

v : Tensor

TBD

Returns: Tensor * Tensor

dsharp.fhessian f x

Full Usage: dsharp.fhessian f x

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor

dsharp.fhessianv f x v

Full Usage: dsharp.fhessianv f x v

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
v : Tensor
Returns: Tensor * Tensor

dsharp.fjacobian f x

Full Usage: dsharp.fjacobian f x

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor

dsharp.fjacobianTv f x v

Full Usage: dsharp.fjacobianTv f x v

Parameters:
    f : Tensor -> Tensor - vector-to-vector function
    x : Tensor - Point at which the function f will be evaluated, it must have a single dimension.
    v : Tensor - Vector

Returns: Tensor * Tensor

Original value and transposed Jacobian-vector product of a vector-to-vector function `f`, at point `x`, along vector `v`

f : Tensor -> Tensor

vector-to-vector function

x : Tensor

Point at which the function f will be evaluated, it must have a single dimension.

v : Tensor

Vector

Returns: Tensor * Tensor

dsharp.fjacobianv f x v

Full Usage: dsharp.fjacobianv f x v

Parameters:
Returns: Tensor * Tensor

TBD

The x and v tensors should have the same number of elements.

f : Tensor -> Tensor

TBD

x : Tensor

TBD

v : Tensor

TBD

Returns: Tensor * Tensor

dsharp.flaplacian f x

Full Usage: dsharp.flaplacian f x

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor

dsharp.flatten (input, ?startDim, ?endDim)

Full Usage: dsharp.flatten (input, ?startDim, ?endDim)

Parameters:
    input : Tensor - The input tensor.
    ?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.

input : Tensor

The input tensor.

?startDim : int

The first dim to flatten.

?endDim : int

The last dim to flatten.

Returns: Tensor

dsharp.flip (input, dims)

Full Usage: dsharp.flip (input, dims)

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

Returns: Tensor

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

input : Tensor

The input tensor.

dims : seq<int>

The axis to flip on.

Returns: Tensor

dsharp.floor input

Full Usage: dsharp.floor input

Parameters:
    input : Tensor - The input tensor.

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.

input : Tensor

The input tensor.

Returns: Tensor

dsharp.forwardDiff nestingTag derivative tensor

Full Usage: dsharp.forwardDiff nestingTag derivative tensor

Parameters:
    nestingTag : uint32 - The level tag.
    derivative : Tensor - The derivative of the input.
    tensor : Tensor - The input.

Returns: Tensor

Produce a new tensor suitable for calculating the forward-mode derivative at the given level tag.

nestingTag : uint32

The level tag.

derivative : Tensor

The derivative of the input.

tensor : Tensor

The input.

Returns: Tensor

dsharp.full (length, value, ?device, ?dtype, ?backend)

Full Usage: dsharp.full (length, value, ?device, ?dtype, ?backend)

Parameters:
    length : int - The length of the returned tensor.
    value : scalar - The scalar giving the 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

Returns a new tensor of the given length filled with value, for the given element type and configuration

length : int

The length of the returned tensor.

value : scalar

The scalar giving the 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

dsharp.full (shape, value, ?device, ?dtype, ?backend)

Full Usage: dsharp.full (shape, value, ?device, ?dtype, ?backend)

Parameters:
    shape : seq<int> - The desired shape of returned tensor.
    value : scalar - The scalar 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

Returns a new tensor filled with the scalar value, for the given shape, element type and configuration

shape : seq<int>

The desired shape of returned tensor.

value : scalar

The scalar 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

dsharp.fullLike (input, value, ?shape, ?device, ?dtype, ?backend)

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    value : scalar - The scalar giving the the initial values for the tensor.
    ?shape : seq<int> - The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

Returns a new tensor filled with the given scalar value with characteristics based on the input tensor.

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

value : scalar

The scalar giving the the initial values for the tensor.

?shape : seq<int>

The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

dsharp.gather (input, dim, indices)

Full Usage: dsharp.gather (input, dim, indices)

Parameters:
    input : Tensor - The input tensor.
    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.

input : Tensor

The input tensor.

dim : int

The axis along which to index.

indices : Tensor

The the indices of elements to gather.

Returns: Tensor

dsharp.ge (a, b)

Full Usage: dsharp.ge (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Returns a boolean tensor for the element-wise greater-than-or-equal comparison of the elements in the two tensors.

The shapes of input and other don’t need to match, but they must be broadcastable.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.grad f x

Full Usage: dsharp.grad f x

Parameters:
Returns: Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor

dsharp.gradhessian f x

Full Usage: dsharp.gradhessian f x

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor * Tensor

dsharp.gradhessianv f x v

Full Usage: dsharp.gradhessianv f x v

Parameters:
Returns: Tensor * Tensor

TBD

f : Tensor -> Tensor
x : Tensor
v : Tensor
Returns: Tensor * Tensor

dsharp.gradv f x v

Full Usage: dsharp.gradv f x v

Parameters:
Returns: Tensor

TBD

f : Tensor -> Tensor
x : Tensor
v : Tensor
Returns: Tensor

dsharp.gt (a, b)

Full Usage: dsharp.gt (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Returns a boolean tensor for the element-wise greater-than comparison of the elements in the two tensors.

The shapes of input and other don’t need to match, but they must be broadcastable.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.hasinf input

Full Usage: dsharp.hasinf input

Parameters:
    input : Tensor - The input tensor.

Returns: bool

Returns a boolean indicating if any element of the tensor is infinite.

input : Tensor

The input tensor.

Returns: bool

dsharp.hasnan input

Full Usage: dsharp.hasnan input

Parameters:
    input : Tensor - The input tensor.

Returns: bool

Returns a boolean indicating if any element of the tensor is a not-a-number (NaN) value.

input : Tensor

The input tensor.

Returns: bool

dsharp.hessian f x

Full Usage: dsharp.hessian f x

Parameters:
Returns: Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor

dsharp.hessianv f x v

Full Usage: dsharp.hessianv f x v

Parameters:
Returns: Tensor

TBD

f : Tensor -> Tensor
x : Tensor
v : Tensor
Returns: Tensor

dsharp.init count initializer

Full Usage: dsharp.init count initializer

Parameters:
    count : int - The length of the tensor.
    initializer : int -> 'a - The function used to initialize each element.

Returns: Tensor

Create a new 1D tensor using the given initializer for each element.

count : int

The length of the tensor.

initializer : int -> 'a

The function used to initialize each element.

Returns: Tensor

dsharp.init2d length1 length2 initializer

Full Usage: dsharp.init2d length1 length2 initializer

Parameters:
    length1 : int - The length of the tensor in the first dimension.
    length2 : int - The length of the tensor in the second dimension.
    initializer : int -> int -> 'a - The function used to initialize each element.

Returns: Tensor

Create a new 2D tensor using the given initializer for each element.

length1 : int

The length of the tensor in the first dimension.

length2 : int

The length of the tensor in the second dimension.

initializer : int -> int -> 'a

The function used to initialize each element.

Returns: Tensor

dsharp.init3d length1 length2 length3 initializer

Full Usage: dsharp.init3d length1 length2 length3 initializer

Parameters:
    length1 : int - The length of the tensor in the 1st dimension.
    length2 : int - The length of the tensor in the 2nd dimension.
    length3 : int - The length of the tensor in the 3rd dimension.
    initializer : int -> int -> int -> 'a - The function used to initialize each element.

Returns: Tensor

Create a new 3D tensor using the given initializer for each element.

length1 : int

The length of the tensor in the 1st dimension.

length2 : int

The length of the tensor in the 2nd dimension.

length3 : int

The length of the tensor in the 3rd dimension.

initializer : int -> int -> int -> 'a

The function used to initialize each element.

Returns: Tensor

dsharp.init4d length1 length2 length3 length4 initializer

Full Usage: dsharp.init4d length1 length2 length3 length4 initializer

Parameters:
    length1 : int - The length of the tensor in the 1st dimension.
    length2 : int - The length of the tensor in the 2nd dimension.
    length3 : int - The length of the tensor in the 3rd dimension.
    length4 : int - The length of the tensor in the 4th dimension.
    initializer : int -> int -> int -> int -> 'a - The function used to initialize each element.

Returns: Tensor

Create a new 4D tensor using the given initializer for each element.

length1 : int

The length of the tensor in the 1st dimension.

length2 : int

The length of the tensor in the 2nd dimension.

length3 : int

The length of the tensor in the 3rd dimension.

length4 : int

The length of the tensor in the 4th dimension.

initializer : int -> int -> int -> int -> 'a

The function used to initialize each element.

Returns: Tensor

dsharp.isBackendAvailable backend

Full Usage: dsharp.isBackendAvailable backend

Parameters:
Returns: bool

Indicates if a given backend is available.

backend : Backend
Returns: bool

dsharp.isCudaAvailable ?backend

Full Usage: dsharp.isCudaAvailable ?backend

Parameters:
    ?backend : Backend - Return information for this backend. Defaults to Backend.Default.

Returns: bool

Indicates if CUDA is available for a given backend.

?backend : Backend

Return information for this backend. Defaults to Backend.Default.

Returns: bool

dsharp.isDeviceAvailable (device, ?backend)

Full Usage: dsharp.isDeviceAvailable (device, ?backend)

Parameters:
    device : Device - The requested device.
    ?backend : Backend - Return information for this backend. Defaults to Backend.Default.

Returns: bool

Indicates if a given device is available for a given backend.

device : Device

The requested device.

?backend : Backend

Return information for this backend. Defaults to Backend.Default.

Returns: bool

dsharp.isDeviceTypeAvailable (deviceType, ?backend)

Full Usage: dsharp.isDeviceTypeAvailable (deviceType, ?backend)

Parameters:
    deviceType : DeviceType - The requested device type.
    ?backend : Backend - Return information for this backend. Defaults to Backend.Default.

Returns: bool

Indicates if a given device type is available for a given backend.

deviceType : DeviceType

The requested device type.

?backend : Backend

Return information for this backend. Defaults to Backend.Default.

Returns: bool

dsharp.isTensor value

Full Usage: dsharp.isTensor value

Parameters:
    value : obj

Returns: bool

Indicates if an object is a tensor

value : obj
Returns: bool

dsharp.isinf input

Full Usage: dsharp.isinf input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

Returns a boolean tensor where each element indicates if the corresponding element in the input tensor is an infinity value.

input : Tensor

The input tensor.

Returns: Tensor

dsharp.isnan input

Full Usage: dsharp.isnan input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

Returns a boolean tensor where each element indicates if the corresponding element in the input tensor is a NaN (not-a-number) value.

input : Tensor

The input tensor.

Returns: Tensor

dsharp.jacobian f x

Full Usage: dsharp.jacobian f x

Parameters:
Returns: Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor

dsharp.jacobianTv f x v

Full Usage: dsharp.jacobianTv f x v

Parameters:
    f : Tensor -> Tensor - vector-to-vector function
    x : Tensor - Point at which the function f will be evaluated, it must have a single dimension.
    v : Tensor - Vector

Returns: Tensor

Transposed Jacobian-vector product of a vector-to-vector function `f`, at point `x`, along vector `v`

f : Tensor -> Tensor

vector-to-vector function

x : Tensor

Point at which the function f will be evaluated, it must have a single dimension.

v : Tensor

Vector

Returns: Tensor

dsharp.jacobianv f x v

Full Usage: dsharp.jacobianv f x v

Parameters:
Returns: Tensor

TBD

f : Tensor -> Tensor
x : Tensor
v : Tensor
Returns: Tensor

dsharp.laplacian f x

Full Usage: dsharp.laplacian f x

Parameters:
Returns: Tensor

TBD

f : Tensor -> Tensor
x : Tensor
Returns: Tensor

dsharp.le (a, b)

Full Usage: dsharp.le (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Return a boolean tensor for the element-wise less-than-or-equal comparison of the elements in the two tensors.

The shapes of input and other don’t need to match, but they must be broadcastable.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.leakyRelu (input, ?negativeSlope)

Full Usage: dsharp.leakyRelu (input, ?negativeSlope)

Parameters:
    input : Tensor - The input tensor.
    ?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{negative\_slope} * \min(0, x)\]

input : Tensor

The input tensor.

?negativeSlope : float

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

Returns: Tensor

dsharp.like (input, value, ?device, ?dtype, ?backend)

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    value : obj - The .NET object giving the the initial values for the tensor.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

Returns a new tensor based on the given .NET value with characteristics based on the input tensor.

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

value : obj

The .NET object giving the the initial values for the tensor.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

dsharp.linspace (startVal, endVal, steps, ?device, ?dtype, ?backend)

Full Usage: dsharp.linspace (startVal, endVal, steps, ?device, ?dtype, ?backend)

Parameters:
    startVal : int - The starting value for the set of points.
    endVal : int - The ending value for the set of points.
    steps : int - The size of the returned 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

Returns a 1-D tensor of size steps whose values are evenly spaced from startVal to endVal. The values are going to be: \( (\text{startVal}, \text{startVal} + \frac{\text{endVal} - \text{startVal}}{\text{steps} - 1}, \ldots, \text{startVal} + (\text{steps} - 2) * \frac{\text{endVal} - \text{startVal}}{\text{steps} - 1}, \text{endVal}) \)

startVal : int

The starting value for the set of points.

endVal : int

The ending value for the set of points.

steps : int

The size of the returned 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

dsharp.linspace (startVal, endVal, steps, ?device, ?dtype, ?backend)

Full Usage: dsharp.linspace (startVal, endVal, steps, ?device, ?dtype, ?backend)

Parameters:
    startVal : float - The starting value for the set of points.
    endVal : float - The ending value for the set of points.
    steps : int - The size of the returned 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

Returns a 1-D tensor of size steps whose values are evenly spaced from startVal to endVal. The values are going to be: \( (\text{startVal}, \text{startVal} + \frac{\text{endVal} - \text{startVal}}{\text{steps} - 1}, \ldots, \text{startVal} + (\text{steps} - 2) * \frac{\text{endVal} - \text{startVal}}{\text{steps} - 1}, \text{endVal}) \)

startVal : float

The starting value for the set of points.

endVal : float

The ending value for the set of points.

steps : int

The size of the returned 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

dsharp.load fileName

Full Usage: dsharp.load fileName

Parameters:
    fileName : string

Returns: 'b

Loads an object from the given file using a bespoke binary format.

The format used may change from version to version of DiffSharp.

fileName : string
Returns: 'b

dsharp.log input

Full Usage: dsharp.log input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.log10 input

Full Usage: dsharp.log10 input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.logsoftmax (input, dim)

Full Usage: dsharp.logsoftmax (input, dim)

Parameters:
    input : Tensor - The input tensor.
    dim : int - A dimension along which softmax will be computed.

Returns: Tensor

Applies a softmax followed by a logarithm.

input : Tensor

The input tensor.

dim : int

A dimension along which softmax will be computed.

Returns: Tensor

dsharp.logspace (startVal, endVal, steps, ?baseVal, ?device, ?dtype, ?backend)

Full Usage: dsharp.logspace (startVal, endVal, steps, ?baseVal, ?device, ?dtype, ?backend)

Parameters:
    startVal : int - The starting value for the set of points.
    endVal : int - The ending value for the set of points.
    steps : int - The size of the returned tensor.
    ?baseVal : int - The base of the logarithm. Default: 10.
    ?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 1-D tensor of size steps whose values are evenly spaced logarithmically from \(\text{baseVal}^{\text{startVal}}\) to \(\text{baseVal}^{\text{endVal}}\). The values are going to be: \( (\text{baseVal}^{\text{startVal}}, \text{baseVal}^{(\text{startVal} + \frac{\text{endVal} - \text{startVal}}{ \text{steps} - 1})}, \ldots, \text{baseVal}^{(\text{startVal} + (\text{steps} - 2) * \frac{\text{endVal} - \text{startVal}}{ \text{steps} - 1})}, \text{baseVal}^{\text{endVal}}) \)

startVal : int

The starting value for the set of points.

endVal : int

The ending value for the set of points.

steps : int

The size of the returned tensor.

?baseVal : int

The base of the logarithm. Default: 10.

?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

dsharp.logspace (startVal, endVal, steps, ?baseVal, ?device, ?dtype, ?backend)

Full Usage: dsharp.logspace (startVal, endVal, steps, ?baseVal, ?device, ?dtype, ?backend)

Parameters:
    startVal : float - The starting value for the set of points.
    endVal : float - The ending value for the set of points.
    steps : int - The size of the returned tensor.
    ?baseVal : float - The base of the logarithm. Default: 10.0.
    ?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 1-D tensor of size steps whose values are evenly spaced logarithmically from \(\text{baseVal}^{\text{startVal}}\) to \(\text{baseVal}^{\text{endVal}}\). The values are going to be: \( (\text{baseVal}^{\text{startVal}}, \text{baseVal}^{(\text{startVal} + \frac{\text{endVal} - \text{startVal}}{ \text{steps} - 1})}, \ldots, \text{baseVal}^{(\text{startVal} + (\text{steps} - 2) * \frac{\text{endVal} - \text{startVal}}{ \text{steps} - 1})}, \text{baseVal}^{\text{endVal}}) \)

startVal : float

The starting value for the set of points.

endVal : float

The ending value for the set of points.

steps : int

The size of the returned tensor.

?baseVal : float

The base of the logarithm. Default: 10.0.

?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

dsharp.logsumexp (input, dim, ?keepDim)

Full Usage: dsharp.logsumexp (input, dim, ?keepDim)

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

Returns: Tensor

Applies a logsumexp followed by a logarithm.

input : Tensor

The input tensor.

dim : int

The dimension to reduce.

?keepDim : bool

Whether the output tensor has dim retained or not.

Returns: Tensor

dsharp.lt (a, b)

Full Usage: dsharp.lt (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Returns a boolean tensor for the element-wise less-than comparison of the elements in the two tensors.

The shapes of input and other don’t need to match, but they must be broadcastable.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.map mapping tensor

Full Usage: dsharp.map mapping tensor

Parameters:
    mapping : Tensor -> Tensor - The function to apply to each element of the tensor.
    tensor : Tensor - The input tensor.

Returns: Tensor

Produce a new tensor by mapping a function over all elements of the input tensor.

mapping : Tensor -> Tensor

The function to apply to each element of the tensor.

tensor : Tensor

The input tensor.

Returns: Tensor

dsharp.map2 mapping tensor1 tensor2

Full Usage: dsharp.map2 mapping tensor1 tensor2

Parameters:
    mapping : Tensor -> Tensor -> Tensor - The function to apply to each element of the tensor.
    tensor1 : Tensor - The first input tensor.
    tensor2 : Tensor - The second input tensor.

Returns: Tensor

Produce a new tensor by mapping a function over all corresponding elements of two input tensors.

The shapes of the two tensors must be identical.

mapping : Tensor -> Tensor -> Tensor

The function to apply to each element of the tensor.

tensor1 : Tensor

The first input tensor.

tensor2 : Tensor

The second input tensor.

Returns: Tensor

dsharp.map3 mapping tensor1 tensor2 tensor3

Full Usage: dsharp.map3 mapping tensor1 tensor2 tensor3

Parameters:
    mapping : Tensor -> Tensor -> Tensor -> Tensor - The function to apply to each element of the tensor.
    tensor1 : Tensor - The first input tensor.
    tensor2 : Tensor - The second input tensor.
    tensor3 : Tensor - The third input tensor.

Returns: Tensor

Produce a new tensor by mapping a function over all corresponding elements of three input tensors.

The shapes of the three tensors must be identical.

mapping : Tensor -> Tensor -> Tensor -> Tensor

The function to apply to each element of the tensor.

tensor1 : Tensor

The first input tensor.

tensor2 : Tensor

The second input tensor.

tensor3 : Tensor

The third input tensor.

Returns: Tensor

dsharp.mapi mapping tensor

Full Usage: dsharp.mapi mapping tensor

Parameters:
    mapping : int[] -> Tensor -> Tensor - The function is passed the index of each element. The function to apply to each element of the tensor.
    tensor : Tensor - The input tensor.

Returns: Tensor

Produce a new tensor by mapping a function over all elements of the input tensor.

mapping : int[] -> Tensor -> Tensor

The function is passed the index of each element. The function to apply to each element of the tensor.

tensor : Tensor

The input tensor.

Returns: Tensor

dsharp.mapi2 mapping tensor1 tensor2

Full Usage: dsharp.mapi2 mapping tensor1 tensor2

Parameters:
    mapping : int[] -> Tensor -> Tensor -> Tensor - The function to apply to each element of the tensor.
    tensor1 : Tensor - The first input tensor.
    tensor2 : Tensor - The second input tensor.

Returns: Tensor

Produce a new tensor by mapping a function over all corresponding elements of two input tensors.

The function is passed the index of each element. The shapes of the two tensors must be identical.

mapping : int[] -> Tensor -> Tensor -> Tensor

The function to apply to each element of the tensor.

tensor1 : Tensor

The first input tensor.

tensor2 : Tensor

The second input tensor.

Returns: Tensor

dsharp.mapi3 mapping tensor1 tensor2 tensor3

Full Usage: dsharp.mapi3 mapping tensor1 tensor2 tensor3

Parameters:
    mapping : int[] -> Tensor -> Tensor -> Tensor -> Tensor - The function to apply to each element of the tensor.
    tensor1 : Tensor - The first input tensor.
    tensor2 : Tensor - The second input tensor.
    tensor3 : Tensor - The third input tensor.

Returns: Tensor

Produce a new tensor by mapping a function over all corresponding elements of three input tensors.

The function is passed the index of each element. The shapes of the three tensors must be identical.

mapping : int[] -> Tensor -> Tensor -> Tensor -> Tensor

The function to apply to each element of the tensor.

tensor1 : Tensor

The first input tensor.

tensor2 : Tensor

The second input tensor.

tensor3 : Tensor

The third input tensor.

Returns: Tensor

dsharp.matmul (a, b)

Full Usage: dsharp.matmul (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Matrix product of two tensors.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.max (a, dim, ?keepDim)

Full Usage: dsharp.max (a, dim, ?keepDim)

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

Returns: Tensor

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

a : Tensor

The tensor.

dim : int

The dimension.

?keepDim : bool

Whether the output tensor has dim retained or not.

Returns: Tensor

dsharp.max (a, b)

Full Usage: dsharp.max (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Each element of the tensor input is compared with the corresponding element of the tensor other and an element-wise maximum is taken.

The shapes of input and other don’t need to match, but they must be broadcastable.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.max input

Full Usage: dsharp.max input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.maxpool1d (input, kernelSize, ?stride, ?padding)

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

Parameters:
    input : Tensor - The input tensor.
    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.

input : Tensor

The input tensor.

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

dsharp.maxpool1di (input, kernelSize, ?stride, ?padding)

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

Parameters:
    input : Tensor - The input tensor.
    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.

input : Tensor

The input tensor.

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

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

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

Parameters:
    input : Tensor - The input tensor.
    ?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.

input : Tensor

The input tensor.

?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

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

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

Parameters:
    input : Tensor - The input tensor.
    ?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.

input : Tensor

The input tensor.

?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

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

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

Parameters:
    input : Tensor - The input tensor.
    ?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.

input : Tensor

The input tensor.

?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

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

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

Parameters:
    input : Tensor - The input tensor.
    ?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.

input : Tensor

The input tensor.

?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

dsharp.maxunpool1d (input, indices, kernelSize, ?stride, ?padding, ?outputSize)

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

Parameters:
    input : Tensor - The input tensor.
    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

input : Tensor

The input tensor.

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

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

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

Parameters:
    input : Tensor - The input tensor.
    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

input : Tensor

The input tensor.

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

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

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

Parameters:
    input : Tensor - The input tensor.
    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

input : Tensor

The input tensor.

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

dsharp.mean (input, dim, ?keepDim)

Full Usage: dsharp.mean (input, dim, ?keepDim)

Parameters:
    input : Tensor - The input tensor.
    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 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(s) dim where it is of size 1. Otherwise, dim is squeezed, resulting in the output tensor having 1 (or len(dim)) fewer dimension(s).

input : Tensor

The input tensor.

dim : int

The dimension to reduce.

?keepDim : bool

Whether the output tensor has dim retained or not.

Returns: Tensor

dsharp.mean input

Full Usage: dsharp.mean input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.min (a, dim, ?keepDim)

Full Usage: dsharp.min (a, dim, ?keepDim)

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

Returns: Tensor

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

a : Tensor

The tensor.

dim : int

The dimension.

?keepDim : bool

Whether the output tensor has dim retained or not.

Returns: Tensor

dsharp.min (a, b)

Full Usage: dsharp.min (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Each element of the tensor input is compared with the corresponding element of the tensor other and an element-wise minimum is taken.

The shapes of input and other don’t need to match, but they must be broadcastable.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.min input

Full Usage: dsharp.min input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.move (input, ?device, ?dtype, ?backend)

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

Parameters:
    input : Tensor - The input tensor.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

Move the tensor to a difference device, backend and/or change its element type.

If the characteristics are unchanged the input tensor will be returned.

input : Tensor

The input tensor.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

dsharp.mseLoss (input, target, ?reduction)

Full Usage: dsharp.mseLoss (input, target, ?reduction)

Parameters:
    input : Tensor - The input tensor.
    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.

input : Tensor

The input tensor.

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

dsharp.mul (a, b)

Full Usage: dsharp.mul (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Return the element-wise multiplication of the two tensors.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.multinomial (probs, numSamples, ?normalize, ?device, ?dtype, ?backend)

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

Parameters:
    probs : Tensor - The input tensor containing probabilities.
    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.

probs : Tensor

The input tensor containing probabilities.

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

dsharp.ne (a, b)

Full Usage: dsharp.ne (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Returns a boolean tensor for the element-wise non-equality comparison of the elements in the two tensors.

The shapes of input and other don’t need to match, but they must be broadcastable.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.neg input

Full Usage: dsharp.neg input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

Return the element-wise negation of the input tensor.

input : Tensor

The input tensor.

Returns: Tensor

dsharp.nelement input

Full Usage: dsharp.nelement input

Parameters:
    input : Tensor - The input tensor.

Returns: int

Returns the total number of elements in the input tensor.

input : Tensor

The input tensor.

Returns: int

dsharp.nest level

Full Usage: dsharp.nest level

Parameters:
    level : uint32 - The new nesting level.

Set the global nesting level for automatic differentiation.

level : uint32

The new nesting level.

dsharp.nest ()

Full Usage: dsharp.nest ()

Increase the global nesting level for automatic differentiation.

dsharp.nestLevel ()

Full Usage: dsharp.nestLevel ()

Returns: uint32

Get the global nesting level for automatic differentiation.

Returns: uint32

dsharp.nestReset ()

Full Usage: dsharp.nestReset ()

Reset the global nesting level for automatic differentiation to zero.

dsharp.nllLoss (input, target, ?weight, ?reduction)

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

Parameters:
    input : Tensor - The input tensor.
    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.

input : Tensor

The input tensor.

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

dsharp.noDiff tensor

Full Usage: dsharp.noDiff tensor

Parameters:
    tensor : Tensor - The input.

Returns: Tensor

Produce a new constant (non-differentiated) tensor.

tensor : Tensor

The input.

Returns: Tensor

dsharp.normalize input

Full Usage: dsharp.normalize input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

Normalizes a vector so all the values are between zero and one (min-max scaling to 0..1).

input : Tensor

The input tensor.

Returns: Tensor

dsharp.one (?device, ?dtype, ?backend)

Full Usage: dsharp.one (?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

Get the scalar '1' tensor for the given configuration

?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

dsharp.oneLike (input, ?device, ?dtype, ?backend)

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

Returns the '0' scalar tensor with characteristics based on the input tensor.

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

dsharp.onehot (length, hot, ?device, ?dtype, ?backend)

Full Usage: dsharp.onehot (length, hot, ?device, ?dtype, ?backend)

Parameters:
    length : int - The length of the returned tensor.
    hot : int - The location to set to 1.
    ?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 one-hot tensor, with one location set to 1, and all others 0.

length : int

The length of the returned tensor.

hot : int

The location to set to 1.

?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

dsharp.onehotLike (input, length, hot, ?device, ?dtype, ?backend)

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    length : int - The length of the returned tensor.
    hot : int - The location to set to 1.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

A version of dsharp.onehot with characteristics based on the input tensor.

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

length : int

The length of the returned tensor.

hot : int

The location to set to 1.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

dsharp.ones (length, ?device, ?dtype, ?backend)

Full Usage: dsharp.ones (length, ?device, ?dtype, ?backend)

Parameters:
    length : int - The length of the returned 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

Returns a new tensor of the given length filled with '1' values for the given element type and configuration

length : int

The length of the returned 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

dsharp.ones (shape, ?device, ?dtype, ?backend)

Full Usage: dsharp.ones (shape, ?device, ?dtype, ?backend)

Parameters:
    shape : seq<int> - The desired shape of returned 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

Returns a new tensor filled with '1' values for the given shape, element type and configuration

shape : seq<int>

The desired shape of returned 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

dsharp.onesLike (input, ?shape, ?device, ?dtype, ?backend)

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    ?shape : seq<int> - The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

Returns a new tensor filled with '1' values with characteristics based on the input tensor.

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

?shape : seq<int>

The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

dsharp.pad (input, paddings)

Full Usage: dsharp.pad (input, paddings)

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

Returns: Tensor

Add zero padding to each side of a tensor

input : Tensor

The input tensor.

paddings : seq<int>

The implicit paddings on corresponding sides of the input.

Returns: Tensor

dsharp.permute (input, permutation)

Full Usage: dsharp.permute (input, permutation)

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

Returns: Tensor

Returns the original tensor with its dimensions permuted.

input : Tensor

The input tensor.

permutation : seq<int>

The desired ordering of dimensions.

Returns: Tensor

dsharp.pow (a, b)

Full Usage: dsharp.pow (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Return the element-wise exponentiation of the two tensors.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.primal tensor

Full Usage: dsharp.primal tensor

Parameters:
Returns: Tensor

Get the primal value of the tensor.

tensor : Tensor
Returns: Tensor

dsharp.primalDerivative tensor

Full Usage: dsharp.primalDerivative tensor

Parameters:
Returns: Tensor * Tensor

Get the primal and derivative values of the tensor.

tensor : Tensor
Returns: Tensor * Tensor

dsharp.rand (length, ?device, ?dtype, ?backend)

Full Usage: dsharp.rand (length, ?device, ?dtype, ?backend)

Parameters:
    length : int - The length of the returned 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

Returns a tensor filled with random numbers from a uniform distribution on the interval [0, 1)

length : int

The length of the returned 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

dsharp.rand (shape, ?device, ?dtype, ?backend)

Full Usage: dsharp.rand (shape, ?device, ?dtype, ?backend)

Parameters:
    shape : seq<int> - The desired shape of returned 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

Returns a tensor filled with random numbers from a uniform distribution on the interval [0, 1)

shape : seq<int>

The desired shape of returned 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

dsharp.randLike (input, ?shape, ?device, ?dtype, ?backend)

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    ?shape : seq<int> - The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

Returns a tensor filled with random numbers from a uniform distribution on the interval [0, 1) with characteristics based on the input tensor

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

?shape : seq<int>

The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

dsharp.randint (low, high, length, ?device, ?dtype, ?backend)

Full Usage: dsharp.randint (low, high, length, ?device, ?dtype, ?backend)

Parameters:
    low : int - Lowest integer to be drawn from the distribution. Default: 0..
    high : int - One above the highest integer to be drawn from the distribution.
    length : int - The length of the returned 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

Returns a tensor filled with random integers generated uniformly between low (inclusive) and high (exclusive).

low : int

Lowest integer to be drawn from the distribution. Default: 0..

high : int

One above the highest integer to be drawn from the distribution.

length : int

The length of the returned 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

dsharp.randint (low, high, shape, ?device, ?dtype, ?backend)

Full Usage: dsharp.randint (low, high, shape, ?device, ?dtype, ?backend)

Parameters:
    low : int - Lowest integer to be drawn from the distribution. Default: 0..
    high : int - One above the highest integer to be drawn from the distribution.
    shape : seq<int> - The desired shape of returned 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

Returns a tensor filled with random integers generated uniformly between low (inclusive) and high (exclusive).

low : int

Lowest integer to be drawn from the distribution. Default: 0..

high : int

One above the highest integer to be drawn from the distribution.

shape : seq<int>

The desired shape of returned 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

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

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    low : int - Lowest integer to be drawn from the distribution. Default: 0..
    high : int - One above the highest integer to be drawn from the distribution.
    ?shape : seq<int> - The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

Returns a tensor with the same shape as Tensor input filled with random integers generated uniformly between low (inclusive) and high (exclusive) with characteristics based on the input tensor.

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

low : int

Lowest integer to be drawn from the distribution. Default: 0..

high : int

One above the highest integer to be drawn from the distribution.

?shape : seq<int>

The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

dsharp.randn (length, ?device, ?dtype, ?backend)

Full Usage: dsharp.randn (length, ?device, ?dtype, ?backend)

Parameters:
    length : int - The length of the returned 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

Returns a tensor filled with random numbers from a normal distribution with mean 0 and variance 1 (also called the standard normal distribution).

length : int

The length of the returned 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

dsharp.randn (shape, ?device, ?dtype, ?backend)

Full Usage: dsharp.randn (shape, ?device, ?dtype, ?backend)

Parameters:
    shape : seq<int> - The desired shape of returned 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

Returns a tensor filled with random numbers from a normal distribution with mean 0 and variance 1 (also called the standard normal distribution).

shape : seq<int>

The desired shape of returned 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

dsharp.randnLike (input, ?shape, ?device, ?dtype, ?backend)

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    ?shape : seq<int> - The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

Returns a tensor filled with random numbers from a normal distribution with mean 0 and variance 1 (also called the standard normal distribution) with characteristics based on the input tensor.

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

?shape : seq<int>

The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

dsharp.relu input

Full Usage: dsharp.relu input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

Applies the rectified linear unit function element-wise.

input : Tensor

The input tensor.

Returns: Tensor

dsharp.repeat (input, dim, times)

Full Usage: dsharp.repeat (input, dim, times)

Parameters:
    input : Tensor - The input tensor.
    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

input : Tensor

The input tensor.

dim : int

The dimension along which to repeat values.

times : int

The number of repetitions for each element.

Returns: Tensor

dsharp.reverse value tensor

Full Usage: dsharp.reverse value tensor

Parameters:
    value : Tensor - The value to apply.
    tensor : Tensor - The output tensor.

Compute the reverse-mode derivative at the given output tensor.

value : Tensor

The value to apply.

tensor : Tensor

The output tensor.

dsharp.reverseDiff nestingTag tensor

Full Usage: dsharp.reverseDiff nestingTag tensor

Parameters:
    nestingTag : uint32 - The level tag.
    tensor : Tensor - The output tensor.

Returns: Tensor

Produce a new tensor suitable for calculating the reverse-mode derivative at the given level tag.

nestingTag : uint32

The level tag.

tensor : Tensor

The output tensor.

Returns: Tensor

dsharp.reversePush value tensor

Full Usage: dsharp.reversePush value tensor

Parameters:
    value : Tensor - The value to apply.
    tensor : Tensor - The output tensor.

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

value : Tensor

The value to apply.

tensor : Tensor

The output tensor.

dsharp.reverseReset tensor

Full Usage: dsharp.reverseReset tensor

Parameters:
    tensor : Tensor - The output tensor.

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

tensor : Tensor

The output tensor.

dsharp.round input

Full Usage: dsharp.round input

Parameters:
    input : Tensor - The input tensor.

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.

input : Tensor

The input tensor.

Returns: Tensor

dsharp.safelog (input, ?epsilon)

Full Usage: dsharp.safelog (input, ?epsilon)

Parameters:
    input : Tensor - The input tensor.
    ?epsilon : float - The smallest value a tensor element can take before the logarithm is applied. Default: 1e-12

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.

input : Tensor

The input tensor.

?epsilon : float

The smallest value a tensor element can take before the logarithm is applied. Default: 1e-12

Returns: Tensor

dsharp.save (value, fileName)

Full Usage: dsharp.save (value, fileName)

Parameters:
    value : obj
    fileName : string

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

The format used may change from version to version of DiffSharp.

value : obj
fileName : string

dsharp.scalar (value, ?device, ?dtype, ?backend)

Full Usage: dsharp.scalar (value, ?device, ?dtype, ?backend)

Parameters:
    value : scalar - The scalar giving the 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

Returns a new scalar tensor with the value value, for the given element type and configuration

value : scalar

The scalar giving the 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

dsharp.scatter (input, dim, indices, destinationShape)

Full Usage: dsharp.scatter (input, dim, indices, destinationShape)

Parameters:
    input : Tensor - The input tensor.
    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

Gathers values along an axis specified by dim.

input : Tensor

The input tensor.

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

dsharp.seed ?seed

Full Usage: dsharp.seed ?seed

Parameters:
    ?seed : int

Seeds all backends with the given random seed, or a new seed based on the current time if no seed is specified.

?seed : int

dsharp.sigmoid input

Full Usage: dsharp.sigmoid input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

Applies the sigmoid element-wise function

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.sign input

Full Usage: dsharp.sign input

Parameters:
    input : Tensor - The input tensor.

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.

input : Tensor

The input tensor.

Returns: Tensor

dsharp.sin input

Full Usage: dsharp.sin input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.sinh input

Full Usage: dsharp.sinh input

Parameters:
Returns: Tensor

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

input : Tensor
Returns: Tensor

dsharp.slice (input, index)

Full Usage: dsharp.slice (input, index)

Parameters:
    input : Tensor - The input tensor.
    index : seq<int> - Index describing the slice.

Returns: Tensor

Get a slice of a tensor

input : Tensor

The input tensor.

index : seq<int>

Index describing the slice.

Returns: Tensor

dsharp.softmax (input, dim)

Full Usage: dsharp.softmax (input, dim)

Parameters:
    input : Tensor - The input tensor.
    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)}.

input : Tensor

The input tensor.

dim : int

A dimension along which softmax will be computed.

Returns: Tensor

dsharp.softplus input

Full Usage: dsharp.softplus input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

Applies the softplus function element-wise.

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.split (input, sizes, ?dim)

Full Usage: dsharp.split (input, sizes, ?dim)

Parameters:
    input : Tensor - The tensor to split.
    sizes : seq<int> - The size of a single chunk or list of sizes for each chunk.
    ?dim : int - The dimension along which to split the tensor.

Returns: Tensor[]

Splits the tensor into chunks. The tensor will be split into sizes.Length chunks each with a corresponding size in the given dimension.

input : Tensor

The tensor to split.

sizes : seq<int>

The size of a single chunk or list of sizes for each chunk.

?dim : int

The dimension along which to split the tensor.

Returns: Tensor[]

dsharp.sqrt input

Full Usage: dsharp.sqrt input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.squeeze (input, ?dim)

Full Usage: dsharp.squeeze (input, ?dim)

Parameters:
    input : Tensor - The input tensor.
    ?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.

input : Tensor

The input tensor.

?dim : int

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

Returns: Tensor

dsharp.stack (tensors, ?dim)

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

Parameters:
    tensors : seq<Tensor> - The sequence of tensors to concatenate.
    ?dim : int - The 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 size.

tensors : seq<Tensor>

The sequence of tensors to concatenate.

?dim : int

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

Returns: Tensor

dsharp.standardize input

Full Usage: dsharp.standardize input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

Returns the tensor after standardization (z-score normalization)

input : Tensor

The input tensor.

Returns: Tensor

dsharp.std (input, dim, ?keepDim, ?unbiased)

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

Parameters:
    input : Tensor - The input tensor.
    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 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(s) dim where it is of size 1. Otherwise, dim is squeezed, resulting in the output tensor having 1 (or len(dim)) 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.

input : Tensor

The input tensor.

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

dsharp.std (input, ?unbiased)

Full Usage: dsharp.std (input, ?unbiased)

Parameters:
    input : Tensor - The input tensor.
    ?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.

input : Tensor

The input tensor.

?unbiased : bool

Whether to use the unbiased estimation or not.

Returns: Tensor

dsharp.sub (a, b)

Full Usage: dsharp.sub (a, b)

Parameters:
    a : Tensor - The first tensor.
    b : Tensor - The second tensor.

Returns: Tensor

Return the element-wise subtraction of the two tensors.

a : Tensor

The first tensor.

b : Tensor

The second tensor.

Returns: Tensor

dsharp.sum (input, dim, ?keepDim)

Full Usage: dsharp.sum (input, dim, ?keepDim)

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

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(s) dim where it is of size 1. Otherwise, dim is squeezed, resulting in the output tensor having 1 (or len(dim)) fewer dimension(s).

input : Tensor

The input tensor.

dim : int

The dimension to reduce.

?keepDim : bool

Whether the output tensor has dim retained or not.

Returns: Tensor

dsharp.sum input

Full Usage: dsharp.sum input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

Returns the sum of all elements in the input tensor

input : Tensor

The input tensor.

Returns: Tensor

dsharp.tan input

Full Usage: dsharp.tan input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.tanh input

Full Usage: dsharp.tanh input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.tensor (value, ?device, ?dtype, ?backend)

Full Usage: dsharp.tensor (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 data is converted from arrays, sequences, lists and tuples of primitive values to a tensor whose shape is inferred from the data. 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
Example

    let t1 = dsharp.tensor [ 1 .. 10 ]
    let t2 = dsharp.tensor [ [ 1.0; 3.0; 4.0 ];
                             [ 1.02; 3.04; 4.01 ] ]

dsharp.toImage (input, ?pixelMin, ?pixelMax, ?normalize, ?gridCols)

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

Parameters:
    input : Tensor - The input tensor.
    ?pixelMin : double - The minimum pixel value.
    ?pixelMax : double - The maximum pixel value.
    ?normalize : bool - If True, shift the image to the range (0, 1), by the min and max values specified by range.
    ?gridCols : int - Number of columns of images in the grid.

Returns: Tensor

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

If the input tensor has 4 dimensions, then make a single image grid.

input : Tensor

The input tensor.

?pixelMin : double

The minimum pixel value.

?pixelMax : double

The maximum pixel value.

?normalize : bool

If True, shift the image to the range (0, 1), by the min and max values specified by range.

?gridCols : int

Number of columns of images in the grid.

Returns: Tensor

dsharp.toImageString (input, ?pixelMin, ?pixelMax, ?normalize, ?gridCols, ?asciiPalette)

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

Parameters:
    input : Tensor - The input tensor.
    ?pixelMin : double - The minimum pixel value.
    ?pixelMax : double - The maximum pixel value.
    ?normalize : bool - If True, shift the image to the range (0, 1), by the min and max values specified by range.
    ?gridCols : int - Number of columns of images in the grid.
    ?asciiPalette : string - The ASCII pallette to use.

Returns: string

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

input : Tensor

The input tensor.

?pixelMin : double

The minimum pixel value.

?pixelMax : double

The maximum pixel value.

?normalize : bool

If True, shift the image to the range (0, 1), by the min and max values specified by range.

?gridCols : int

Number of columns of images in the grid.

?asciiPalette : string

The ASCII pallette to use.

Returns: string

dsharp.trace input

Full Usage: dsharp.trace input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.transpose input

Full Usage: dsharp.transpose input

Parameters:
    input : Tensor - The input tensor.

Returns: Tensor

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

input : Tensor

The input tensor.

Returns: Tensor

dsharp.transpose (input, dim0, dim1)

Full Usage: dsharp.transpose (input, dim0, dim1)

Parameters:
    input : Tensor - The input tensor.
    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.

input : Tensor

The input tensor.

dim0 : int

The first dimension to be transposed.

dim1 : int

The second dimension to be transposed.

Returns: Tensor

dsharp.undilate (input, dilations)

Full Usage: dsharp.undilate (input, dilations)

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

Returns: Tensor

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

input : Tensor

The input tensor.

dilations : seq<int>

The dilations to use.

Returns: Tensor

dsharp.unflatten (input, dim, unflattenedShape)

Full Usage: dsharp.unflatten (input, dim, unflattenedShape)

Parameters:
    input : Tensor - The input tensor.
    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.

input : Tensor

The input tensor.

dim : int

The dimension to unflatten.

unflattenedShape : seq<int>

New shape of the unflattened dimenension.

Returns: Tensor

dsharp.unsqueeze (input, dim)

Full Usage: dsharp.unsqueeze (input, dim)

Parameters:
    input : Tensor - The input tensor.
    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

input : Tensor

The input tensor.

dim : int

The index at which to insert the singleton dimension.

Returns: Tensor

dsharp.unsqueezeAs (input, other)

Full Usage: dsharp.unsqueezeAs (input, other)

Parameters:
    input : Tensor - The input tensor.
    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.

input : Tensor

The input tensor.

other : Tensor

The other tensor.

Returns: Tensor

dsharp.unstack (input, ?dim)

Full Usage: dsharp.unstack (input, ?dim)

Parameters:
    input : Tensor - The input tensor.
    ?dim : int - The dimension to remove.

Returns: Tensor[]

Removes a tensor dimension

input : Tensor

The input tensor.

?dim : int

The dimension to remove.

Returns: Tensor[]

dsharp.var (input, dim, ?keepDim, ?unbiased)

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

Parameters:
    input : Tensor - The input tensor.
    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 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(s) dim where it is of size 1. Otherwise, dim is squeezed, resulting in the output tensor having 1 (or len(dim)) fewer dimension(s). If unbiased is False, then the variance will be calculated via the biased estimator. Otherwise, Bessel’s correction will be used.

input : Tensor

The input tensor.

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

dsharp.var (input, ?unbiased)

Full Usage: dsharp.var (input, ?unbiased)

Parameters:
    input : Tensor - The input tensor.
    ?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.

input : Tensor

The input tensor.

?unbiased : bool

Whether to use the unbiased estimation or not.

Returns: Tensor

dsharp.version

Full Usage: dsharp.version

Returns: string

Returns the version of the DiffSharp.Core assembly.

Returns: string

dsharp.view (input, shape)

Full Usage: dsharp.view (input, shape)

Parameters:
    input : Tensor - The input tensor.
    shape : 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. 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]\]

input : Tensor

The input tensor.

shape : int

The desired shape of returned tensor.

Returns: Tensor

dsharp.view (input, shape)

Full Usage: dsharp.view (input, shape)

Parameters:
    input : Tensor - The input tensor.
    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. 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]\]

input : Tensor

The input tensor.

shape : seq<int>

The desired shape of returned tensor.

Returns: Tensor

dsharp.viewAs (input, other)

Full Usage: dsharp.viewAs (input, other)

Parameters:
    input : Tensor - The input tensor.
    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]\]

input : Tensor

The input tensor.

other : Tensor

The result tensor has the same size as other.

Returns: Tensor

dsharp.zero (?device, ?dtype, ?backend)

Full Usage: dsharp.zero (?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

Get the scalar zero tensor for the given configuration

?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

dsharp.zeroCreate count

Full Usage: dsharp.zeroCreate count

Parameters:
    count : int - The number of elements in the tensor.

Returns: Tensor

Create a new 1D tensor using '0' as value for each element.

count : int

The number of elements in the tensor.

Returns: Tensor

dsharp.zeroLike (input, ?device, ?dtype, ?backend)

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

Returns the '0' scalar tensor with characteristics based on the input tensor.

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

dsharp.zeros (length, ?device, ?dtype, ?backend)

Full Usage: dsharp.zeros (length, ?device, ?dtype, ?backend)

Parameters:
    length : int - The length of the returned 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

Returns a new tensor filled with '0' values for the given length, element type and configuration

length : int

The length of the returned 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

dsharp.zeros (shape, ?device, ?dtype, ?backend)

Full Usage: dsharp.zeros (shape, ?device, ?dtype, ?backend)

Parameters:
    shape : seq<int> - The desired shape of returned 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

Returns a new tensor filled with '0' values for the given shape, element type and configuration

shape : seq<int>

The desired shape of returned 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

dsharp.zerosLike (input, ?shape, ?device, ?dtype, ?backend)

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

Parameters:
    input : Tensor - The shape and characteristics of input will determine those of the output tensor.
    ?shape : seq<int> - The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.
    ?device : Device - The desired device of returned tensor. Default: if None, the device of the input tensor is used.
    ?dtype : Dtype - The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.
    ?backend : Backend - The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

Returns a new tensor filled with '0' values with characteristics based on the input tensor.

input : Tensor

The shape and characteristics of input will determine those of the output tensor.

?shape : seq<int>

The desired shape of returned tensor. Default: If None, the shape of the input tensor is used.

?device : Device

The desired device of returned tensor. Default: if None, the device of the input tensor is used.

?dtype : Dtype

The desired element type of returned tensor. Default: if None, the element type of the input tensor is used.

?backend : Backend

The desired backend of returned tensor. Default: if None, the backend of the input tensor is used.

Returns: Tensor

© Copyright 2021, DiffSharp Contributors.