Struct ark_api::ml::Experiment
source · [−]pub struct Experiment { /* private fields */ }
Expand description
A machine learning context. Takes batches of observations, and produces corresponding batches of actions.
Implementations
sourceimpl Experiment
impl Experiment
sourcepub fn new(
host: &HiveHost,
game_name: &str,
experiment_name: &str,
num_remote_workers: u32,
config: &str,
checkpoint: Option<&str>,
training_duration_in_seconds: u64,
protocol: &ProtocolConfig
) -> impl Future<Output = Result<Self, Error>>
pub fn new(
host: &HiveHost,
game_name: &str,
experiment_name: &str,
num_remote_workers: u32,
config: &str,
checkpoint: Option<&str>,
training_duration_in_seconds: u64,
protocol: &ProtocolConfig
) -> impl Future<Output = Result<Self, Error>>
Start training with a new experiment.
host
where the hive server exists.
game_name
identifier for a type of game, e.g. ‘pong’ or ‘moreau-arena’.
experiment_name
identifier for this experiment. This can be any arbitrary data. If the server already has an experiment with that name then a number will be appended to make it unique.
num_features
number of floating point values the neural network takes as input in each observation.
num_actions
number of floating point values the neural network outputs for each observation.
num_remote_workers
number of workers that should be started in the cloud.
Using a non-zero number is only supported when using a cloud host
.
config
is a piece of data that contains all the necessary information to re-create the training run.
This is not used anywhere internally, but when connecting to an existing experiment you can query it using the Experiment::config
method.
The only constraint on this data is that it must be valid json.
This is very useful for remote workers as they can download this configuration.
checkpoint
optional reference to checkpoint data to load from. TODO: Api for listing checkpoints.
training_duration_in_seconds
Number of seconds that the training will run for. The hive server will stop the experiment after this amount of time.
This is primarily useful when training in the cloud with remote workers,
sourcepub fn connect_to_experiment(
host: &HiveHost,
run_id: &str
) -> impl Future<Output = Result<Self, Error>>
pub fn connect_to_experiment(
host: &HiveHost,
run_id: &str
) -> impl Future<Output = Result<Self, Error>>
Connects to an already running experiment
sourcepub fn config(&self) -> impl Future<Output = Result<ExperimentConfig, Error>>
pub fn config(&self) -> impl Future<Output = Result<ExperimentConfig, Error>>
Retrieves the configuration for the experiment
This may require a download from the hive server.
sourcepub fn num_actions(&self) -> Result<usize, Error>
pub fn num_actions(&self) -> Result<usize, Error>
Number of actions that this experiment outputs
sourcepub fn num_features(&self) -> Result<usize, Error>
pub fn num_features(&self) -> Result<usize, Error>
Number of features that this experiment takes as input
sourcepub fn metrics(&self) -> impl Future<Output = Result<Vec<(String, f32)>, Error>>
pub fn metrics(&self) -> impl Future<Output = Result<Vec<(String, f32)>, Error>>
Retrieves current training metrics for Hive
sourcepub fn snapshot(&self) -> impl Future<Output = Result<Vec<u8>, Error>>
pub fn snapshot(&self) -> impl Future<Output = Result<Vec<u8>, Error>>
Retrieves a trained snapshot.
sourcepub fn push_training_experiences<'a>(
&self,
observations: &[Observation<'a>]
) -> Result<Vec<Response>, Error>
pub fn push_training_experiences<'a>(
&self,
observations: &[Observation<'a>]
) -> Result<Vec<Response>, Error>
Trains using the current batch of observations.
sourcepub fn push_demonstration_experiences<'a>(
&self,
demonstrations: &[Demonstration<'a>]
) -> Result<(), Error>
pub fn push_demonstration_experiences<'a>(
&self,
demonstrations: &[Demonstration<'a>]
) -> Result<(), Error>
Send demonstration experiences recorded in ark to Hive. Will return an error if the Hive protocol doesn’t support imitation learning
sourcepub fn push_augmented_experiences<'a>(
&self,
observations: &[AugmentedObservation<'a>]
) -> Result<(), Error>
pub fn push_augmented_experiences<'a>(
&self,
observations: &[AugmentedObservation<'a>]
) -> Result<(), Error>
Send augmented experiences augmented in ark to Hive.
The list of observations represents one timestep for a set of agents. You should not include multiple observations for a single agent, call this method multiple times instead.
sourcepub fn stop_experiment(self) -> Result<(), Error>
pub fn stop_experiment(self) -> Result<(), Error>
Stops an experiment and all associated workers.
If you just want to disconnect this client (without stopping potential remote workers) then simply drop
the experiment.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Experiment
impl Send for Experiment
impl Sync for Experiment
impl Unpin for Experiment
impl UnwindSafe for Experiment
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more