networks package¶
- networks.register_network(network_name: str) Callable[[T], T] ¶
the decorator to register a network
to add a new class as a registered network, add the following code to the top of the file:
@register_network("network_name") YourEnvClass(BaseEnv): ...
- Parameters:
network_name (str) – the name of the registered network
- Returns:
the decorator to register the network
- Return type:
Callable[[_T], _T]
Submodules¶
networks.MultiValueLSTM module¶
- class networks.MultiValueLSTM.MultiValueLSTM(args: Namespace)¶
Bases:
Module
The MultiValueLSTM model
References
https://arxiv.org/abs/1907.03665
https://github.com/Jogima-cyber/portfolio-manager
- static add_args(parser: ArgumentParser) None ¶
add arguments to the parser
to add arguments to the parser, modify the method as follows:
@staticmethod def add_args(parser: argparse.ArgumentParser) -> None: parser.add_argument( ... )
then add arguments to the parser
- Parameters:
parser (argparse.ArgumentParser) – the parser to add arguments to
- __init__(args: Namespace) None ¶
initialize the MultiValueLSTM model
- Parameters:
args (argparse.Namespace) – the arguments
- forward(state: Dict[str, Tensor], pretrain: bool, only_LSTM: bool = False, no_LSTM: bool = False) Tensor ¶
the overridden forward method
- Parameters:
state (Dict[str, torch.Tensor]) – the state dictionary, including “Xt_Matrix” and “Portfolio_Weight”
pretrain (bool) – is this a pretrain step or not
only_LSTM (bool) – only use the LSTM encoder
no_LSTM (bool) – do not use the LSTM encoder
- Returns:
the output tensor
- Return type:
torch.Tensor
- class networks.MultiValueLSTM.LSTMEncoder(args: Namespace)¶
Bases:
Module
the LSTM encoder for the MultiValueLSTM model
- __init__(args: Namespace) None ¶
initialize the LSTM encoder
- Parameters:
args (argparse.Namespace) – the arguments
- forward(Xt: Tensor) Tensor ¶
the overridden forward method
- Parameters:
Xt (torch.Tensor) – the state tensor Xt
- Returns:
the output tensor
- Return type:
torch.Tensor
- class networks.MultiValueLSTM.Decoder(args: Namespace)¶
Bases:
Module
the decoder for the MultiValueLSTM model on pretraining
- __init__(args: Namespace) None ¶
initialize the decoder
- Parameters:
args (argparse.Namespace) – the arguments
- forward(hn: Tensor) Tensor ¶
the overridden forward method
- Parameters:
hn (torch.Tensor) – the hidden state tensor hn from the LSTM encoder
- Returns:
the output tensor
- Return type:
torch.Tensor
- class networks.MultiValueLSTM.DNN(args: Namespace)¶
Bases:
Module
the DNN for the MultiValueLSTM model on training
- __init__(args: Namespace) None ¶
initialize the DNN
- Parameters:
args (argparse.Namespace) – the arguments
- forward(hn: Tensor, wt: Tensor) Tensor ¶
the overridden forward method
- Parameters:
hn (torch.Tensor) – the hidden state tensor hn from the LSTM encoder
wt (torch.Tensor) – the weight tensor wt
- Returns:
the output tensor
- Return type:
torch.Tensor
networks.PolicyCNN module¶
- class networks.PolicyCNN.PolicyCNN(args: Namespace)¶
Bases:
Module
The PolicyCNN model
- static add_args(parser: ArgumentParser) None ¶
add arguments to the parser
to add arguments to the parser, modify the method as follows:
@staticmethod def add_args(parser: argparse.ArgumentParser) -> None: parser.add_argument( ... ) then add arguments to the parser
- Parameters:
parser (argparse.ArgumentParser) – the parser to add arguments to
- __init__(args: Namespace) None ¶
initialize the PolicyCNN model
- Parameters:
args (argparse.Namespace) – the arguments
- forward(state: Dict[str, Tensor]) Tensor ¶
forward pass of the PolicyCNN model
- Parameters:
x (Dict[str, torch.Tensor]) – the input tensors
- Returns:
the out**put tensor
- Return type:
torch.Tensor
networks.PolicyWeightCNN module¶
- class networks.PolicyWeightCNN.PolicyWeightCNN(args: Namespace)¶
Bases:
Module
The PolicyWeightCNN model
- Reference:
original paper: https://arxiv.org/abs/1706.10059
- static add_args(parser: ArgumentParser) None ¶
add arguments to the parser
to add arguments to the parser, modify the method as follows:
@staticmethod def add_args(parser: argparse.ArgumentParser) -> None: parser.add_argument( ... ) then add arguments to the parser
- Parameters:
parser (argparse.ArgumentParser) – the parser to add arguments to
- __init__(args: Namespace) None ¶
initialize the PolicyWeightCNN model
- Parameters:
args (argparse.Namespace) – the arguments
- forward(state: Dict[str, Tensor]) Tensor ¶
forward pass of the PolicyWeightCNN model
- Parameters:
x (Dict[str, torch.Tensor]) – the input tensors
- Returns:
the output tensor
- Return type:
torch.Tensor
networks.PolicyWeightLSTM module¶
- class networks.PolicyWeightLSTM.PolicyWeightLSTM(args: Namespace)¶
Bases:
Module
The PolicyWeightLSTM model
- Reference:
original paper: https://arxiv.org/abs/1706.10059
- static add_args(parser: ArgumentParser) None ¶
add arguments to the parser
to add arguments to the parser, modify the method as follows:
@staticmethod def add_args(parser: argparse.ArgumentParser) -> None: parser.add_argument( ... ) then add arguments to the parser
- Parameters:
parser (argparse.ArgumentParser) – the parser to add arguments to
- __init__(args: Namespace) None ¶
initialize the PolicyWeightLSTM model
- Parameters:
args (argparse.Namespace) – the arguments
- forward(state: Dict[str, Tensor]) Tensor ¶
forward pass of the PolicyWeightLSTM model
- Parameters:
x (Dict[str, torch.Tensor]) – the input tensors
- Returns:
the output tensor
- Return type:
torch.Tensor
networks.PolicyWeightRNN module¶
- class networks.PolicyWeightRNN.PolicyWeightRNN(args: Namespace)¶
Bases:
Module
The PolicyWeightRNN model
- Reference:
original paper: https://arxiv.org/abs/1706.10059
- static add_args(parser: ArgumentParser) None ¶
add arguments to the parser
to add arguments to the parser, modify the method as follows:
@staticmethod def add_args(parser: argparse.ArgumentParser) -> None: parser.add_argument( ... ) then add arguments to the parser
- Parameters:
parser (argparse.ArgumentParser) – the parser to add arguments to
- __init__(args: Namespace) None ¶
initialize the PolicyWeightRNN model
- Parameters:
args (argparse.Namespace) – the arguments
- forward(state: Dict[str, Tensor]) Tensor ¶
forward pass of the PolicyWeightRNN model
- Parameters:
x (Dict[str, torch.Tensor]) – the input tensors
- Returns:
the output tensor
- Return type:
torch.Tensor
networks.ValueDNN module¶
- class networks.ValueDNN.ValueDNN(args: Namespace)¶
Bases:
Module
The ValueDNN model
- Reference:
original paper: https://arxiv.org/abs/1907.03665
- static add_args(parser: ArgumentParser) None ¶
add arguments to the parser
to add arguments to the parser, modify the method as follows:
@staticmethod def add_args(parser: argparse.ArgumentParser) -> None: parser.add_argument( ... )
then add arguments to the parser
- Parameters:
parser (argparse.ArgumentParser) – the parser to add arguments to
- __init__(args: Namespace) None ¶
initialize the ValueDNN model
- Parameters:
args (argparse.Namespace) – the arguments
- forward(state: Dict[str, Tensor], action: Tensor)¶
forward pass
- Parameters:
state (Dict[str, torch.Tensor]) – the state
action (torch.Tensor) – the action
- Returns:
the output
- Return type:
torch.Tensor