rotta_rs 0.0.5

a Deep Learning library with rust language
Documentation

ROTTA Logo

ROTTA-rs

A Deep Learning Library In Rust 🦀

🛠️ still in development stage 🛠️


📦 Version: 0.0.5

✨ New Features

  • arange method for create tensor
    let tensor = Tensor::arange(0, 10, 2); // (start, stop, step)
    println!("{}", tensor) // [0.0, 2.0, 4.0, 6.0, 8.0]
  • concat method for combining tensors in vectors
fn main() {
    let tensor_a = Tensor::new([[1.0, 2.0, 3.0, 4.0, 5.0]]);
    let tensor_b = Tensor::new([[6.0, 7.0, 8.0, 9.0, 10.0]]);
    let vector = vec![&tensor_a, &tensor_b];

    let tensor = concat(vector, 0);
    println!("{}", tensor);     // [
                                //  [1.0, 2.0, 3.0, 4.0, 5.0]
                                //  [6.0, 7.0, 8.0, 9.0, 10.0]
                                // ]    
}
  • new method for slicing
fn main() {
    let tensor_a = Tensor::arange(0, 12, 1).reshape(vec![-1, 3]);
    println!("{}", tensor_a);
    // [
    //  [0.0, 1.0, 2.0]
    //  [3.0, 4.0, 5.0]
    //  [6.0, 7.0, 8.0]
    //  [9.0, 10.0, 11.0]
    // ]

    // before 0.0.5
    let slicing = tensor_a.slice(vec![ArrSlice(Some(0), Some(2)), ArrSlice(Some(1), None)]);
    println!("{}", slicing);
    // [
    //  [1.0, 2.0]
    //  [4.0, 5.0]
    // ]

    // 0.0.5
    let slicing = tensor_a.slice(vec![r(0..2), r(1..)]);
    println!("{}", slicing)
    // [
    //  [1.0, 2.0]
    //  [4.0, 5.0]
    // ]
}
  • new method for sum axis and sum axis keep dim
fn main() {
    let tensor_a = Tensor::arange(0, 12, 1).reshape(vec![-1, 3]);
    println!("{}", tensor_a);
    // [
    //  [0.0, 1.0, 2.0]
    //  [3.0, 4.0, 5.0]
    //  [6.0, 7.0, 8.0]
    //  [9.0, 10.0, 11.0]
    // ]

    // before 0.0.5
    // let sum = tensor_a.sum_axis(0); // in version 0.0.5, it can no longer be done

    // 0.0.5
    let slicing = tensor_a.sum_axis(&[0]);
    println!("{}", slicing);
    // [18.0, 22.0, 26.0]

    let slicing = tensor_a.sum_axis_keep_dim(&[0, 1]);
    println!("{}", slicing);
    // [
    //  [66.0]
    // ]
}
  • mean & mean axis & mean axis keep dim

see more details in guide.md tensor section

  • RMSProp

see more details in guide.md Optimazer section

  • Adam

see more details in guide.md Optimazer section

  • Layer Norm

see more details in guide.md Module section

  • Batch Norm

see more details in guide.md Module section

  • Dataset & DataHandler

see more details in guide.md Dataset and DataHandler section

🚀 Optimizations

  • implemented SIMD for matmul

🛠️ Bug Fixes

  • Broadcast error during scalar operation
  • Broadcast error when [x] will be broadcast to [1, x]

📌 Check all releases: Tags
📜 Full changelog: version.md


⚙️ Installation

ROTTA-rs can be installed directly through crates.io. To use it:

[dependencies]
rotta_rs = "0.0.5"

🧠 Simple AI Model

use rotta_rs::*;

fn main() {
    let mut model = Module::init();
    let optimazer = Sgd::init(model.parameters(), 0.00001);
    let loss_fn = SSResidual::init();

    let linear = model.liniar_init(1, 1);
    let linear_2 = model.liniar_init(1, 1);

    let input = Tensor::new([[1.0], [2.0]]);
    let actual = Tensor::new([[1.0], [4.0]]);

    for epoch in 0..100 {
        let x = linear.forward(&input);
        let x = relu(&x);
        let output = linear_2.forward(&x);

        let loss = loss_fn.forward(&output, &actual);
        println!("epoch:{epoch} | loss => {loss}");

        optimazer.zero_grad();

        let backward = loss.backward();

        optimazer.optim(backward);
    }
}

📚 GUIDE

📘 Start learning: 🧭 GUIDE.md

👍️ Support the Developer

If you find this project useful, you can support further development via:

🔗 saweria

🌐 Connect with Me

  • youtube

araxnoid

click here to go directly to youtube

  • tiktok

araxnoid

click here to go directly to tiktok

contact

  • Gmail

araxnoid0@gmail.com

📥 Dependencies