pub struct Repeated<T, const N: usize> {
pub modules: Vec<T>,
}
Expand description
Repeats T
N
times. This requires that T
’s input is the same as it’s output.
Generics
T
the Module to repeatN
the number of times to repeatT
.
Examples
type Model = Repeated<(Linear<10, 10>, ReLU), 5>;
let model = dev.build_module::<Model, f32>();
let out: Tensor<Rank1<10>, f32, _> = model.forward(dev.zeros());
Fields§
§modules: Vec<T>
Trait Implementations§
source§impl<D: Device<E>, E: Dtype, T: BuildOnDevice<D, E>, const N: usize> BuildOnDevice<D, E> for Repeated<T, N>
impl<D: Device<E>, E: Dtype, T: BuildOnDevice<D, E>, const N: usize> BuildOnDevice<D, E> for Repeated<T, N>
source§impl<Input, T: Module<Input, Output = Input>, const N: usize> Module<Input> for Repeated<T, N>
impl<Input, T: Module<Input, Output = Input>, const N: usize> Module<Input> for Repeated<T, N>
source§impl<Input, T: ModuleMut<Input, Output = Input>, const N: usize> ModuleMut<Input> for Repeated<T, N>
impl<Input, T: ModuleMut<Input, Output = Input>, const N: usize> ModuleMut<Input> for Repeated<T, N>
source§impl<E: Dtype, D: Device<E>, T: TensorCollection<E, D>, const N: usize> TensorCollection<E, D> for Repeated<T, N>
impl<E: Dtype, D: Device<E>, T: TensorCollection<E, D>, const N: usize> TensorCollection<E, D> for Repeated<T, N>
§type To<E2: Dtype, D2: Device<E2>> = Repeated<<T as TensorCollection<E, D>>::To<E2, D2>, N>
type To<E2: Dtype, D2: Device<E2>> = Repeated<<T as TensorCollection<E, D>>::To<E2, D2>, N>
Type alias that specifies the how a module’s type changes when using a different dtype and/or
device.
source§fn iter_tensors<V: ModuleVisitor<Self, E, D>>(
visitor: &mut V
) -> Result<Option<Self::To<V::E2, V::D2>>, V::Err>
fn iter_tensors<V: ModuleVisitor<Self, E, D>>( visitor: &mut V ) -> Result<Option<Self::To<V::E2, V::D2>>, V::Err>
Specifies how to iterate through tensors or modules containted within this module, and how
to contruct this module given values for its fields. Returns
Err(_)
to indicate an error,
Ok(None)
to indicate that there is no error and a module has not been built, and
Ok(Some(_))
contains Self::Output<E2, D2>
source§fn module<F1, F2, Field>(
name: &str,
get_ref: F1,
get_mut: F2
) -> ModuleField<'_, F1, F2, Self, Field>where
F1: FnMut(&Self) -> &Field,
F2: FnMut(&mut Self) -> &mut Field,
Field: TensorCollection<E, D>,
fn module<F1, F2, Field>( name: &str, get_ref: F1, get_mut: F2 ) -> ModuleField<'_, F1, F2, Self, Field>where F1: FnMut(&Self) -> &Field, F2: FnMut(&mut Self) -> &mut Field, Field: TensorCollection<E, D>,
Creates a ModuleFields that represents a field that may contain one or more tensors. Read more
source§fn tensor<F1, F2, S>(
name: &str,
get_ref: F1,
get_mut: F2,
options: TensorOptions<S, E, D>
) -> TensorField<'_, F1, F2, Self, S, E, D>where
F1: FnMut(&Self) -> &Tensor<S, E, D>,
F2: FnMut(&mut Self) -> &mut Tensor<S, E, D>,
S: Shape,
fn tensor<F1, F2, S>( name: &str, get_ref: F1, get_mut: F2, options: TensorOptions<S, E, D> ) -> TensorField<'_, F1, F2, Self, S, E, D>where F1: FnMut(&Self) -> &Tensor<S, E, D>, F2: FnMut(&mut Self) -> &mut Tensor<S, E, D>, S: Shape,
Creates a ModuleFields that represents a tensor field. Read more