How to Use the candle ML Framework in Rust

Use the candle crate to build and run deep learning models in Rust by adding dependencies and initializing tensors.

There is no official "candle ML framework" in Rust; you are likely looking for the candle crate, a deep learning library. Add it to your project and initialize a model to start using it.

[dependencies]
candle-core = "0.8"
candle-nn = "0.8"
use candle_core as candle;
use candle_nn::Module;

fn main() -> candle::Result<()> {
    let device = candle::Device::Cpu;
    let model = candle_nn::linear(10, 5, &device)?;
    let input = candle::Tensor::randn(0., 1., (1, 10), &device)?;
    let output = model.forward(&input)?;
    Ok(())
}