Trait AsModule

Source
pub trait AsModule {
    type Module: Module;

    // Required methods
    fn as_module(&self) -> &Self::Module;
    fn as_module_mut(&mut self) -> &mut Self::Module;

    // Provided method
    fn batch_map<F: Fn(Tensor) -> Tensor>(self, f: F) -> BatchMap<Self, F>
       where Self: Sized { ... }
}
Expand description

A trait for module wrappers that allow borrowing the contained Module.

Required Associated Types§

Required Methods§

Source

fn as_module(&self) -> &Self::Module

Source

fn as_module_mut(&mut self) -> &mut Self::Module

Provided Methods§

Source

fn batch_map<F: Fn(Tensor) -> Tensor>(self, f: F) -> BatchMap<Self, F>
where Self: Sized,

Apply a batch-structure-preserving function to the module output.

Implementors§

Source§

impl<M: Module, O> AsModule for Ppo<M, O>

Source§

impl<M: Module, O> AsModule for Reinforce<M, O>

Source§

impl<M: Module, O> AsModule for Trpo<M, O>

Source§

impl<T: AsModule> AsModule for WithCpuCopy<T>

Source§

impl<T: AsModule, F> AsModule for BatchMap<T, F>

Source§

impl<T: Module> AsModule for T