RLPack
 
Loading...
Searching...
No Matches
rlpack.utils.sanity_check.SanityCheck Class Reference

This class does the basic sanity check of input_config. More...

+ Inheritance diagram for rlpack.utils.sanity_check.SanityCheck:
+ Collaboration diagram for rlpack.utils.sanity_check.SanityCheck:

Public Member Functions

def __init__ (self, Dict[str, Any] input_config)
 
None check_activation_init_sanity (self)
 Checks the basic sanity of activation related arguments in config. More...
 
None check_agent_init_sanity (self, bool only_model_arg_check=False)
 Check the sanity of agent input. More...
 
bool check_distribution_sanity (self)
 For agents with requirements of the argument distribution, checks if valid distribution is being passed. More...
 
None check_if_valid_agent_for_simulator (self)
 Checks if agent is valid for rlpack.simulator.Simulator (single process agent). More...
 
None check_if_valid_agent_for_simulator_distributed (self)
 Checks if agent is valid for rlpack.simulator_distributed.SimulatorDistributed (multi process agent). More...
 
None check_lr_scheduler_init_sanity (self)
 Checks the basic sanity of lr_scheduler related arguments in config. More...
 
None check_mandatory_params_sanity (self)
 Checks the sanity of mandatory parameters for RLPack Simulator to run. More...
 
bool check_model_init_sanity (self)
 Checks the sanity of model arguments, either custom or in-built. More...
 
None check_optimizer_init_sanity (self)
 Checks the basic sanity of optimizer related arguments in config. More...
 
def __init__ (self)
 

Data Fields

 args
 The arguments received from the input input_config keyword arguments. More...
 
 input_config
 The argument input_config; indicating keyword arguments to be used to training/evaluation. More...
 
- Data Fields inherited from rlpack.utils.base.register.Register
 activation_init_args
 The activation initialization arguments when using in-built models. More...
 
 activation_map
 The mapping between given keyword and PyTorch activation function class. More...
 
 agent_args
 The mapping between given keyword and agent agents' arguments. More...
 
 agent_args_default
 The mapping between given keyword and agent agent's default arguments. More...
 
 agent_init_args
 The mandatory agent initialisation arguments. More...
 
 agents
 The mapping between given keyword and agents models. More...
 
 distributions_map
 The mapping between given keyword and PyTorch Distribution class. More...
 
 loss_function_map
 The mapping between given keyword and PyTorch loss function class. More...
 
 lr_scheduler_init_args
 The LR Scheduler initialization arguments. More...
 
 lr_scheduler_map
 The mapping between given keyword and PyTorch LR Scheduler class. More...
 
 mandatory_distributed_agents
 
 mandatory_distribution_required_agents
 
 mandatory_keys
 The tuple for mandatory keys (or keyword arguments) always expected. More...
 
 model_args
 The mapping between given keyword and in-built models' arguments. More...
 
 model_args_default
 The mapping between given keyword and in-built model's default arguments. More...
 
 model_args_to_optimize
 The mapping between keyword and agents' model arguments to wrap optimizer with. More...
 
 model_init_args
 The model initialization arguments when using in-built models. More...
 
 models
 The mapping between given keyword and in-built models. More...
 
 optimizer_init_args
 The optimizer initialization arguments for given models. More...
 
 optimizer_map
 The mapping between given keyword and PyTorch optimizer class. More...
 

Private Member Functions

str _error_message (self, str param_of_arg, List[bool] boolean_args)
 Protected method to craft the error message indicating parameters that are missing. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from rlpack.utils.base.register.Register
def get_prefix_path ()
 Gets prefix path for rlpack package, from python installation. More...
 

Detailed Description

This class does the basic sanity check of input_config.

Constructor & Destructor Documentation

◆ __init__()

def rlpack.utils.sanity_check.SanityCheck.__init__ (   self,
Dict[str, Any]  input_config 
)
Parameters
input_config(Dict[str, Any]): The input config that is to be used for training/evaluation.

Reimplemented from rlpack.utils.base.register.Register.

Member Function Documentation

◆ _error_message()

str rlpack.utils.sanity_check.SanityCheck._error_message (   self,
str  param_of_arg,
List[bool]  boolean_args 
)
private

Protected method to craft the error message indicating parameters that are missing.

Parameters
param_of_argstr: The parameter for which argument is missing.
boolean_argsBoolean list of indicating if the corresponding argument was received or not
Returns
str: The error message.

◆ check_activation_init_sanity()

None rlpack.utils.sanity_check.SanityCheck.check_activation_init_sanity (   self)

Checks the basic sanity of activation related arguments in config.

Note that this will not check sanity of the given activation even if Activation is valid. If invalid arguments are passed, error will be raised by PyTorch.

◆ check_agent_init_sanity()

None rlpack.utils.sanity_check.SanityCheck.check_agent_init_sanity (   self,
bool   only_model_arg_check = False 
)

Check the sanity of agent input.

This function will check the arguments received for agents to verify if all necessary arguments are received.

Parameters
only_model_arg_checkbool: Indicating weather to check only the model related arguments or all of the mandatory arguments.

◆ check_distribution_sanity()

bool rlpack.utils.sanity_check.SanityCheck.check_distribution_sanity (   self)

For agents with requirements of the argument distribution, checks if valid distribution is being passed.

If agent requires distribution argument and valid argument is passed, True is returned. If agent doesn't require distribution argument returns False.

Returns
bool: Flag indicating if agent requires distribution argument or not.

◆ check_if_valid_agent_for_simulator()

None rlpack.utils.sanity_check.SanityCheck.check_if_valid_agent_for_simulator (   self)

Checks if agent is valid for rlpack.simulator.Simulator (single process agent).

◆ check_if_valid_agent_for_simulator_distributed()

None rlpack.utils.sanity_check.SanityCheck.check_if_valid_agent_for_simulator_distributed (   self)

Checks if agent is valid for rlpack.simulator_distributed.SimulatorDistributed (multi process agent).

◆ check_lr_scheduler_init_sanity()

None rlpack.utils.sanity_check.SanityCheck.check_lr_scheduler_init_sanity (   self)

Checks the basic sanity of lr_scheduler related arguments in config.

Note that this will not check sanity of the given lr_scheduler's args even if LR Scheduler valid. If invalid arguments are passed, error will be raised by PyTorch.

◆ check_mandatory_params_sanity()

None rlpack.utils.sanity_check.SanityCheck.check_mandatory_params_sanity (   self)

Checks the sanity of mandatory parameters for RLPack Simulator to run.

◆ check_model_init_sanity()

bool rlpack.utils.sanity_check.SanityCheck.check_model_init_sanity (   self)

Checks the sanity of model arguments, either custom or in-built.

When in-built is to be used, both model_name and model_args must be passed. If both are not passed, it will try to check if there is a custom model that is passed. Custom models' names must correspond to their target agent's keyword argument name.

Returns
A flag indicating if we use a custom model or an in-built model.

◆ check_optimizer_init_sanity()

None rlpack.utils.sanity_check.SanityCheck.check_optimizer_init_sanity (   self)

Checks the basic sanity of optimizer related arguments in config.

Note that this will not check sanity of the given optimizer args even if optimizer is valid. If invalid arguments are passed, error will be raised by PyTorch.

Field Documentation

◆ args

rlpack.utils.sanity_check.SanityCheck.args

The arguments received from the input input_config keyword arguments.

◆ input_config

rlpack.utils.sanity_check.SanityCheck.input_config

The argument input_config; indicating keyword arguments to be used to training/evaluation.