Autograd API Reference
The autograd module provides automatic differentiation.
Tensor
The core data structure for autograd.
zig
pub fn Tensor(comptime T: type) typeLifecycle
init
Initialize a tensor.
zig
pub fn init(allocator: Allocator, data: NDArray(T), requires_grad: bool) !*Selfdeinit
Deinitialize the tensor.
zig
pub fn deinit(self: *Self, allocator: Allocator) voidGradients
backward
Compute gradients.
zig
pub fn backward(self: *Self, allocator: Allocator) !voidOperations
add
Element-wise addition.
zig
pub fn add(self: *Self, allocator: Allocator, other: *Self) !*Selfmul
Element-wise multiplication.
zig
pub fn mul(self: *Self, allocator: Allocator, other: *Self) !*Selfmatmul
Matrix multiplication.
zig
pub fn matmul(self: *Self, allocator: Allocator, other: *Self) !*SelfActivation Functions
relu
Rectified Linear Unit.
zig
pub fn relu(self: *Self, allocator: Allocator) !*Selfsigmoid
Sigmoid activation.
zig
pub fn sigmoid(self: *Self, allocator: Allocator) !*Selftanh
Hyperbolic tangent activation.
zig
pub fn tanh(self: *Self, allocator: Allocator) !*Selfsoftmax
Softmax activation.
zig
pub fn softmax(self: *Self, allocator: Allocator) !*SelfLoss Functions
mse_loss
Mean Squared Error loss.
zig
pub fn mse_loss(self: *Self, allocator: Allocator, target: *Self) !*Selfcross_entropy_loss
Cross Entropy loss.
zig
pub fn cross_entropy_loss(self: *Self, allocator: Allocator, target: *Self) !*Self