Modules. Here is the module trait:
Linear is defined:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Composable building blocks of complex neural networks.
Modules. Here is the module trait:
/// A module with a forward pass
pub trait Module<I> {
type Output;
fn forward(&self, input: I) -> Self::Output;
}
Linear is defined:
/// A simple linear layer
pub struct Linear<const A: usize, const B: usize> {
pub(crate) weight: GraphTensor<R2<A, B>>,
}
impl<const A: usize, const B: usize> Module<GraphTensor<R1<A>>> for Linear<A, B> {
type Output = GraphTensor<R1<B>>;
fn forward(&self, input: GraphTensor<R1<A>>) -> Self::Output {
input.matmul(self.weight)
}
}
