Array
The Endia Array
is the main data structure for storing and manipulating multi-dimensional data.
fn __init__(inout self, shape: List[Int], requires_grad: Bool = False, is_complex: Bool = False)
Args
- shape (List[Int]): The shape of the array.
- requires_grad (Bool): Whether to track gradients for this array. (optional, default: False)
- is_complex (Bool): Whether the array contains complex numbers. (optional, default: False)
Endia Arrays behave in a similar way to PyTorch Tensors
or Jax ndarrays
.
Array creation
- array: Create an array from a string or a list
- zeros: Create an array filled with zeros with a given shape
- randu: Create an array filled with random numbers from a uniform distribution
- randn: Create an array filled with random numbers from a normal distribution
- full: Create an array filled with a scalar value and a given shape
- complex: Create a complex array from two real arrays
Methods
- Unary Operations: Trigonometric, exponential, logarithmic, ...
- Binary Operations: Addition, multiplication, division, ...
- Comparison Operations: Equal, greater, less, ...
- Reduce Operations: Sum, mean, ...
- View Operations: Reshape, slice, permute, ...
- Spacial Operations: Convolution, pooling, ...
- Stacking and Concatenation: Concatenate, pad, ...
- backward: Compute the gradients of the array with respect to the input arrays
See the complete list of operations here.
Example
import endia as nd
# Create a 2x2 array
a = nd.array('[[1, 2], [3, 4]]')
b = nd.array('[[5, 6], [7, 8]]')
# Compute the sum of the arrays
c = a + b
# Print the result
print(c)
# Output:
# Array([[6., 8.],
# [10., 12.]], shape=(2, 2), dtype=float3232)