modelbuilder

Crates.iomodelbuilder
lib.rsmodelbuilder
version0.0.1
sourcesrc
created_at2023-11-19 00:41:17.244158
updated_at2023-11-19 00:41:17.244158
descriptionArtificial intelligence and neural network model building architecture.
homepagehttps://github.com/rustml/modelbuilder
repositoryhttps://github.com/rustml/modelbuilder
max_upload_size
id1040824
size65,045
Ryan Kopf (ryankopf)

documentation

README

Model Builder

Artificial intelligence and neural network model building architecture.

Installation

You will need to follow the installation guide for candle-core as described in Installation.

use candle_nn::{Linear, LayerNorm, Module};
use candle_core::{Tensor, Device::Cpu};
use modelbuilder::{ModelBuilder, GenericLayer};

fn main() -> candle_core::Result<()> {
    // Create the ModelBuilder
    let model_builder = ModelBuilder::new()
        .add_layer(Linear::new(
            Tensor::new(&[[1., 2.], [3., 4.]], &Cpu)?, 
            Some(Tensor::new(&[0.5, 1.0], &Cpu)?)
        ))
        .add_layer(LayerNorm::new(
            Tensor::new(1., &Cpu)?, 
            Tensor::new(0., &Cpu)?, 
            1e-5
        ));

    // Sample input tensor
    let input = Tensor::new(&[[0.5, 1.5]], &Cpu)?;

    // Use the ModelBuilder's forward method,
    // sending the input tensor through the model.
    let final_output = model_builder.forward(&input)?;

    println!("Output: {:?}", final_output);
    Ok(())
}
Commit count: 5

cargo fmt