use crate::error::Error;
use crate::neural_network::layers::recurrent::simple_rnn::SimpleRNN;
use crate::neural_network::traits::ApplyWeights;
use ndarray::Array2;
use serde::{Deserialize, Serialize};
use std::borrow::Cow;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SimpleRNNLayerWeight<'a> {
pub kernel: Cow<'a, Array2<f32>>,
pub recurrent_kernel: Cow<'a, Array2<f32>>,
pub bias: Cow<'a, Array2<f32>>,
}
impl ApplyWeights<SimpleRNN> for SimpleRNNLayerWeight<'_> {
fn apply_to_layer(&self, layer: &mut SimpleRNN) -> Result<(), Error> {
layer.set_weights(
(*self.kernel).clone(),
(*self.recurrent_kernel).clone(),
(*self.bias).clone(),
)?;
Ok(())
}
}