2 releases

0.1.1 Mar 21, 2024
0.1.0 Mar 9, 2024

#942 in Machine learning

Download history 13/week @ 2024-03-14 126/week @ 2024-03-21 24/week @ 2024-03-28 14/week @ 2024-04-04

74 downloads per month

MIT/Apache

170KB
4K SLoC

zyx-derive

This crate contains procedural macros for zyx.

Macro Module automatically implements IntoIterator<Item = &Tensor> for your module, so that you can use it in backpropagation and save it to disk.

use zyx_core::backend::Backend;
use zyx_core::tensor::Tensor;

#[derive(Module)]
struct MyNet<B: Backend> {
    b: Tensor<B>,
    w: Tensor<B>,
}

impl<B: Backend> MyNet<B> {
    fn forward(&self, x: &Tensor<B>) -> Tensor<B> {
        x.dot(self.w) + self.b
    }
}

For README and source code, please visit github.

For more details, there is a book.

Features

  • std - enables zyx-core/std

lib.rs:

zyx-derive

This crate contains procedural macros for zyx.

Macro Module automatically implements IntoIterator<Item = &Tensor> for your module, so that you can use it in backpropagation and save it to disk.

use zyx_core::backend::Backend;
use zyx_core::tensor::Tensor;
use zyx_derive::Module;

#[derive(Module)]
struct MyNet<B: Backend> {
    b: Tensor<B>,
    w: Tensor<B>,
}

impl<B: Backend> MyNet<B> {
    fn forward(&self, x: &Tensor<B>) -> Tensor<B> {
        x.dot(&self.w) + &self.b
    }
}

For README, quick tutorial and source code, please visit https://www.github.com/zk4x/zyx.

For more details, there is a book.

Dependencies

~0.5–1MB
~22K SLoC