Crate zyx_derive
source ·Expand description
§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.
Derive Macros§
- Procedural macro Module