pub struct AsyncPolicy<B: Backend, P: Policy<B>> { /* private fields */ }Expand description
An asynchronous policy using an inference server with autobatching.
Implementations§
Source§impl<B, P> AsyncPolicy<B, P>
impl<B, P> AsyncPolicy<B, P>
Sourcepub fn new(autobatch_size: usize, inner_policy: P) -> Self
pub fn new(autobatch_size: usize, inner_policy: P) -> Self
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.
Sourcepub fn increment_agents(&self, num: usize)
pub fn increment_agents(&self, num: usize)
Increment the number of agents using the inference server.
Sourcepub fn decrement_agents(&self, num: usize)
pub fn decrement_agents(&self, num: usize)
Decrement the number of agents using the inference server.
Trait Implementations§
Source§impl<B: Clone + Backend, P: Clone + Policy<B>> Clone for AsyncPolicy<B, P>
impl<B: Clone + Backend, P: Clone + Policy<B>> Clone for AsyncPolicy<B, P>
Source§fn clone(&self) -> AsyncPolicy<B, P>
fn clone(&self) -> AsyncPolicy<B, P>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<B, P> Policy<B> for AsyncPolicy<B, P>
impl<B, P> Policy<B> for AsyncPolicy<B, P>
Source§type ActionContext = <P as Policy<B>>::ActionContext
type ActionContext = <P as Policy<B>>::ActionContext
Additional context on the policy’s decision.
Source§type PolicyState = <P as Policy<B>>::PolicyState
type PolicyState = <P as Policy<B>>::PolicyState
The current parameterization of the policy.
Source§type Observation = <P as Policy<B>>::Observation
type Observation = <P as Policy<B>>::Observation
The observation given as input to the policy.
Source§type ActionDistribution = <P as Policy<B>>::ActionDistribution
type ActionDistribution = <P as Policy<B>>::ActionDistribution
The action distribution parameters defining how the action will be sampled.
Source§fn forward(&mut self, states: Self::Observation) -> Self::ActionDistribution
fn forward(&mut self, states: Self::Observation) -> Self::ActionDistribution
Produces the action distribution from a batch of observations.
Source§fn action(
&mut self,
states: Self::Observation,
deterministic: bool,
) -> (Self::Action, Vec<Self::ActionContext>)
fn action( &mut self, states: Self::Observation, deterministic: bool, ) -> (Self::Action, Vec<Self::ActionContext>)
Gives the action from a batch of observations.
Source§fn update(&mut self, update: Self::PolicyState)
fn update(&mut self, update: Self::PolicyState)
Update the policy’s parameters.
Source§fn state(&self) -> Self::PolicyState
fn state(&self) -> Self::PolicyState
Returns the current parameterization.
Source§fn load_record(
self,
_record: <Self::PolicyState as PolicyState<B>>::Record,
) -> Self
fn load_record( self, _record: <Self::PolicyState as PolicyState<B>>::Record, ) -> Self
Loads the policy parameters from a record.
Auto Trait Implementations§
impl<B, P> Freeze for AsyncPolicy<B, P>
impl<B, P> RefUnwindSafe for AsyncPolicy<B, P>
impl<B, P> Send for AsyncPolicy<B, P>where
<P as Policy<B>>::PolicyState: Send,
<P as Policy<B>>::Observation: Send,
<P as Policy<B>>::ActionDistribution: Send,
<P as Policy<B>>::Action: Send,
<P as Policy<B>>::ActionContext: Send,
impl<B, P> Sync for AsyncPolicy<B, P>where
<P as Policy<B>>::PolicyState: Send,
<P as Policy<B>>::Observation: Send,
<P as Policy<B>>::ActionDistribution: Send,
<P as Policy<B>>::Action: Send,
<P as Policy<B>>::ActionContext: Send,
impl<B, P> Unpin for AsyncPolicy<B, P>
impl<B, P> UnsafeUnpin for AsyncPolicy<B, P>
impl<B, P> UnwindSafe for AsyncPolicy<B, 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