pub struct EpsilonInjector<T: Inferer, NG: NoiseGenerator = HighQualityNoiseGenerator> { /* private fields */ }Expand description
The EpsilonInjector wraps an inferer to add noise values as one of the input data points. This is useful for
continuous action policies where you might have trained your agent to follow a stochastic policy trained with the
reparametrization trick.
Note that it’s fully possible to pass an epsilon directly in your observation, and this is purely a convenience wrapper.
Implementations§
Source§impl<T> EpsilonInjector<T, HighQualityNoiseGenerator>where
T: Inferer,
impl<T> EpsilonInjector<T, HighQualityNoiseGenerator>where
T: Inferer,
Sourcepub fn wrap(
inferer: T,
key: &str,
) -> Result<EpsilonInjector<T, HighQualityNoiseGenerator>>
pub fn wrap( inferer: T, key: &str, ) -> Result<EpsilonInjector<T, HighQualityNoiseGenerator>>
Wraps the provided inferer to automatically generate noise for the input named by key.
This function will use HighQualityNoiseGenerator as the noise source.
§Errors
Will return an error if the provided key doesn’t match an input on the model.
Source§impl<T, NG> EpsilonInjector<T, NG>where
T: Inferer,
NG: NoiseGenerator,
impl<T, NG> EpsilonInjector<T, NG>where
T: Inferer,
NG: NoiseGenerator,
Sourcepub fn with_generator(inferer: T, generator: NG, key: &str) -> Result<Self>
pub fn with_generator(inferer: T, generator: NG, key: &str) -> Result<Self>
Create a new injector for the provided key, using the custom generator as the noise source.
§Errors
Will return an error if the provided key doesn’t match an input on the model.
Trait Implementations§
Source§impl<T, NG> Inferer for EpsilonInjector<T, NG>where
T: Inferer,
NG: NoiseGenerator,
impl<T, NG> Inferer for EpsilonInjector<T, NG>where
T: Inferer,
NG: NoiseGenerator,
Source§fn select_batch_size(&self, max_count: usize) -> usize
fn select_batch_size(&self, max_count: usize) -> usize
Source§fn infer_raw(&self, batch: &mut ScratchPadView<'_>) -> Result<(), Error>
fn infer_raw(&self, batch: &mut ScratchPadView<'_>) -> Result<(), Error>
Source§fn input_shapes(&self) -> &[(String, Vec<usize>)]
fn input_shapes(&self) -> &[(String, Vec<usize>)]
Source§fn raw_input_shapes(&self) -> &[(String, Vec<usize>)]
fn raw_input_shapes(&self) -> &[(String, Vec<usize>)]
Source§fn raw_output_shapes(&self) -> &[(String, Vec<usize>)]
fn raw_output_shapes(&self) -> &[(String, Vec<usize>)]
fn begin_agent(&self, id: u64)
fn end_agent(&self, id: u64)
Auto Trait Implementations§
impl<T, NG> Freeze for EpsilonInjector<T, NG>
impl<T, NG> RefUnwindSafe for EpsilonInjector<T, NG>where
T: RefUnwindSafe,
NG: RefUnwindSafe,
impl<T, NG> Send for EpsilonInjector<T, NG>
impl<T, NG> Sync for EpsilonInjector<T, NG>
impl<T, NG> Unpin for EpsilonInjector<T, NG>
impl<T, NG> UnwindSafe for EpsilonInjector<T, NG>where
T: UnwindSafe,
NG: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> InfererExt for Twhere
T: Inferer,
impl<T> InfererExt for Twhere
T: Inferer,
Source§fn with_default_epsilon(self, key: &str) -> Result<EpsilonInjector<Self>>
fn with_default_epsilon(self, key: &str) -> Result<EpsilonInjector<Self>>
Source§fn with_epsilon<G: NoiseGenerator>(
self,
generator: G,
key: &str,
) -> Result<EpsilonInjector<Self, G>>
fn with_epsilon<G: NoiseGenerator>( self, generator: G, key: &str, ) -> Result<EpsilonInjector<Self, G>>
Source§fn into_batched(self) -> Batched<Self>
fn into_batched(self) -> Batched<Self>
Source§fn infer(
&mut self,
observations: HashMap<u64, State<'_>>,
) -> Result<HashMap<u64, Response<'_>>, Error>
fn infer( &mut self, observations: HashMap<u64, State<'_>>, ) -> Result<HashMap<u64, Response<'_>>, Error>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more