Parameter Make.Operator

Vectorised functions

noop arr performs no operation on the array arr and returns it as is. This can be useful as a placeholder function. Returns the input array arr.

val empty : int array -> Symbol.Shape.Type.arr

empty shape creates an uninitialized array with the specified shape. The contents of the array are undefined. Returns a new array with the given shape.

val zeros : int array -> Symbol.Shape.Type.arr

zeros shape creates an array with the specified shape, filled with zeros. Returns a new array with all elements initialized to zero.

val ones : int array -> Symbol.Shape.Type.arr

ones shape creates an array with the specified shape, filled with ones. Returns a new array with all elements initialized to one.

val create : int array -> Symbol.Shape.Type.elt -> Symbol.Shape.Type.arr

create shape value creates an array with the specified shape, filled with the given value. Returns a new array with all elements initialized to value.

val sequential : ?a:Symbol.Shape.Type.elt -> ?step:Symbol.Shape.Type.elt -> int array -> Symbol.Shape.Type.arr

sequential ?a ?step shape creates an array with the specified shape, filled with a sequence of values starting from a with a step of step. If a is not provided, the sequence starts from 0. If step is not provided, the step size is 1. Returns a new array with sequential values.

uniform ?a ?b shape creates an array with the specified shape, filled with random values drawn from a uniform distribution over [a, b\). If a and b are not provided, the default range is [0, 1\) . Returns a new array with uniform random values.

val gaussian : ?mu:Symbol.Shape.Type.elt -> ?sigma:Symbol.Shape.Type.elt -> int array -> Symbol.Shape.Type.arr

gaussian ?mu ?sigma shape creates an array with the specified shape, filled with random values drawn from a Gaussian distribution with mean mu and standard deviation sigma. If mu is not provided, the default mean is 0. If sigma is not provided, the default standard deviation is 1. Returns a new array with Gaussian random values.

val bernoulli : ?p:Symbol.Shape.Type.elt -> int array -> Symbol.Shape.Type.arr

bernoulli ?p shape creates an array with the specified shape, filled with random values drawn from a Bernoulli distribution with probability p of being 1. If p is not provided, the default probability is 0.5. Returns a new array with Bernoulli random values.

val init : int array -> (int -> Symbol.Shape.Type.elt) -> Symbol.Shape.Type.arr

init shape f creates an array with the specified shape, where each element is initialized using the function f. The function f takes the linear index of the element as input. Returns a new array with elements initialized by the function f.

val init_nd : int array -> (int array -> Symbol.Shape.Type.elt) -> Symbol.Shape.Type.arr

init_nd shape f creates an array with the specified shape, where each element is initialized using the function f. The function f takes the multidimensional index of the element as input. Returns a new array with elements initialized by the function f.

val shape : Symbol.Shape.Type.arr -> int array

shape arr returns the shape of the array arr as an array of integers, each representing the size of the corresponding dimension.

val numel : Symbol.Shape.Type.arr -> int

numel arr returns the total number of elements in the array arr.

get arr index retrieves the element at the specified multidimensional index in the array arr. Returns the value of the element at the given index.

val set : Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.elt -> unit

set arr index value sets the element at the specified multidimensional index in the array arr to the given value.

val get_slice : int list list -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

get_slice slices arr extracts a slice from the array arr according to the list of slices. Each element in slices specifies the range for the corresponding dimension. Returns a new array with the extracted slice.

val set_slice : int list list -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> unit

set_slice slices src dest sets the slice in dest defined by slices with the values from the source array src.

get_fancy indices arr extracts elements from the array arr according to the list of indices. Each element in indices specifies an advanced indexing method. Returns a new array with the extracted elements.

set_fancy indices src dest sets the elements in dest defined by indices with the values from the source array src.

copy arr creates a deep copy of the array arr. Returns a new array that is a copy of arr.

val copy_ : out:'a -> 'b -> 'c

copy_ ~out src copies the contents of the array src into the pre-allocated array out.

val reset : Symbol.Shape.Type.arr -> unit

reset arr sets all elements of the array arr to zero.

val reshape : Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr

reshape arr shape reshapes the array arr into the new shape. The total number of elements must remain the same. Returns a new array with the specified shape.

reverse arr reverses the elements of the array arr along each dimension. Returns a new array with the elements reversed.

val tile : Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr

tile arr reps replicates the array arr according to the number of repetitions specified in reps for each dimension. Returns a new array with the tiled data.

val repeat : Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr

repeat arr reps repeats the elements of the array arr according to the number of repetitions specified in reps for each dimension. Returns a new array with the repeated data.

pad ?v padding arr pads the array arr with the value v according to the padding specification for each dimension. If v is not provided, the default padding value is zero. Returns a new array with the padded data.

val expand : ?hi:bool -> Symbol.Shape.Type.arr -> int -> Symbol.Shape.Type.arr

expand ?hi arr n expands the dimensions of the array arr by inserting a new dimension of size n. If hi is true, the new dimension is added at the beginning; otherwise, it is added at the end. Returns a new array with the expanded dimensions.

val squeeze : ?axis:int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

squeeze ?axis arr removes single-dimensional entries from the shape of the array arr. If axis is provided, only the specified dimensions are removed. Returns a new array with the squeezed shape.

val concatenate : ?axis:int -> Symbol.Shape.Type.arr array -> Symbol.Shape.Type.arr

concatenate ?axis arrays concatenates a sequence of arrays along the specified axis. If axis is not provided, the arrays are concatenated along the first axis. Returns a new array with the concatenated data.

val stack : ?axis:int -> Symbol.Shape.Type.arr array -> Symbol.Shape.Type.arr

stack ?axis arrays stacks a sequence of arrays along a new dimension at the specified axis. If axis is not provided, the arrays are stacked along the first axis. Returns a new array with the stacked data.

concat ~axis a b concatenates the arrays a and b along the specified axis. Returns a new array with the concatenated data.

val split : ?axis:int -> 'a -> 'b -> 'c

split ?axis src num_or_sections splits the array src into multiple sub-arrays along the specified axis.

  • num_or_sections specifies the number of equal-sized sub-arrays or the indices where to split. Returns an array of sub-arrays.
val draw : ?axis:int -> Symbol.Shape.Type.arr -> int -> Symbol.Shape.Type.arr * 'a array

draw ?axis arr n randomly draws n samples from the array arr along the specified axis. Returns a tuple containing the sampled array and an array of indices from which the samples were drawn.

map f arr applies the function f to each element of the array arr. Returns a new array with the results of applying f.

fold ?axis f init arr reduces the array arr along the specified axis using the function f and an initial value init. If axis is not provided, the reduction is performed on all elements. Returns a new array with the reduced values.

scan ?axis f arr performs a cumulative reduction of the array arr along the specified axis using the function f. Returns a new array with the cumulative results.

one_hot depth arr converts the array arr into a one-hot encoded array with a specified depth. Returns a new array with one-hot encoding.

delay f x returns f x. It allows to use a function that is not tracked by the computation graph and delay its evaluation. The output must have the same shape as the input.

delay_array out_shape f x works in the same way as delay but is applied on an array of ndarrays. Needs the shape of the output as an argument.

val lazy_print : ?max_row:int -> ?max_col:int -> ?header:bool -> ?fmt:(Symbol.Shape.Type.Device.A.elt -> string) -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

lazy_print x prints the output of x when it is evaluated. Is implemented as an identity node. For information about the optional parameters, refer to the print function of the Ndarray module.

val print : ?max_row:'a -> ?max_col:'b -> ?header:'c -> ?fmt:'d -> 'e -> unit

print ?max_row ?max_col ?header ?fmt data prints a representation of the given data.

  • max_row is an optional parameter specifying the maximum number of rows to print.
  • max_col is an optional parameter specifying the maximum number of columns to print.
  • header is an optional parameter to include a header in the output.
  • fmt is an optional parameter to specify the format of the output.

abs arr computes the absolute value of each element in the array arr. Returns a new array with the absolute values.

neg arr negates each element in the array arr. Returns a new array with each element negated.

floor arr applies the floor function to each element in the array arr. Returns a new array with the floor of each element.

ceil arr applies the ceiling function to each element in the array arr. Returns a new array with the ceiling of each element.

round arr rounds each element in the array arr to the nearest integer. Returns a new array with each element rounded to the nearest integer.

sqr arr computes the square of each element in the array arr. Returns a new array with the square of each element.

sqrt arr computes the square root of each element in the array arr. Returns a new array with the square roots of the elements.

log arr computes the natural logarithm of each element in the array arr. Returns a new array with the natural logarithms of the elements.

log2 arr computes the base-2 logarithm of each element in the array arr. Returns a new array with the base-2 logarithms of the elements.

log10 arr computes the base-10 logarithm of each element in the array arr. Returns a new array with the base-10 logarithms of the elements.

exp arr computes the exponential function of each element in the array arr. Returns a new array with the exponentials of the elements.

sin arr computes the sine of each element in the array arr. Returns a new array with the sines of the elements.

cos arr computes the cosine of each element in the array arr. Returns a new array with the cosines of the elements.

tan arr computes the tangent of each element in the array arr. Returns a new array with the tangents of the elements.

sinh arr computes the hyperbolic sine of each element in the array arr. Returns a new array with the hyperbolic sines of the elements.

cosh arr computes the hyperbolic cosine of each element in the array arr. Returns a new array with the hyperbolic cosines of the elements.

tanh arr computes the hyperbolic tangent of each element in the array arr. Returns a new array with the hyperbolic tangents of the elements.

asin arr computes the arcsine of each element in the array arr. Returns a new array with the arcsines of the elements.

acos arr computes the arccosine of each element in the array arr. Returns a new array with the arccosines of the elements.

atan arr computes the arctangent of each element in the array arr. Returns a new array with the arctangents of the elements.

asinh arr computes the inverse hyperbolic sine of each element in the array arr. Returns a new array with the inverse hyperbolic sines of the elements.

acosh arr computes the inverse hyperbolic cosine of each element in the array arr. Returns a new array with the inverse hyperbolic cosines of the elements.

atanh arr computes the inverse hyperbolic tangent of each element in the array arr. Returns a new array with the inverse hyperbolic tangents of the elements.

val min : ?axis:int -> ?keep_dims:bool -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

min ?axis ?keep_dims arr computes the minimum value along the specified axis of the array arr.

  • axis specifies the axis along which to compute the minimum.
  • keep_dims specifies whether to keep the reduced dimensions. Returns a new array with the minimum values.
val max : ?axis:int -> ?keep_dims:bool -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

max ?axis ?keep_dims arr computes the maximum value along the specified axis of the array arr.

  • axis specifies the axis along which to compute the maximum.
  • keep_dims specifies whether to keep the reduced dimensions. Returns a new array with the maximum values.
val sum : ?axis:int -> ?keep_dims:bool -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

sum ?axis ?keep_dims arr computes the sum of elements along the specified axis of the array arr.

  • axis specifies the axis along which to compute the sum.
  • keep_dims specifies whether to keep the reduced dimensions. Returns a new array with the sum of elements.
val sum_reduce : ?axis:int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

sum_reduce ?axis arr computes the sum of elements along the specified axes of the array arr.

  • axis specifies the axes along which to compute the sum. Returns a new array with the sum of elements.

signum arr computes the signum function of each element in the array arr. Returns a new array where each element is -1, 0, or 1, depending on the sign of the corresponding element in arr.

sigmoid arr computes the sigmoid function of each element in the array arr. Returns a new array with the sigmoid values.

relu arr applies the Rectified Linear Unit (ReLU) function to each element in the array arr. Returns a new array where each element is the maximum of 0 and the corresponding element in arr.

dawsn arr computes Dawson's function of each element in the array arr. Returns a new array with Dawson's function values.

min' arr computes the minimum value in the array arr. Returns the minimum value as an element.

max' arr computes the maximum value in the array arr. Returns the maximum value as an element.

sum' arr computes the sum of all elements in the array arr. Returns the sum as an element.

log_sum_exp' arr computes the log-sum-exp of all elements in the array arr. Returns the log-sum-exp as an element.

val log_sum_exp : ?axis:int -> ?keep_dims:bool -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

log_sum_exp ?axis ?keep_dims arr computes the log of the sum of exponentials of elements along the specified axis of the array arr.

  • axis specifies the axis along which to compute the log-sum-exp. If not specified, computes over all elements.
  • keep_dims if true, retains reduced dimensions with size 1. Returns a new array with the log-sum-exp values.

l1norm' arr computes the L1 norm (sum of absolute values) of all elements in the array arr. Returns the L1 norm as an element.

l2norm' arr computes the L2 norm (Euclidean norm) of all elements in the array arr. Returns the L2 norm as an element.

l2norm_sqr' arr computes the squared L2 norm (sum of squared values) of all elements in the array arr. Returns the squared L2 norm as an element.

clip_by_value ?amin ?amax arr clips the values in the array arr to the range amin, amax.

  • amin specifies the minimum value to clip to.
  • amax specifies the maximum value to clip to. Returns a new array with the values clipped to the specified range.

clip_by_l2norm max_norm arr clips the values in the array arr so that the L2 norm does not exceed max_norm. Returns a new array with the values clipped by the specified L2 norm.

pow base exp computes each element of the array base raised to the power of the corresponding element in exp. Returns a new array with the power values.

scalar_pow scalar arr raises the scalar value scalar to the power of each element in the array arr. Returns a new array with the power values.

pow_scalar arr scalar raises each element in the array arr to the power of the scalar value scalar. Returns a new array with the power values.

atan2 y x computes the element-wise arctangent of y / x, using the signs of the elements to determine the correct quadrant. Returns a new array with the arctangent values.

scalar_atan2 scalar arr computes the element-wise arctangent of scalar / each element in the array arr. Returns a new array with the arctangent values.

atan2_scalar arr scalar computes the element-wise arctangent of each element in the array arr / scalar. Returns a new array with the arctangent values.

hypot x y computes the hypotenuse (sqrt(x^2 + y^2)) for each element in the arrays x and y. Returns a new array with the hypotenuse values.

min2 a b computes the element-wise minimum of arrays a and b. Returns a new array with the minimum values.

max2 a b computes the element-wise maximum of arrays a and b. Returns a new array with the maximum values.

add a b computes the element-wise addition of arrays a and b. Returns a new array with the sum of elements.

sub a b computes the element-wise subtraction of arrays a and b. Returns a new array with the difference of elements.

mul a b computes the element-wise multiplication of arrays a and b. Returns a new array with the product of elements.

div a b computes the element-wise division of arrays a and b. Returns a new array with the quotient of elements.

add_scalar arr scalar adds the scalar value scalar to each element in the array arr. Returns a new array with the resulting values.

sub_scalar arr scalar subtracts the scalar value scalar from each element in the array arr. Returns a new array with the resulting values.

mul_scalar arr scalar multiplies each element in the array arr by the scalar value scalar. Returns a new array with the resulting values.

div_scalar arr scalar divides each element in the array arr by the scalar value scalar. Returns a new array with the resulting values.

scalar_add scalar arr adds the scalar value scalar to each element in the array arr. Returns a new array with the resulting values.

scalar_sub scalar arr subtracts each element in the array arr from the scalar value scalar. Returns a new array with the resulting values.

scalar_mul scalar arr multiplies each element in the array arr by the scalar value scalar. Returns a new array with the resulting values.

scalar_div scalar arr divides the scalar value scalar by each element in the array arr. Returns a new array with the resulting values.

fma a b c computes the fused multiply-add operation, multiplying arrays a and b, then adding array c. Returns a new array with the resulting values.

elt_equal a b performs element-wise equality comparison between arrays a and b. Returns a new array where each element is true if the corresponding elements in a and b are equal, and false otherwise.

elt_not_equal a b performs element-wise inequality comparison between arrays a and b. Returns a new array where each element is true if the corresponding elements in a and b are not equal, and false otherwise.

elt_less a b performs element-wise less-than comparison between arrays a and b. Returns a new array where each element is true if the corresponding element in a is less than that in b, and false otherwise.

elt_greater a b performs element-wise greater-than comparison between arrays a and b. Returns a new array where each element is true if the corresponding element in a is greater than that in b, and false otherwise.

elt_less_equal a b performs element-wise less-than-or-equal-to comparison between arrays a and b. Returns a new array where each element is true if the corresponding element in a is less than or equal to that in b, and false otherwise.

elt_greater_equal a b performs element-wise greater-than-or-equal-to comparison between arrays a and b. Returns a new array where each element is true if the corresponding element in a is greater than or equal to that in b, and false otherwise.

elt_equal_scalar arr scalar performs element-wise equality comparison between each element in the array arr and the scalar value scalar. Returns a new array where each element is true if it equals scalar, and false otherwise.

elt_not_equal_scalar arr scalar performs element-wise inequality comparison between each element in the array arr and the scalar value scalar. Returns a new array where each element is true if it does not equal scalar, and false otherwise.

elt_less_scalar arr scalar performs element-wise less-than comparison between each element in the array arr and the scalar value scalar. Returns a new array where each element is true if it is less than scalar, and false otherwise.

elt_greater_scalar arr scalar performs element-wise greater-than comparison between each element in the array arr and the scalar value scalar. Returns a new array where each element is true if it is greater than scalar, and false otherwise.

elt_less_equal_scalar arr scalar performs element-wise less-than-or-equal-to comparison between each element in the array arr and the scalar value scalar. Returns a new array where each element is true if it is less than or equal to scalar, and false otherwise.

elt_greater_equal_scalar arr scalar performs element-wise greater-than-or-equal-to comparison between each element in the array arr and the scalar value scalar. Returns a new array where each element is true if it is greater than or equal to scalar, and false otherwise.

conv1d ?padding input kernel strides performs a 1-dimensional convolution on the input array using the specified kernel.

  • padding specifies the padding strategy (default is "valid").
  • strides specifies the stride length. Returns a new array with the result of the convolution.

conv2d ?padding input kernel strides performs a 2-dimensional convolution on the input array using the specified kernel.

  • padding specifies the padding strategy (default is "valid").
  • strides specifies the stride length. Returns a new array with the result of the convolution.

conv3d ?padding input kernel strides performs a 3-dimensional convolution on the input array using the specified kernel.

  • padding specifies the padding strategy (default is "valid").
  • strides specifies the stride length. Returns a new array with the result of the convolution.
val transpose_conv1d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr

transpose_conv1d ?padding input kernel strides performs a 1-dimensional transposed convolution (also known as deconvolution) on the input array using the specified kernel.

  • padding specifies the padding strategy (default is "valid").
  • strides specifies the stride length. Returns a new array with the result of the transposed convolution.
val transpose_conv2d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr

transpose_conv2d ?padding input kernel strides performs a 2-dimensional transposed convolution (also known as deconvolution) on the input array using the specified kernel.

  • padding specifies the padding strategy (default is "valid").
  • strides specifies the stride length. Returns a new array with the result of the transposed convolution.
val transpose_conv3d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr

transpose_conv3d ?padding input kernel strides performs a 3-dimensional transposed convolution (also known as deconvolution) on the input array using the specified kernel.

  • padding specifies the padding strategy (default is "valid").
  • strides specifies the stride length. Returns a new array with the result of the transposed convolution.
val dilated_conv1d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr

dilated_conv1d ?padding input kernel strides dilations performs a 1-dimensional dilated convolution on the input array using the specified kernel.

  • padding specifies the padding strategy (default is "valid").
  • strides specifies the stride length.
  • dilations specifies the dilation rate. Returns a new array with the result of the dilated convolution.
val dilated_conv2d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr

dilated_conv2d ?padding input kernel strides dilations performs a 2-dimensional dilated convolution on the input array using the specified kernel.

  • padding specifies the padding strategy (default is "valid").
  • strides specifies the stride length.
  • dilations specifies the dilation rate. Returns a new array with the result of the dilated convolution.
val dilated_conv3d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr

dilated_conv3d ?padding input kernel strides dilations performs a 3-dimensional dilated convolution on the input array using the specified kernel.

  • padding specifies the padding strategy (default is "valid").
  • strides specifies the stride length.
  • dilations specifies the dilation rate. Returns a new array with the result of the dilated convolution.
val max_pool1d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr

max_pool1d ?padding input pool_size strides applies a 1-dimensional max pooling operation on the input array.

  • padding specifies the padding strategy (default is "valid").
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length. Returns a new array with the result of the max pooling.
val max_pool2d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr

max_pool2d ?padding input pool_size strides applies a 2-dimensional max pooling operation on the input array.

  • padding specifies the padding strategy (default is "valid").
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length. Returns a new array with the result of the max pooling.
val max_pool3d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr

max_pool3d ?padding input pool_size strides applies a 3-dimensional max pooling operation on the input array.

  • padding specifies the padding strategy (default is "valid").
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length. Returns a new array with the result of the max pooling.
val avg_pool1d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr

avg_pool1d ?padding input pool_size strides applies a 1-dimensional average pooling operation on the input array.

  • padding specifies the padding strategy (default is "valid").
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length. Returns a new array with the result of the average pooling.
val avg_pool2d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr

avg_pool2d ?padding input pool_size strides applies a 2-dimensional average pooling operation on the input array.

  • padding specifies the padding strategy (default is "valid").
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length. Returns a new array with the result of the average pooling.
val avg_pool3d : ?padding:Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr

avg_pool3d ?padding input pool_size strides applies a 3-dimensional average pooling operation on the input array.

  • padding specifies the padding strategy (default is "valid").
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length. Returns a new array with the result of the average pooling.
val upsampling2d : Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr

upsampling2d input size performs a 2-dimensional upsampling on the input array.

  • size specifies the upsampling factors for each dimension. Returns a new array with the upsampled data.

conv1d_backward_input input kernel strides grad_output computes the gradient of the loss with respect to the 1-dimensional input array.

  • input is the original input array.
  • kernel is the convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the convolutional layer. Returns a new array with the gradients of the input.

conv1d_backward_kernel input kernel strides grad_output computes the gradient of the loss with respect to the 1-dimensional convolutional kernel.

  • input is the original input array.
  • kernel is the convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the convolutional layer. Returns a new array with the gradients of the kernel.

conv2d_backward_input input kernel strides grad_output computes the gradient of the loss with respect to the 2-dimensional input array.

  • input is the original input array.
  • kernel is the convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the convolutional layer. Returns a new array with the gradients of the input.

conv2d_backward_kernel input kernel strides grad_output computes the gradient of the loss with respect to the 2-dimensional convolutional kernel.

  • input is the original input array.
  • kernel is the convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the convolutional layer. Returns a new array with the gradients of the kernel.

conv3d_backward_input input kernel strides grad_output computes the gradient of the loss with respect to the 3-dimensional input array.

  • input is the original input array.
  • kernel is the convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the convolutional layer. Returns a new array with the gradients of the input.

conv3d_backward_kernel input kernel strides grad_output computes the gradient of the loss with respect to the 3-dimensional convolutional kernel.

  • input is the original input array.
  • kernel is the convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the convolutional layer. Returns a new array with the gradients of the kernel.
val transpose_conv1d_backward_input : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

transpose_conv1d_backward_input input kernel strides grad_output computes the gradient of the loss with respect to the 1-dimensional input array for the transposed convolution operation.

  • input is the original input array.
  • kernel is the transposed convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the transposed convolutional layer. Returns a new array with the gradients of the input.
val transpose_conv1d_backward_kernel : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

transpose_conv1d_backward_kernel input kernel strides grad_output computes the gradient of the loss with respect to the 1-dimensional transposed convolutional kernel.

  • input is the original input array.
  • kernel is the transposed convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the transposed convolutional layer. Returns a new array with the gradients of the kernel.
val transpose_conv2d_backward_input : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

transpose_conv2d_backward_input input kernel strides grad_output computes the gradient of the loss with respect to the 2-dimensional input array for the transposed convolution operation.

  • input is the original input array.
  • kernel is the transposed convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the transposed convolutional layer. Returns a new array with the gradients of the input.
val transpose_conv2d_backward_kernel : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

transpose_conv2d_backward_kernel input kernel strides grad_output computes the gradient of the loss with respect to the 2-dimensional transposed convolutional kernel.

  • input is the original input array.
  • kernel is the transposed convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the transposed convolutional layer. Returns a new array with the gradients of the kernel.
val transpose_conv3d_backward_input : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

transpose_conv3d_backward_input input kernel strides grad_output computes the gradient of the loss with respect to the 3-dimensional input array for the transposed convolution operation.

  • input is the original input array.
  • kernel is the transposed convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the transposed convolutional layer. Returns a new array with the gradients of the input.
val transpose_conv3d_backward_kernel : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

transpose_conv3d_backward_kernel input kernel strides grad_output computes the gradient of the loss with respect to the 3-dimensional transposed convolutional kernel.

  • input is the original input array.
  • kernel is the transposed convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the transposed convolutional layer. Returns a new array with the gradients of the kernel.
val dilated_conv1d_backward_input : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

dilated_conv1d_backward_input input kernel strides dilations grad_output computes the gradient of the loss with respect to the 1-dimensional input array for the dilated convolution operation.

  • input is the original input array.
  • kernel is the dilated convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • dilations specifies the dilation rate.
  • grad_output is the gradient of the loss with respect to the output of the dilated convolutional layer. Returns a new array with the gradients of the input.
val dilated_conv1d_backward_kernel : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

dilated_conv1d_backward_kernel input kernel strides dilations grad_output computes the gradient of the loss with respect to the 1-dimensional dilated convolutional kernel.

  • input is the original input array.
  • kernel is the dilated convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • dilations specifies the dilation rate.
  • grad_output is the gradient of the loss with respect to the output of the dilated convolutional layer. Returns a new array with the gradients of the kernel.
val dilated_conv2d_backward_input : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

dilated_conv2d_backward_input input kernel strides dilations grad_output computes the gradient of the loss with respect to the 2-dimensional input array for the dilated convolution operation.

  • input is the original input array.
  • kernel is the dilated convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • dilations specifies the dilation rate.
  • grad_output is the gradient of the loss with respect to the output of the dilated convolutional layer. Returns a new array with the gradients of the input.
val dilated_conv2d_backward_kernel : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

dilated_conv2d_backward_kernel input kernel strides dilations grad_output computes the gradient of the loss with respect to the 2-dimensional dilated convolutional kernel.

  • input is the original input array.
  • kernel is the dilated convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • dilations specifies the dilation rate.
  • grad_output is the gradient of the loss with respect to the output of the dilated convolutional layer. Returns a new array with the gradients of the kernel.
val dilated_conv3d_backward_input : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

dilated_conv3d_backward_input input kernel strides dilations grad_output computes the gradient of the loss with respect to the 3-dimensional input array for the dilated convolution operation.

  • input is the original input array.
  • kernel is the dilated convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • dilations specifies the dilation rate.
  • grad_output is the gradient of the loss with respect to the output of the dilated convolutional layer. Returns a new array with the gradients of the input.
val dilated_conv3d_backward_kernel : Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

dilated_conv3d_backward_kernel input kernel strides dilations grad_output computes the gradient of the loss with respect to the 3-dimensional dilated convolutional kernel.

  • input is the original input array.
  • kernel is the dilated convolutional kernel used during the forward pass.
  • strides specifies the stride length.
  • dilations specifies the dilation rate.
  • grad_output is the gradient of the loss with respect to the output of the dilated convolutional layer. Returns a new array with the gradients of the kernel.
val max_pool1d_backward : Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

max_pool1d_backward padding input pool_size strides grad_output computes the gradient of the loss with respect to the 1-dimensional input array after max pooling.

  • padding specifies the padding strategy used during the forward pass.
  • input is the original input array.
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the max pooling layer. Returns a new array with the gradients of the input.
val max_pool2d_backward : Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

max_pool2d_backward padding input pool_size strides grad_output computes the gradient of the loss with respect to the 2-dimensional input array after max pooling.

  • padding specifies the padding strategy used during the forward pass.
  • input is the original input array.
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the max pooling layer. Returns a new array with the gradients of the input.
val max_pool3d_backward : Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

max_pool3d_backward padding input pool_size strides grad_output computes the gradient of the loss with respect to the 3-dimensional input array after max pooling.

  • padding specifies the padding strategy used during the forward pass.
  • input is the original input array.
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the max pooling layer. Returns a new array with the gradients of the input.
val avg_pool1d_backward : Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

avg_pool1d_backward padding input pool_size strides grad_output computes the gradient of the loss with respect to the 1-dimensional input array after average pooling.

  • padding specifies the padding strategy used during the forward pass.
  • input is the original input array.
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the average pooling layer. Returns a new array with the gradients of the input.
val avg_pool2d_backward : Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

avg_pool2d_backward padding input pool_size strides grad_output computes the gradient of the loss with respect to the 2-dimensional input array after average pooling.

  • padding specifies the padding strategy used during the forward pass.
  • input is the original input array.
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the average pooling layer. Returns a new array with the gradients of the input.
val avg_pool3d_backward : Owl_types.padding -> Symbol.Shape.Type.arr -> int array -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

avg_pool3d_backward padding input pool_size strides grad_output computes the gradient of the loss with respect to the 3-dimensional input array after average pooling.

  • padding specifies the padding strategy used during the forward pass.
  • input is the original input array.
  • pool_size specifies the size of the pooling window.
  • strides specifies the stride length.
  • grad_output is the gradient of the loss with respect to the output of the average pooling layer. Returns a new array with the gradients of the input.
val upsampling2d_backward : Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

upsampling2d_backward input size grad_output computes the gradient of the loss with respect to the input array after 2-dimensional upsampling.

  • input is the original input array.
  • size specifies the upsampling factors for each dimension.
  • grad_output is the gradient of the loss with respect to the output of the upsampling layer. Returns a new array with the gradients of the input.
val row_num : Symbol.Shape.Type.arr -> int

row_num arr returns the number of rows in the array arr.

val col_num : Symbol.Shape.Type.arr -> int

col_num arr returns the number of columns in the array arr.

row arr idx extracts the row at index idx from the array arr. Returns a new array containing the specified row.

val rows : Symbol.Shape.Type.arr -> int array -> Symbol.Shape.Type.arr

rows arr indices extracts multiple rows specified by indices from the array arr. Returns a new array containing the selected rows.

val copy_row_to : Symbol.Shape.Type.arr -> 'a -> 'b -> unit

copy_row_to src src_idx dest_idx copies the row at index src_idx in the array src to the row at index dest_idx.

val copy_col_to : Symbol.Shape.Type.arr -> 'a -> 'b -> unit

copy_col_to src src_idx dest_idx copies the column at index src_idx in the array src to the column at index dest_idx.

diag ?k arr extracts the k-th diagonal from the array arr. If k is not provided, the main diagonal is extracted. Returns a new array containing the diagonal elements.

trace arr computes the sum of the elements on the main diagonal of the array arr. Returns the trace as an element.

dot a b computes the dot product of the arrays a and b. Returns a new array with the result of the dot product.

val transpose : ?axis:int array -> Symbol.Shape.Type.arr -> Symbol.Shape.Type.arr

transpose ?axis arr transposes the array arr. If axis is provided, the transpose is performed according to the specified axes. Returns a new array with the transposed data.

val to_rows : Symbol.Shape.Type.arr -> 'a array

to_rows arr converts the array arr into an array of row vectors. Returns an array where each element is a row from the original array.

of_rows rows creates an array by stacking the row vectors in rows. Returns a new array constructed from the row vectors.

val to_cols : Symbol.Shape.Type.arr -> 'a array

to_cols arr converts the array arr into an array of column vectors. Returns an array where each element is a column from the original array.

of_cols cols creates an array by stacking the column vectors in cols. Returns a new array constructed from the column vectors.

val of_array : Symbol.Shape.Type.elt array -> int array -> Symbol.Shape.Type.arr

of_array data shape creates an array from a flat array data with the specified shape. Returns a new array with the data arranged according to the shape.

val of_arrays : Symbol.Shape.Type.elt array array -> Symbol.Shape.Type.arr

of_arrays data creates an array from a 2D array data, where each sub-array represents a row. Returns a new array with the data from the 2D array.

val to_arrays : Symbol.Shape.Type.arr -> Symbol.Shape.Type.elt array array

to_arrays arr converts the array arr into a 2D array where each sub-array represents a row. Returns a 2D array with the data from the original array.

Scalar functions
module Scalar : sig ... end
module Mat : sig ... end
module Linalg : sig ... end