5.3. clumsygrad.math#

This module provides basic mathematical operations.

clumsygrad.math.sum(tensor: Tensor, axis: int | tuple[int, ...] | None = None, keepdims: bool = False) → Tensor[source]#

Compute the sum of the tensor along specified axis.

Parameters:
  • tensor – The input Tensor to compute the sum of.

  • axis – Axis or axes along which the sum is computed. If None, computes the sum of the flattened array.

  • keepdims – If True, the reduced axes are left in the result as dimensions with size one.

Returns:

A new Tensor containing the sum of the input tensor.

clumsygrad.math.mean(tensor: Tensor, axis: int | tuple[int, ...] | None = None, keepdims: bool = False) → Tensor[source]#

Compute the mean of the tensor along specified axis.

Parameters:
  • tensor – The input Tensor to compute the mean of.

  • axis – Axis or axes along which the means are computed. If None, computes the mean of the flattened array.

  • keepdims – If True, the reduced axes are left in the result as dimensions with size one.

Returns:

A new Tensor containing the mean of the input tensor.

clumsygrad.math.abs(tensor: Tensor) → Tensor[source]#

Compute the absolute value of the tensor.

clumsygrad.math.sqrt(tensor: Tensor) → Tensor[source]#

Compute the square root of the tensor.

clumsygrad.math.exp(tensor: Tensor) → Tensor[source]#

Compute the exponential of the tensor.

clumsygrad.math.log(tensor: Tensor) → Tensor[source]#

Compute the natural logarithm of the tensor.

clumsygrad.math.sin(tensor: Tensor) → Tensor[source]#

Compute the sine of the tensor.

clumsygrad.math.cos(tensor: Tensor) → Tensor[source]#

Compute the cosine of the tensor.

clumsygrad.math.tan(tensor: Tensor) → Tensor[source]#

Compute the tangent of the tensor.