use burn::module::Module;
use burn::nn::BatchNorm;
use burn::nn::BatchNormConfig;
use burn::tensor::backend::Backend;
use burn::tensor::Tensor;
#[derive(Module, Debug)]
pub struct BatchNormTT1d<B: Backend> {
pub layers: Vec<BatchNorm<B, 1>>,
}
impl<B: Backend> BatchNormTT1d<B> {
pub fn new(num_steps: usize, num_features: usize, device: &B::Device) -> Self {
let config = BatchNormConfig::new(num_features);
let layers = (0..num_steps)
.map(|_| config.init::<B, 1>(device))
.collect();
Self { layers }
}
pub fn forward(&self, step_index: usize, x: Tensor<B, 3>) -> Tensor<B, 3> {
self.layers[step_index].forward(x)
}
}
#[derive(Module, Debug)]
pub struct BatchNormTT2d<B: Backend> {
pub layers: Vec<BatchNorm<B, 2>>,
}
impl<B: Backend> BatchNormTT2d<B> {
pub fn new(num_steps: usize, num_features: usize, device: &B::Device) -> Self {
let config = BatchNormConfig::new(num_features);
let layers = (0..num_steps)
.map(|_| config.init::<B, 2>(device))
.collect();
Self { layers }
}
pub fn forward(&self, step_index: usize, x: Tensor<B, 4>) -> Tensor<B, 4> {
self.layers[step_index].forward(x)
}
}