use crate::params_base::ParamsBase;
use crate::iter::{ParamsIter, ParamsIterMut};
use ndarray::iter as nditer;
use ndarray::{Axis, Data, DataMut, Dimension, RawData, RemoveAxis};
impl<A, S, D> ParamsBase<S, D, A>
where
S: RawData<Elem = A>,
D: Dimension,
{
pub fn iter(&self) -> ParamsIter<'_, A, D>
where
D: RemoveAxis,
S: Data,
{
ParamsIter {
bias: self.bias().iter(),
weights: self.weights().axis_iter(Axis(1)),
}
}
pub fn iter_mut(&mut self) -> ParamsIterMut<'_, A, D>
where
D: RemoveAxis,
S: DataMut,
{
ParamsIterMut {
bias: self.bias.iter_mut(),
weights: self.weights.axis_iter_mut(Axis(0)),
}
}
pub fn iter_bias(&self) -> nditer::Iter<'_, A, D::Smaller>
where
S: Data,
{
self.bias().iter()
}
pub fn iter_bias_mut(&mut self) -> nditer::IterMut<'_, A, D::Smaller>
where
S: DataMut,
{
self.bias_mut().iter_mut()
}
pub fn iter_weights(&self) -> nditer::Iter<'_, A, D>
where
S: Data,
{
self.weights().iter()
}
pub fn iter_weights_mut(&mut self) -> nditer::IterMut<'_, A, D>
where
S: DataMut,
{
self.weights_mut().iter_mut()
}
pub fn axis_iter_weights(&self, axis: Axis) -> nditer::AxisIter<'_, A, D::Smaller>
where
D: RemoveAxis,
S: Data,
{
self.weights().axis_iter(axis)
}
pub fn axis_iter_weights_mut(&mut self, axis: Axis) -> nditer::AxisIterMut<'_, A, D::Smaller>
where
D: RemoveAxis,
S: DataMut,
{
self.weights_mut().axis_iter_mut(axis)
}
}