Skip to content

Commit

Permalink
Update docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
misaghsoltani committed Sep 6, 2024
1 parent 2d7780f commit 394654d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions deepcubeai/training/train_env_cont.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ def load_nnet(nnet_dir: str, env: Environment) -> nn.Module:

def load_train_state(train_dir: str, nnet_model_dir: str,
env: Environment) -> Tuple[nn.Module, int]:
"""Loads the training state.
"""Loads the training data.
Args:
train_dir (str): Directory of the training state.
train_dir (str): Directory of the training data.
nnet_model_dir (str): Directory of the neural network model.
env (Environment): The environment instance.
Expand Down
12 changes: 6 additions & 6 deletions deepcubeai/training/train_env_disc.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ def forward(self, states: Tensor) -> Tuple[Tensor, Tensor, Tensor]:
states (Tensor): Input states.
Returns:
Tuple[Tensor, Tensor, Tensor]: Encoded states, encoded states with dropout, and
reconstructed states.
Tuple[Tensor, Tensor, Tensor]: Encoded states, discrete encoded states
(after rounding), and reconstructed states.
"""
enc, enc_d = self.encoder(states)
recon = self.decoder(enc_d)
Expand Down Expand Up @@ -267,12 +267,12 @@ def step_model(
Args:
autoencoder (Autoencoder): Autoencoder model.
env_nnet (nn.Module): Environment neural network.
env_nnet (nn.Module): Environment model.
state_episodes (List[np.ndarray]): List of state episodes.
action_episodes (List[List[int]]): List of action episodes.
start_idxs (np.array): Start indices.
device (torch.device): Device to run the model on.
env_coeff (float): Environment coefficient.
env_coeff (float): Environment model weight.
Returns:
Tuple[Tensor, Tensor, Tensor, float, float, float, float, Tensor, Tensor]: Losses and
Expand Down Expand Up @@ -373,7 +373,7 @@ def train_nnet(autoencoder: Autoencoder, env_nnet: nn.Module, nnet_dir: str,
Args:
autoencoder (Autoencoder): Autoencoder model.
env_nnet (nn.Module): Environment neural network.
env_nnet (nn.Module): Environment model.
nnet_dir (str): Directory to save the neural network.
state_episodes_train (List[np.ndarray]): List of training state episodes.
action_episodes_train (List[List[int]]): List of training action episodes.
Expand All @@ -385,7 +385,7 @@ def train_nnet(autoencoder: Autoencoder, env_nnet: nn.Module, nnet_dir: str,
start_itr (int): Starting iteration.
lr (float): Learning rate.
lr_d (float): Learning rate decay.
env_coeff (float): Environment coefficient.
env_coeff (float): Environment model weight.
only_env (bool): Whether to train only the environment model.
"""
# initialize
Expand Down
19 changes: 10 additions & 9 deletions deepcubeai/utils/pytorch_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ def __init__(self,
layer_norms (Optional[List[bool]], optional): List of layer normalization flags.
Defaults to None.
dropouts (Optional[List[float]], optional): List of dropout rates. Defaults to None.
use_bias_with_norm (bool, optional): Whether to use bias with normalization. Defaults
to True.
use_bias_with_norm (bool, optional): Whether to use bias if the is a normalization immidiately
after the
"""
super().__init__()
self.layers: nn.ModuleList = nn.ModuleList()
Expand Down Expand Up @@ -285,8 +285,8 @@ def __init__(self,
out_dim (int): Output dimension.
batch_norm (bool): Whether to use batch normalization.
act (str): Activation function.
use_bias_with_norm (bool, optional): Whether to use bias with normalization. Defaults
to True.
use_bias_with_norm (bool, optional): Whether to use bias if the is a normalization immidiately
after the
"""
super().__init__()
self.blocks = nn.ModuleList()
Expand Down Expand Up @@ -374,10 +374,11 @@ def __init__(self,
padding_values (Optional[List[Union[int, float]]], optional): List of padding values.
if padding mode = 'constant' padding will be filled with 'value' if specified,
otherwise 'zero'. Defaults to None.
group_norms (Optional[List[int]], optional): List of group normalization values.
group_norms (Optional[List[int]], optional): List of number of groups for
group normalization.
Defaults to None.
use_bias_with_norm (bool, optional): Whether to use bias with normalization. Defaults
to True.
use_bias_with_norm (bool, optional): Whether to use bias if there is a normalization
(such as BatchNorm or GroupNorm) used in this layer.
"""
super().__init__()
self.layers: nn.ModuleList = nn.ModuleList()
Expand Down Expand Up @@ -524,8 +525,8 @@ def __init__(self,
batch_norm (bool): Whether to use batch normalization.
act (str): Activation function.
group_norm (Optional[int], optional): Group normalization value. Defaults to 0.
use_bias_with_norm (bool, optional): Whether to use bias with normalization. Defaults
to True.
use_bias_with_norm (bool, optional): Whether to use bias if the is a normalization immidiately
after the
"""
super().__init__()
self.blocks: nn.ModuleList = nn.ModuleList()
Expand Down

0 comments on commit 394654d

Please sign in to comment.