Struct AsyncPolicy
pub struct AsyncPolicy<P>where
P: Policy,{ /* private fields */ }Expand description
An asynchronous policy using an inference server with autobatching.
Implementations§
§impl<P> AsyncPolicy<P>
impl<P> AsyncPolicy<P>
pub fn new(autobatch_size: usize, inner_policy: P) -> AsyncPolicy<P>
pub fn new(autobatch_size: usize, inner_policy: P) -> AsyncPolicy<P>
Create the policy.
§Arguments
autobatch_size- Number of observations to accumulate before running a pass of inference.inner_policy- The policy used to take actions.
pub fn increment_agents(&self, num: usize)
pub fn increment_agents(&self, num: usize)
Increment the number of agents using the inference server.
pub fn decrement_agents(&self, num: usize)
pub fn decrement_agents(&self, num: usize)
Decrement the number of agents using the inference server.
Trait Implementations§
§impl<P> Clone for AsyncPolicy<P>
impl<P> Clone for AsyncPolicy<P>
§fn clone(&self) -> AsyncPolicy<P>
fn clone(&self) -> AsyncPolicy<P>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read more§impl<P> Policy for AsyncPolicy<P>
impl<P> Policy for AsyncPolicy<P>
§type ActionContext = <P as Policy>::ActionContext
type ActionContext = <P as Policy>::ActionContext
Additional context on the policy’s decision.
§type PolicyState = <P as Policy>::PolicyState
type PolicyState = <P as Policy>::PolicyState
The current parameterization of the policy.
§type Observation = <P as Policy>::Observation
type Observation = <P as Policy>::Observation
The observation given as input to the policy.
§type ActionDistribution = <P as Policy>::ActionDistribution
type ActionDistribution = <P as Policy>::ActionDistribution
The action distribution parameters defining how the action will be sampled.
§fn forward(
&mut self,
states: <AsyncPolicy<P> as Policy>::Observation,
) -> <AsyncPolicy<P> as Policy>::ActionDistribution
fn forward( &mut self, states: <AsyncPolicy<P> as Policy>::Observation, ) -> <AsyncPolicy<P> as Policy>::ActionDistribution
Produces the action distribution from a batch of observations.
§fn action(
&mut self,
states: <AsyncPolicy<P> as Policy>::Observation,
deterministic: bool,
) -> (<AsyncPolicy<P> as Policy>::Action, Vec<<AsyncPolicy<P> as Policy>::ActionContext>)
fn action( &mut self, states: <AsyncPolicy<P> as Policy>::Observation, deterministic: bool, ) -> (<AsyncPolicy<P> as Policy>::Action, Vec<<AsyncPolicy<P> as Policy>::ActionContext>)
Gives the action from a batch of observations.
§fn update(&mut self, update: <AsyncPolicy<P> as Policy>::PolicyState)
fn update(&mut self, update: <AsyncPolicy<P> as Policy>::PolicyState)
Update the policy’s parameters.
§fn state(&self) -> <AsyncPolicy<P> as Policy>::PolicyState
fn state(&self) -> <AsyncPolicy<P> as Policy>::PolicyState
Returns the current parameterization.
§fn to_device(self, device: &Device) -> AsyncPolicy<P>
fn to_device(self, device: &Device) -> AsyncPolicy<P>
Loads the policy on the given device.
§fn load_record(
self,
_record: <<AsyncPolicy<P> as Policy>::PolicyState as PolicyState>::Record,
) -> AsyncPolicy<P>
fn load_record( self, _record: <<AsyncPolicy<P> as Policy>::PolicyState as PolicyState>::Record, ) -> AsyncPolicy<P>
Loads the policy parameters from a record.
Auto Trait Implementations§
impl<P> Freeze for AsyncPolicy<P>
impl<P> RefUnwindSafe for AsyncPolicy<P>
impl<P> Send for AsyncPolicy<P>where
<P as Policy>::PolicyState: Send,
<P as Policy>::Observation: Send,
<P as Policy>::ActionDistribution: Send,
<P as Policy>::Action: Send,
<P as Policy>::ActionContext: Send,
impl<P> Sync for AsyncPolicy<P>where
<P as Policy>::PolicyState: Send,
<P as Policy>::Observation: Send,
<P as Policy>::ActionDistribution: Send,
<P as Policy>::Action: Send,
<P as Policy>::ActionContext: Send,
impl<P> Unpin for AsyncPolicy<P>
impl<P> UnsafeUnpin for AsyncPolicy<P>
impl<P> UnwindSafe for AsyncPolicy<P>
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<K, Q> Comparable<Q> for K
impl<K, Q> Comparable<Q> for K
§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
Compare self to
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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>
Converts
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>
Converts
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