AI_Zig/src/activations.zig
2026-02-03 14:58:24 +01:00

14 lines
269 B
Zig

const std = @import("std");
pub const Sigmoid = struct {
pub fn apply(x: f32) f32 {
return 1.0 / (1.0 + std.math.exp(-x));
}
pub fn derivative(y: f32) f32 {
return y * (1.0 - y);
}
};
// Possiamo aggiungere ReLU, Tanh, ecc. in futuro