Skip to content

Commit 65d4262

Browse files
author
Shawn P. Duncan
committed
update documentation with better markup
1 parent 491f2dd commit 65d4262

5 files changed

+96
-77
lines changed

Diff for: ae_processor.py

+24-23
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@ def main(args: Namespace) -> None:
2424
2525
For the training loop:
2626
27-
- Instantiates a data object using `cp_tokenized_data.QuackTokenizedDataModule`.
28-
- Instantiates a model using `autoencoder.QuackAutoEncoder`.
29-
- Instantiates a strategy plugin using `ray_lightning.ray_ddp.RayPlugin`.
27+
- Instantiates a data object using ``cp_tokenized_data.QuackTokenizedDataModule``.
28+
- Instantiates a model using ``autoencoder.QuackAutoEncoder``.
29+
- Instantiates a strategy plugin using ``ray_lightning.ray_ddp.RayPlugin``.
3030
- Instantiates callback objects:
31-
-- A logger using `pytorch_lightning.loggers.comet.CometLogger`
32-
-- A learning rate monitor using `pytorch_lightning.callbacks.lr_monitor.LearningRateMonitor`
33-
-- A checkpoint creator using `pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint`
34-
-- An early stopping monitor using `pytorch_lightning.callbacks.early_stopping.EarlyStopping`
3531
36-
Then using these objects, instantiates a training control object using `pytorch_lightning.trainer.trainer.Trainer`
32+
- A logger using ``pytorch_lightning.loggers.comet.CometLogger``
33+
- A learning rate monitor using ``pytorch_lightning.callbacks.lr_monitor.LearningRateMonitor``
34+
- A checkpoint creator using ``pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint``
35+
- An early stopping monitor using ``pytorch_lightning.callbacks.early_stopping.EarlyStopping``
36+
37+
Then using these objects, instantiates a training control object using ``pytorch_lightning.trainer.trainer.Trainer``
3738
3839
For inference with a trained model, just the logger and the ray strategy are used along with an instance of
3940
autoencoder.AutoencoderWriter which when composed with Trainer prepares the prediction loop to output its results
@@ -44,49 +45,49 @@ def main(args: Namespace) -> None:
4445
args: Namespace
4546
Command line arguments. Possible arguments are:
4647
47-
`--data_dir`
48+
--data_dir
4849
*str* default='./data' The top directory of the data storage tree.
4950
50-
`--batch_size`
51+
--batch_size
5152
*int* default=4 The batch size used for processing data.
5253
53-
`--num_workers`
54+
--num_workers
5455
*int* default=0 The number of worker processes used by the data loader.
5556
56-
`--embed_size`
57+
--embed_size
5758
*int* default=128 Hyperparameter passed to QuackAutoEncoder.
5859
59-
`--hidden_size`
60+
--hidden_size
6061
*int* default=512 Hyperparameter passed to QuackAutoEncoder.
6162
62-
`--encode`
63+
--encode
6364
*bool* Flag to run the inference loop instead of train. True when present, otherwise False
6465
65-
`--filtered`
66+
--filtered
6667
*bool* Flag to output labeled data from the inference loop. True when present, otherwise False
6768
68-
`--evaluate`
69+
--evaluate
6970
*bool* Flag to output undetermined data from the inference loop. True when present, otherwise False
7071
71-
`--checkpoint_path`
72+
--checkpoint_path
7273
*str* A checkpoint used for manual restart. Only the weights are used.
7374
74-
`--storage_path`
75+
--storage_path
7576
*str* default='./data/encoded' A path for storing the outputs from inference.
7677
77-
`--l_rate`
78+
--l_rate
7879
*float* default=1e-1 Hyperparameter passed to QuackAutoEncoder.
7980
80-
`--l_rate_min`
81+
--l_rate_min
8182
*float* default=1e-3 Hyperparameter passed to QuackAutoEncoder.
8283
83-
`--l_rate_max_epoch`
84+
--l_rate_max_epoch
8485
*int* default=-1 Hyperparameter passed to QuackAutoEncoder.
8586
86-
`--exp_label`
87+
--exp_label
8788
*str* default='autoencoder-train' Label passed to the logger.
8889
89-
`--ray_nodes`
90+
--ray_nodes
9091
*int* default=4 Number of parallel nodes passed to the Ray plugin.
9192
9293
Returns

Diff for: autoencoder.py

+21-7
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,7 @@ def __init__(self, dim: int) -> None:
164164

165165
def forward(self, states: pt.Tensor, context: pt.Tensor) -> pt.Tensor:
166166
"""
167-
Computes the dot-product score:
168-
169-
:math`score(h_t, c) = \frac{h^T_t \cdot c}{\sqrt{H}}`
170-
with values of h taken from the states parameter, c from the context paramter and H is the dim parameter
171-
passed at construction.
167+
Computes the dot-product score.
172168
173169
Parameters
174170
----------
@@ -382,6 +378,24 @@ def forward(self, x: pt.Tensor) -> Tuple[pt.Tensor, pt.Tensor]:
382378
return last_h, encoded_sequence
383379

384380
def _common_step(self, x: pt.Tensor, batch_index: int, step_id: str) -> float:
381+
"""
382+
The common step containds the decoder logic, and begins by calling self.forward() so that it executes the full
383+
autoencder cycle.
384+
385+
Parameters
386+
----------
387+
x: pt.Tensor
388+
The input, which should be (B, T) shaped.
389+
batch_index: int
390+
The batch index
391+
step_id: str
392+
The step id.
393+
394+
Returns
395+
-------
396+
float
397+
The total loss over the sequence.
398+
"""
385399
final_state, sequence = self.forward(x)
386400

387401
# Now add the decoder part.
@@ -492,9 +506,9 @@ def predict_step(self, batch: Any, batch_idx: int, dataloader_idx: Optional[int]
492506
493507
Parameters
494508
----------
495-
batch: pt. Tuple[dict, pt.Tensor]
509+
batch: pt. Tuple[dict, pt.Tensor]
496510
An tuple of a metadata dictionary and the associated input data
497-
batch_idx: int
511+
batch_idx: int
498512
The index of the batch. Required to match the parent signature. Unused in our model.
499513
dataloader_idx: int
500514
Index of the current dataloader. Required to match the parent signature. Unused in our model.

Diff for: cp_flatten_processor.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ def main() -> None:
4747
4848
**Required** arguments are:
4949
50-
`--source_path`
50+
--source_path
5151
*str* The path to the .tar file. May be local or a url. Passed to `CensoredPlanetFlatten`.
52-
` --storage_path`
52+
--storage_path
5353
*str* The top directory of the data storage tree.
54-
`--log_path`
54+
--log_path
5555
*str* default=0 The path to a log file.
56-
`--vocab_path`
56+
--vocab_path
5757
*str* default=0 The path to a .pyc file. Passed to `CensoredPlanetFlatten`.
5858
"""
5959
# Add args to make a more flexible cli tool.

Diff for: dn_processor.py

+24-22
Original file line numberDiff line numberDiff line change
@@ -21,51 +21,53 @@ def main(args: Namespace) -> None:
2121
The executable logic for this controller.
2222
2323
For the training loop:
24-
- Instantiates a data object using `cp_image_data.QuackImageDataModule`.
25-
- Instantiates a model using `densenet.QuackDenseNet`.
26-
- Instantiates a strategy plugin using `ray_lightning.ray_ddp.RayPlugin`.
24+
- Instantiates a data object using ``cp_image_data.QuackImageDataModule``.
25+
- Instantiates a model using ``densenet.QuackDenseNet``.
26+
- Instantiates a strategy plugin using ``ray_lightning.ray_ddp.RayPlugin``.
2727
- Instantiates callback objects:
28-
-- A logger using `pytorch_lightning.loggers.comet.CometLogger`
29-
-- A learning rate monitor using `pytorch_lightning.callbacks.lr_monitor.LearningRateMonitor`
30-
-- A checkpoint creator using `pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint`
31-
-- An early stopping monitor using `pytorch_lightning.callbacks.early_stopping.EarlyStopping`
32-
Then using these objects, instantiates a training control object using `pytorch_lightning.trainer.trainer.Trainer`
28+
29+
- A logger using ``pytorch_lightning.loggers.comet.CometLogger``
30+
- A learning rate monitor using ``pytorch_lightning.callbacks.lr_monitor.LearningRateMonitor``
31+
- A checkpoint creator using ``pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint``
32+
- An early stopping monitor using ``pytorch_lightning.callbacks.early_stopping.EarlyStopping``
33+
34+
Then using these objects, instantiates a training control object using ``pytorch_lightning.trainer.trainer.Trainer``
3335
3436
For inference with a trained model, just the logger and the ray strategy are used along with an instance of
35-
`densenet.CensoredDataWriter` which when composed with Trainer prepares the prediction loop to output its results
37+
``densenet.CensoredDataWriter`` which when composed with Trainer prepares the prediction loop to output its results
3638
to file on each iteration.
3739
3840
Parameters
3941
----------
4042
args: Namespace
4143
Command line arguments. Possible arguments are:
4244
43-
`--data_dir`
45+
--data_dir
4446
*str* default='./data' The top directory of the data storage tree.
45-
`--batch_size`
47+
--batch_size
4648
*int* default=4 The batch size used for processing data.
47-
`--num_workers`
49+
--num_workers
4850
*int* default=0 The number of worker processes used by the data loader.
49-
`--evaluate`
51+
--evaluate
5052
*bool* Flag to output undetermined data from the inference loop. True when present, otherwise False
51-
`--checkpoint_path`
53+
--checkpoint_path
5254
*str* A checkpoint used for manual restart. Only the weights are used.
53-
`--storage_path`
55+
--storage_path
5456
*str* default='./data/encoded' A path for storing the outputs from inference.
55-
`--l_rate`
57+
--l_rate
5658
*float* default=1e-1 Hyperparameter passed to QuackAutoEncoder.
57-
`--l_rate_min`
59+
--l_rate_min
5860
*float* default=1e-3 Hyperparameter passed to QuackAutoEncoder.
59-
`--l_rate_max_epoch`
61+
--l_rate_max_epoch
6062
*int* default=-1 Hyperparameter passed to QuackAutoEncoder.
61-
`--exp_label`
63+
--exp_label
6264
*str* default='autoencoder-train' Label passed to the logger.
63-
`--ray_nodes`
65+
--ray_nodes
6466
*int* default=4 Number of parallel nodes passed to the Ray plugin.
65-
`--freeze`
67+
--freeze
6668
*bool* Flag to construct so that the image analyzing layers of the pre-trained Densenet are frozen for
6769
training.
68-
`--simple_transforms`
70+
--simple_transforms
6971
*bool* Flag passed to the data module to simplify image transforms.
7072
7173
Returns

Diff for: latent_processor.py

+23-21
Original file line numberDiff line numberDiff line change
@@ -22,48 +22,50 @@ def main(args: Namespace) -> None:
2222
The executable logic for this controller.
2323
2424
For the training loop:
25-
- Instantiates a data object using `cp_latent_data.QuackLatentDataModule`.
26-
- Instantiates a model using `cp_latent_classifier.QuackLatentClassifier`.
27-
- Instantiates a strategy plugin using `ray_lightning.ray_ddp.RayPlugin`.
25+
- Instantiates a data object using ``cp_latent_data.QuackLatentDataModule``.
26+
- Instantiates a model using ``cp_latent_classifier.QuackLatentClassifier``.
27+
- Instantiates a strategy plugin using ``ray_lightning.ray_ddp.RayPlugin``.
2828
- Instantiates callback objects:
29-
-- A logger using `pytorch_lightning.loggers.comet.CometLogger`
30-
-- A learning rate monitor using `pytorch_lightning.callbacks.lr_monitor.LearningRateMonitor`
31-
-- A checkpoint creator using `pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint`
32-
-- An early stopping monitor using `pytorch_lightning.callbacks.early_stopping.EarlyStopping`
33-
Then using these objects, instantiates a training control object using `pytorch_lightning.trainer.trainer.Trainer`
29+
30+
- A logger using ``pytorch_lightning.loggers.comet.CometLogger``
31+
- A learning rate monitor using ``pytorch_lightning.callbacks.lr_monitor.LearningRateMonitor``
32+
- A checkpoint creator using ``pytorch_lightning.callbacks.model_checkpoint.ModelCheckpoint``
33+
- An early stopping monitor using ``pytorch_lightning.callbacks.early_stopping.EarlyStopping``
34+
35+
Then using these objects, instantiates a training control object using ``pytorch_lightning.trainer.trainer.Trainer``
3436
3537
For inference with a trained model, just the logger and the ray strategy are used along with an instance of
36-
`densenet.CensoredDataWriter` which when composed with Trainer prepares the prediction loop to output its results
38+
``densenet.CensoredDataWriter`` which when composed with Trainer prepares the prediction loop to output its results
3739
to file on each iteration.
3840
3941
Parameters
4042
----------
4143
args: Namespace
4244
Command line arguments. Possible arguments are:
4345
44-
`--data_dir`
46+
--data_dir
4547
*str* default='./data' The top directory of the data storage tree.
46-
`--batch_size`
48+
--batch_size
4749
*int* default=4 The batch size used for processing data.
48-
`--num_workers`
50+
--num_workers
4951
*int* default=0 The number of worker processes used by the data loader.
50-
`--evaluate`
52+
--evaluate
5153
*bool* Flag to output undetermined data from the inference loop. True when present, otherwise False
52-
`--checkpoint_path`
54+
--checkpoint_path
5355
*str* A checkpoint used for manual restart. Only the weights are used.
54-
`--storage_path`
56+
--storage_path
5557
*str* default='./data/encoded' A path for storing the outputs from inference.
56-
`--l_rate`
58+
--l_rate
5759
*float* default=1e-1 Hyperparameter passed to QuackAutoEncoder.
58-
`--l_rate_min`
60+
--l_rate_min
5961
*float* default=1e-3 Hyperparameter passed to QuackAutoEncoder.
60-
`--l_rate_max_epoch`
62+
--l_rate_max_epoch
6163
*int* default=-1 Hyperparameter passed to QuackAutoEncoder.
62-
`--exp_label`
64+
--exp_label
6365
*str* default='autoencoder-train' Label passed to the logger.
64-
`--ray_nodes`
66+
--ray_nodes
6567
*int* default=4 Number of parallel nodes passed to the Ray plugin.
66-
`--freeze`
68+
--freeze
6769
*bool* Flag to construct so that the image analyzing layers of the pre-trained Densenet are frozen for
6870
training.
6971

0 commit comments

Comments
 (0)