TorchCraftAI
A bot for machine learning research on StarCraft: Brood War
Public Member Functions | Friends | List of all members
cpid::Evaluator::make_shared_enabler Struct Reference

#include <evaluator.h>

Inherits cpid::Evaluator.

Public Member Functions

 make_shared_enabler (ag::Container model, std::unique_ptr< BaseSampler > s, size_t n, ForwardFunction f)
 
- Public Member Functions inherited from cpid::Evaluator
EpisodeHandle startEpisode () override
 Returns true if succeeded to register an episode, and false otherwise. More...
 
void forceStopEpisode (EpisodeHandle const &) override
 
bool update () override
 
virtual ag::Variant forward (ag::Variant inp, EpisodeHandle const &) override
 
void reset () override
 Releases all the worker threads so that they can be joined. More...
 
std::shared_ptr< ReplayBufferFramemakeFrame (ag::Variant, ag::Variant, float reward) override
 
- Public Member Functions inherited from cpid::Trainer
 Trainer (ag::Container model, ag::Optimizer optim, std::unique_ptr< BaseSampler >, std::unique_ptr< AsyncBatcher > batcher=nullptr)
 
ag::Variant forwardUnbatched (ag::Variant in, ag::Container model=nullptr)
 Convenience function when one need to forward a single input. More...
 
virtual ~Trainer ()=default
 
void setTrain (bool=true)
 
bool isTrain () const
 
ag::Variant sample (ag::Variant in)
 Sample using the class' sampler. More...
 
ag::Container model () const
 
ag::Optimizer optim () const
 
ReplayBufferreplayBuffer ()
 
virtual std::shared_ptr< EvaluatormakeEvaluator (size_t, std::unique_ptr< BaseSampler > sampler)
 
void setDone (bool=true)
 
bool isDone () const
 
virtual void step (EpisodeHandle const &, std::shared_ptr< ReplayBufferFrame > v, bool isDone=false)
 
bool isActive (EpisodeHandle const &)
 
template<class Archive >
void save (Archive &ar) const
 
template<class Archive >
void load (Archive &ar)
 
template<typename T >
bool is () const
 
TrainersetMetricsContext (std::shared_ptr< MetricsContext > context)
 
std::shared_ptr< MetricsContextmetricsContext () const
 
 TORCH_ARG (float, noiseStd)
 
 TORCH_ARG (bool, continuousActions)
 
void setBatcher (std::unique_ptr< AsyncBatcher > batcher)
 

Friends

class Trainer
 

Additional Inherited Members

- Protected Types inherited from cpid::Trainer
using ForwardFunction = std::function< ag::Variant(ag::Variant, EpisodeHandle const &)>
 
- Protected Member Functions inherited from cpid::Evaluator
virtual void stepEpisode (GameUID const &, EpisodeKey const &, ReplayBuffer::Episode &) override
 
 Evaluator (ag::Container model, std::unique_ptr< BaseSampler > sampler, size_t batchSize, ForwardFunction func)
 
- Protected Member Functions inherited from cpid::Trainer
virtual void stepFrame (GameUID const &, EpisodeKey const &, ReplayBuffer::Episode &)
 
virtual void stepGame (GameUID const &game)
 
template<typename T >
std::vector< T const * > cast (ReplayBuffer::Episode const &e)
 
- Static Protected Member Functions inherited from cpid::Trainer
static std::shared_ptr< EvaluatorevaluatorFactory (ag::Container model, std::unique_ptr< BaseSampler > s, size_t n, ForwardFunction func)
 
- Protected Attributes inherited from cpid::Evaluator
size_t batchSize_
 
size_t gamesStarted_ = 0
 
std::condition_variable batchBarrier_
 
std::mutex updateMutex_
 
std::shared_timed_mutex insertionMutex_
 
std::deque< std::pair< GameUID, EpisodeKey > > newGames_
 
ForwardFunction forwardFunction_
 
- Protected Attributes inherited from cpid::Trainer
ag::Container model_
 
ag::Optimizer optim_
 
std::shared_ptr< MetricsContextmetricsContext_
 
ReplayBuffer replayer_
 
bool train_ = true
 
std::atomic< bool > done_ {false}
 
std::mutex modelWriteMutex_
 
std::shared_timed_mutex activeMapMutex_
 
std::unique_ptr< BaseSamplersampler_
 
std::unique_ptr< AsyncBatcherbatcher_
 
std::shared_ptr< HandleGuardepGuard_
 
ReplayBuffer::UIDKeyStore actives_
 
- Static Protected Attributes inherited from cpid::Trainer
static constexpr float kFwdMetricsSubsampling = 0.1
 We subsample kFwdMetricsSubsampling of the forward() events when measuring their duration. More...
 

Constructor & Destructor Documentation

cpid::Evaluator::make_shared_enabler::make_shared_enabler ( ag::Container  model,
std::unique_ptr< BaseSampler s,
size_t  n,
ForwardFunction  f 
)
inline

Friends And Related Function Documentation

friend class Trainer
friend

The documentation for this struct was generated from the following file: