torchabc 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {torchabc-0.2.1 → torchabc-0.2.2}/PKG-INFO +7 -7
- {torchabc-0.2.1 → torchabc-0.2.2}/README.md +5 -5
- {torchabc-0.2.1 → torchabc-0.2.2}/pyproject.toml +2 -2
- {torchabc-0.2.1 → torchabc-0.2.2}/torchabc/__init__.py +1 -1
- {torchabc-0.2.1 → torchabc-0.2.2}/torchabc/cli.py +1 -1
- {torchabc-0.2.1 → torchabc-0.2.2}/LICENSE +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: torchabc
|
|
3
|
-
Version: 0.2.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.2.2
|
|
4
|
+
Summary: A simple abstract class for training and inference in PyTorch.
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: Emanuele Guidotti
|
|
7
7
|
Author-email: emanuele.guidotti@usi.ch
|
|
@@ -18,21 +18,21 @@ Description-Content-Type: text/markdown
|
|
|
18
18
|
|
|
19
19
|
# TorchABC
|
|
20
20
|
|
|
21
|
-
[`TorchABC`](https://github.com/eguidotti/torchabc) is an abstract class for training
|
|
21
|
+
[`TorchABC`](https://github.com/eguidotti/torchabc/blob/main/torchabc/__init__.py) is an abstract class for training and inference in PyTorch that helps you keep your code well organized. It is a minimalist version of [pytorch-lightning](https://pypi.org/project/pytorch-lightning/), it depends on [torch](https://pypi.org/project/torch/) only, and it consists of a simple self-contained [file](https://github.com/eguidotti/torchabc/blob/main/torchabc/__init__.py).
|
|
22
22
|
|
|
23
23
|
## Workflow
|
|
24
24
|
|
|
25
25
|

|
|
26
26
|
|
|
27
|
-
`TorchABC` implements the workflow illustrated above. The workflow begins with raw `data`, which undergoes a `preprocess` step. This step transforms the raw `data` into `input` samples and their corresponding `target` labels.
|
|
27
|
+
The `TorchABC` class implements the workflow illustrated above. The workflow begins with raw `data`, which undergoes a `preprocess` step. This step transforms the raw `data` into `input` samples and their corresponding `target` labels.
|
|
28
28
|
|
|
29
29
|
Next, the individual `input` samples are grouped into batches called `inputs` using a `collate` function. Similarly, the `target` labels are batched into `targets`. The `inputs` are then fed into the `network`, which produces `outputs`.
|
|
30
30
|
|
|
31
|
-
The `outputs` are compared to the `targets` using a `loss` function
|
|
31
|
+
The `outputs` are compared to the `targets` using a `loss` function which quantifies the error between the two. The `optimizer` updates the parameters of the `network` to minimize the `loss`. The `scheduler` can dynamically change the learning rate of the `optimizer` during training.
|
|
32
32
|
|
|
33
33
|
Finally, the raw `outputs` from the `network` undergo a `postprocess` step to generate the final `predictions`. This could involve converting probabilities to class labels, applying thresholds, or other task-specific transformations.
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
The core logic blocks are abstract. You define their specific behavior with maximum flexibility.
|
|
36
36
|
|
|
37
37
|
## Quick start
|
|
38
38
|
|
|
@@ -82,7 +82,7 @@ class ClassName(TorchABC):
|
|
|
82
82
|
return outputs
|
|
83
83
|
```
|
|
84
84
|
|
|
85
|
-
Fill out the template with the dataloaders, preprocessing and postprocessing steps, the neural network, optimizer, scheduler, loss, and evaluation metrics.
|
|
85
|
+
Fill out the template with the dataloaders, preprocessing and postprocessing steps, the neural network, optimizer, scheduler, loss, and optional evaluation metrics.
|
|
86
86
|
|
|
87
87
|
#### `dataloaders`: the dataloaders for training and evaluation
|
|
88
88
|
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
# TorchABC
|
|
2
2
|
|
|
3
|
-
[`TorchABC`](https://github.com/eguidotti/torchabc) is an abstract class for training
|
|
3
|
+
[`TorchABC`](https://github.com/eguidotti/torchabc/blob/main/torchabc/__init__.py) is an abstract class for training and inference in PyTorch that helps you keep your code well organized. It is a minimalist version of [pytorch-lightning](https://pypi.org/project/pytorch-lightning/), it depends on [torch](https://pypi.org/project/torch/) only, and it consists of a simple self-contained [file](https://github.com/eguidotti/torchabc/blob/main/torchabc/__init__.py).
|
|
4
4
|
|
|
5
5
|
## Workflow
|
|
6
6
|
|
|
7
7
|

|
|
8
8
|
|
|
9
|
-
`TorchABC` implements the workflow illustrated above. The workflow begins with raw `data`, which undergoes a `preprocess` step. This step transforms the raw `data` into `input` samples and their corresponding `target` labels.
|
|
9
|
+
The `TorchABC` class implements the workflow illustrated above. The workflow begins with raw `data`, which undergoes a `preprocess` step. This step transforms the raw `data` into `input` samples and their corresponding `target` labels.
|
|
10
10
|
|
|
11
11
|
Next, the individual `input` samples are grouped into batches called `inputs` using a `collate` function. Similarly, the `target` labels are batched into `targets`. The `inputs` are then fed into the `network`, which produces `outputs`.
|
|
12
12
|
|
|
13
|
-
The `outputs` are compared to the `targets` using a `loss` function
|
|
13
|
+
The `outputs` are compared to the `targets` using a `loss` function which quantifies the error between the two. The `optimizer` updates the parameters of the `network` to minimize the `loss`. The `scheduler` can dynamically change the learning rate of the `optimizer` during training.
|
|
14
14
|
|
|
15
15
|
Finally, the raw `outputs` from the `network` undergo a `postprocess` step to generate the final `predictions`. This could involve converting probabilities to class labels, applying thresholds, or other task-specific transformations.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
The core logic blocks are abstract. You define their specific behavior with maximum flexibility.
|
|
18
18
|
|
|
19
19
|
## Quick start
|
|
20
20
|
|
|
@@ -64,7 +64,7 @@ class ClassName(TorchABC):
|
|
|
64
64
|
return outputs
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
Fill out the template with the dataloaders, preprocessing and postprocessing steps, the neural network, optimizer, scheduler, loss, and evaluation metrics.
|
|
67
|
+
Fill out the template with the dataloaders, preprocessing and postprocessing steps, the neural network, optimizer, scheduler, loss, and optional evaluation metrics.
|
|
68
68
|
|
|
69
69
|
#### `dataloaders`: the dataloaders for training and evaluation
|
|
70
70
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "torchabc"
|
|
3
|
-
version = "0.2.
|
|
4
|
-
description = "
|
|
3
|
+
version = "0.2.2"
|
|
4
|
+
description = "A simple abstract class for training and inference in PyTorch."
|
|
5
5
|
authors = [
|
|
6
6
|
{name = "Emanuele Guidotti",email = "emanuele.guidotti@usi.ch"}
|
|
7
7
|
]
|
|
@@ -7,7 +7,7 @@ from typing import Any, Union, Dict, List, Callable
|
|
|
7
7
|
|
|
8
8
|
class TorchABC(abc.ABC):
|
|
9
9
|
"""
|
|
10
|
-
|
|
10
|
+
A simple abstract class for training and inference in PyTorch.
|
|
11
11
|
"""
|
|
12
12
|
|
|
13
13
|
def __init__(self, device: Union[str, torch.device] = None, logger: Callable = print, **hparams):
|
|
@@ -38,7 +38,7 @@ class ClassName(TorchABC):"""
|
|
|
38
38
|
|
|
39
39
|
if not args.min:
|
|
40
40
|
template += """
|
|
41
|
-
\"\"\"A concrete
|
|
41
|
+
\"\"\"A concrete subclass of the TorchABC abstract class.
|
|
42
42
|
|
|
43
43
|
Use this template to implement your own model by following these steps:
|
|
44
44
|
- replace ClassName with the name of your model,
|
|
File without changes
|