Skip to main content
Glama
8b-is
by 8b-is
linear.rs781 B
//! A basic linear layer. use crate::nn::Module; use crate::tensor::Tensor; pub struct Linear { weights: Tensor, bias: Tensor, } impl Linear { pub fn new(in_features: usize, out_features: usize) -> Self { println!( "INFO: Initializing Linear layer with in_features={}, out_features={}", in_features, out_features ); Self { weights: Tensor::rand(vec![in_features, out_features]), bias: Tensor::zeros(vec![out_features]), } } } impl Module for Linear { fn forward(&self, input: &Tensor) -> Tensor { let x = input.matmul(&self.weights); &x + &self.bias } fn parameters(&self) -> Vec<Tensor> { vec![self.weights.clone(), self.bias.clone()] } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/8b-is/smart-tree'

If you have feedback or need assistance with the MCP directory API, please join our Discord server