digideep.pipeline package¶
Submodules¶
digideep.pipeline.runner module¶
-
class
digideep.pipeline.runner.
Runner
(params)[source]¶ Bases:
object
This class controls the main flow of the program. The main components of the class are:
- explorer: A dictionary containing
Explorer
for the three modes oftrain
,test
, andeval
. AnExplorer
is a class which handles running simulations concurrently in several environments. - memory: The component responsible for storing the trajectories generated by the explorer.
- agents: A dictionary containing all agents in the environment.
This class also prints the
Profiler
andMonitor
information. Also the main serialization burden is on this class. The rest of classes only need to implement thestate_dict
andload_state_dict
functions for serialization.Caution
The lines of code for testing while training are commented out.
-
enjoy
()[source]¶ This function evaluates the current policy in the environment. It only runs the explorer in a loop.
# Do a cycle while not done: # Explore explorer["eval"].update() log()
-
instantiate
()[source]¶ This function will instantiate the memory, the explorers, and the agents with their specific parameters.
-
lazy_init
()[source]¶ Initialization of attributes which are not part of the object state. These need lazy initialization due to proper initialization when loading from a checkpoint.
-
load
()[source]¶ This is a function used by the
start()
function to load the states of internal objects from the checkpoint and update the objects state dicts.
-
load_state_dict
(state_dict)[source]¶ This function will load the states of the internal objects:
- Agents
- Explorers (state of
train
mode would be loaded fortest
andeval
as well) - Memory
-
save
(forced=False)[source]¶ This is a high-level function for saving both the state of objects and the runner object. It will use helper functions from
Session
.
-
start
(session)[source]¶ A function to initialize the objects and load their states (if loading from a checkpoint). This function must be called before using the
train()
andenjoy()
functions.If we are starting from scrarch, we will:
- Instantiate all internal components using parameters.
If we are loading from a saved checkpoint, we will:
- Instantiate all internal components using old parameters.
- Load all state dicts.
- (OPTIONAL) Override parameters.
-
state_dict
()[source]¶ This function will return the states of all internal objects:
- Agents
- Explorer (only the
train
mode) - Memory
Todo
Memory should be dumped in a separate file, since it can get really large. Moreover, it should be optional.
- explorer: A dictionary containing
digideep.pipeline.session module¶
-
class
digideep.pipeline.session.
Session
(root_path)[source]¶ Bases:
object
This class provides the utilities for storing results of a session. It provides a unique path based on a timestamp and creates all sub- folders that are required there. A session directory will have the following contents:
session_YYYYMMDDHHMMSS/
:checkpoints/
: The directory of all stored checkpoints.modules/
: A copy of all modules that should be saved with the results. This helps to load checkpoints in evolving codes with breaking changes. Use extra modules with--save-modules
command-line option.monitor/
: Summary results of each worker environment.cpanel.json
: A json file including control panel (cpanel
) parameters inparams
file.params.yaml
: The parameter tree of the session, i.e. the params variable inparams
file.report.log
: A log file for Logger class.visdom.log
: A log file for visdom logs.__init__.py
: Python__init__
file to convert the session to a module.
Parameters: root_path (str) – The path to the digideep
module.Note
This class also initializes helping tools (e.g. Visdom, Logger, Monitor, etc.) and has helper functions for saving/loading checkpoints.
Tip
The default directory for storing sessions is
/tmp/digideep_sessions
. To change the default directory use the program with cli argument--session-path <path>
Todo
Complete the session-as-a-module (SaaM) implementation. Then,
session_YYYYMMDDHHMMSS
should work like an importable module for testing and inference.Todo
If restoring a session,
visdom.log
should be copied from there and replayed.play resume loading dry-run session-only | implemented——————————————————————————————– | ———— Train 0 0 0 0 0 | 1 Train session barebone 0 0 0 0 1 | 1 Train from a checkpoint 0 1 1 0 0 | 1 Play (policy initialized) 1 0 0 0/1 0 | 1 Play (policy loaded from checkpoint) 1 0 1 0/1 0 | 1
-
createSaaM
()[source]¶ SaaM = Session-as-a-Module This function will make the session act like a python module. The user can then simply import the module for inference.