modelmark 0.1.0__tar.gz → 0.1.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.
- modelmark-0.1.2/PKG-INFO +179 -0
- modelmark-0.1.2/README.md +161 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/pyproject.toml +1 -1
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/common/dataset.py +14 -10
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/common/loader.py +9 -9
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/common/parser.py +21 -19
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/config.py +3 -1
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/constants.py +1 -8
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/modelmark.py +38 -27
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/models/conv.py +21 -26
- modelmark-0.1.2/src/modelmark/models/gru.py +49 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/models/linear.py +31 -16
- modelmark-0.1.2/src/modelmark/models/lstm.py +49 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/models/transformer.py +35 -34
- modelmark-0.1.2/src/modelmark.egg-info/PKG-INFO +179 -0
- modelmark-0.1.0/PKG-INFO +0 -109
- modelmark-0.1.0/README.md +0 -91
- modelmark-0.1.0/src/modelmark/models/gru.py +0 -45
- modelmark-0.1.0/src/modelmark/models/lstm.py +0 -43
- modelmark-0.1.0/src/modelmark.egg-info/PKG-INFO +0 -109
- {modelmark-0.1.0 → modelmark-0.1.2}/LICENSE +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/setup.cfg +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/__init__.py +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/__main__.py +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/common/downloader.py +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/common/logger.py +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/common/report.py +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/common/tester.py +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark/common/utils.py +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark.egg-info/SOURCES.txt +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark.egg-info/dependency_links.txt +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark.egg-info/entry_points.txt +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark.egg-info/requires.txt +0 -0
- {modelmark-0.1.0 → modelmark-0.1.2}/src/modelmark.egg-info/top_level.txt +0 -0
modelmark-0.1.2/PKG-INFO
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: modelmark
|
|
3
|
+
Version: 0.1.2
|
|
4
|
+
Summary: Benchmark framework for neural network models
|
|
5
|
+
Author: Andrew Larin
|
|
6
|
+
License: MIT
|
|
7
|
+
Requires-Python: >=3.12
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: numpy>=2.4
|
|
11
|
+
Requires-Dist: pandas>=3.0
|
|
12
|
+
Requires-Dist: torch>=2.12
|
|
13
|
+
Requires-Dist: tqdm>=4.67
|
|
14
|
+
Requires-Dist: playwright>=1.62
|
|
15
|
+
Requires-Dist: rich>=15.0
|
|
16
|
+
Requires-Dist: thop>=0.1
|
|
17
|
+
Dynamic: license-file
|
|
18
|
+
|
|
19
|
+
# ModelMark
|
|
20
|
+
|
|
21
|
+
ModelMark is a CLI benchmarking tool for comparing neural-network models. It runs your models on one or more datasets, records performance and efficiency statistics, and generates an easy-to-embed HTML/PNG report.
|
|
22
|
+
|
|
23
|
+

|
|
24
|
+
|
|
25
|
+
## Table of Contents
|
|
26
|
+
|
|
27
|
+
- [About](#about)
|
|
28
|
+
- [Requirements](#requirements)
|
|
29
|
+
- [Installation](#installation)
|
|
30
|
+
- [Quick Start](#quick-start)
|
|
31
|
+
- [Configuration](#configuration)
|
|
32
|
+
- [How the Benchmark Works](#how-the-benchmark-works)
|
|
33
|
+
- [Reported Metrics](#reported-metrics)
|
|
34
|
+
- [Examples](#examples)
|
|
35
|
+
- [Troubleshooting](#troubleshooting)
|
|
36
|
+
|
|
37
|
+
## About
|
|
38
|
+
|
|
39
|
+
For each benchmark run, ModelMark:
|
|
40
|
+
|
|
41
|
+
1. Selects the next combination of dataset, input/output size, model, and seed.
|
|
42
|
+
2. Seeds the random generators for reproducibility.
|
|
43
|
+
3. Creates the data loader, model, and tester objects.
|
|
44
|
+
4. Trains the model for the configured number of epochs and restores the checkpoint with the lowest validation loss.
|
|
45
|
+
5. Records runtime and efficiency statistics.
|
|
46
|
+
6. Evaluates the model on the dataset using the metrics from the configuration file.
|
|
47
|
+
|
|
48
|
+
After all runs finish, ModelMark aggregates the results and generates a report containing testing results, training statistics, and your machine metadata.
|
|
49
|
+
|
|
50
|
+
## Requirements
|
|
51
|
+
|
|
52
|
+
- OS: Windows or Linux
|
|
53
|
+
- Python: 3.12 or newer
|
|
54
|
+
- Git: required for installation from GitHub
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
Install ModelMark from PyPI:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install modelmark
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Quick Start
|
|
65
|
+
|
|
66
|
+
1. Run initialization in an empty folder:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
modelmark init
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
This creates two folders:
|
|
73
|
+
- `modelmark_files/` — configuration and log files
|
|
74
|
+
- `models/` — your model files
|
|
75
|
+
|
|
76
|
+
2. Edit the configuration file:
|
|
77
|
+
|
|
78
|
+
`modelmark_files/config.py`
|
|
79
|
+
|
|
80
|
+
It contains three main configuration blocks:
|
|
81
|
+
- `model_config` — model hyperparameters such as number of layers, hidden dimension, kernel size, etc.
|
|
82
|
+
- `data_config` — dataset parameters such as file path, input/output features, train/val ratios, etc.
|
|
83
|
+
- `test_config` — testing options such as optimizer, loss criterion, metrics, learning rate, etc.
|
|
84
|
+
|
|
85
|
+
3. Put the testing models to the `models/` folder.
|
|
86
|
+
|
|
87
|
+
Make sure to import model's class definitions to the `config.py`.
|
|
88
|
+
|
|
89
|
+
Configure `config.model_config` according to your task.
|
|
90
|
+
|
|
91
|
+
5. Download the dataset files (ETT by default):
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
modelmark load
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
6. Run the benchmark:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
modelmark run
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
7. View the generated report:
|
|
104
|
+
- `result.html`
|
|
105
|
+
- `result.png`
|
|
106
|
+
|
|
107
|
+
## Configuration
|
|
108
|
+
|
|
109
|
+
You can adjust the configuration and add your own model files in the `models/` directory to match your benchmarking needs.
|
|
110
|
+
|
|
111
|
+
Make sure your model implementation is compatible with the keys and settings used in your configuration.
|
|
112
|
+
|
|
113
|
+
A detailed configuration example is available at:
|
|
114
|
+
[src/modelmark/config.py](https://github.com/gloptim77/ModelMark/blob/main/src/modelmark/config.py)
|
|
115
|
+
|
|
116
|
+
A detailed example model is available at:
|
|
117
|
+
[src/modelmark/models/linear.py](https://github.com/gloptim77/ModelMark/blob/main/src/modelmark/models/linear.py)
|
|
118
|
+
|
|
119
|
+
## How the Benchmark Works
|
|
120
|
+
|
|
121
|
+
The benchmark consists of:
|
|
122
|
+
|
|
123
|
+
```text
|
|
124
|
+
F × O × M × S
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
where:
|
|
128
|
+
|
|
129
|
+
| Symbol | Meaning | Example |
|
|
130
|
+
|---|---|---|
|
|
131
|
+
| `F` | Number of dataset files in the configuration | `{"ETTh1": ..., "Weather": ...}` → `F = 2` |
|
|
132
|
+
| `O` | Number of input/output size configurations | `[32, 64, 128]` → `O = 3` |
|
|
133
|
+
| `M` | Number of models | `{"Linear": ..., "LSTM": ...}` → `M = 2` |
|
|
134
|
+
| `S` | Number of seeds | `[42, 43, 44]` → `S = 3` |
|
|
135
|
+
|
|
136
|
+
ModelMark repeats the training/evaluation process for each combination and stores the mean result over `S` runs. Using more seeds generally makes the comparison more fair and statistically stable.
|
|
137
|
+
|
|
138
|
+
## Reported Metrics
|
|
139
|
+
|
|
140
|
+
The report includes statistics such as:
|
|
141
|
+
|
|
142
|
+
| Metric | Description |
|
|
143
|
+
|---|---|
|
|
144
|
+
| Time | Average training time per epoch |
|
|
145
|
+
| Params | Total number of model parameters |
|
|
146
|
+
| GFLOPs | Average GFLOPs per batch |
|
|
147
|
+
| Peak Memory | Maximum memory observed during a training iteration |
|
|
148
|
+
|
|
149
|
+
The report also includes the evaluation metrics configured in `test_config` and your machine metadata.
|
|
150
|
+
|
|
151
|
+
## Examples
|
|
152
|
+
|
|
153
|
+
Run `modelmark init`, it will create config at `modelmark_files/config.py` and model's example folder at `models/` with Linear model file inside:
|
|
154
|
+
|
|
155
|
+
- Configuration example: [src/modelmark/config.py](https://github.com/gloptim77/ModelMark/blob/main/src/modelmark/config.py)
|
|
156
|
+
- Linear model example: [src/modelmark/models/linear.py](https://github.com/gloptim77/ModelMark/blob/main/src/modelmark/models/linear.py)
|
|
157
|
+
|
|
158
|
+
## Troubleshooting
|
|
159
|
+
|
|
160
|
+
If something does not work:
|
|
161
|
+
|
|
162
|
+
1. Check the application log:
|
|
163
|
+
`modelmark_files/modelmark.log`
|
|
164
|
+
2. Try restarting ModelMark:
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
modelmark restart
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
3. If the issue persists, delete the `modelmark_files` folder and run:
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
modelmark init
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
When opening an issue on GitHub, please include the relevant part of your log file.
|
|
177
|
+
|
|
178
|
+
If you have questions or want to inspect the source code, see the
|
|
179
|
+
[ModelMark GitHub repository](https://github.com/gloptim77/ModelMark/tree/main).
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# ModelMark
|
|
2
|
+
|
|
3
|
+
ModelMark is a CLI benchmarking tool for comparing neural-network models. It runs your models on one or more datasets, records performance and efficiency statistics, and generates an easy-to-embed HTML/PNG report.
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
## Table of Contents
|
|
8
|
+
|
|
9
|
+
- [About](#about)
|
|
10
|
+
- [Requirements](#requirements)
|
|
11
|
+
- [Installation](#installation)
|
|
12
|
+
- [Quick Start](#quick-start)
|
|
13
|
+
- [Configuration](#configuration)
|
|
14
|
+
- [How the Benchmark Works](#how-the-benchmark-works)
|
|
15
|
+
- [Reported Metrics](#reported-metrics)
|
|
16
|
+
- [Examples](#examples)
|
|
17
|
+
- [Troubleshooting](#troubleshooting)
|
|
18
|
+
|
|
19
|
+
## About
|
|
20
|
+
|
|
21
|
+
For each benchmark run, ModelMark:
|
|
22
|
+
|
|
23
|
+
1. Selects the next combination of dataset, input/output size, model, and seed.
|
|
24
|
+
2. Seeds the random generators for reproducibility.
|
|
25
|
+
3. Creates the data loader, model, and tester objects.
|
|
26
|
+
4. Trains the model for the configured number of epochs and restores the checkpoint with the lowest validation loss.
|
|
27
|
+
5. Records runtime and efficiency statistics.
|
|
28
|
+
6. Evaluates the model on the dataset using the metrics from the configuration file.
|
|
29
|
+
|
|
30
|
+
After all runs finish, ModelMark aggregates the results and generates a report containing testing results, training statistics, and your machine metadata.
|
|
31
|
+
|
|
32
|
+
## Requirements
|
|
33
|
+
|
|
34
|
+
- OS: Windows or Linux
|
|
35
|
+
- Python: 3.12 or newer
|
|
36
|
+
- Git: required for installation from GitHub
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
Install ModelMark from PyPI:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install modelmark
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Quick Start
|
|
47
|
+
|
|
48
|
+
1. Run initialization in an empty folder:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
modelmark init
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
This creates two folders:
|
|
55
|
+
- `modelmark_files/` — configuration and log files
|
|
56
|
+
- `models/` — your model files
|
|
57
|
+
|
|
58
|
+
2. Edit the configuration file:
|
|
59
|
+
|
|
60
|
+
`modelmark_files/config.py`
|
|
61
|
+
|
|
62
|
+
It contains three main configuration blocks:
|
|
63
|
+
- `model_config` — model hyperparameters such as number of layers, hidden dimension, kernel size, etc.
|
|
64
|
+
- `data_config` — dataset parameters such as file path, input/output features, train/val ratios, etc.
|
|
65
|
+
- `test_config` — testing options such as optimizer, loss criterion, metrics, learning rate, etc.
|
|
66
|
+
|
|
67
|
+
3. Put the testing models to the `models/` folder.
|
|
68
|
+
|
|
69
|
+
Make sure to import model's class definitions to the `config.py`.
|
|
70
|
+
|
|
71
|
+
Configure `config.model_config` according to your task.
|
|
72
|
+
|
|
73
|
+
5. Download the dataset files (ETT by default):
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
modelmark load
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
6. Run the benchmark:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
modelmark run
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
7. View the generated report:
|
|
86
|
+
- `result.html`
|
|
87
|
+
- `result.png`
|
|
88
|
+
|
|
89
|
+
## Configuration
|
|
90
|
+
|
|
91
|
+
You can adjust the configuration and add your own model files in the `models/` directory to match your benchmarking needs.
|
|
92
|
+
|
|
93
|
+
Make sure your model implementation is compatible with the keys and settings used in your configuration.
|
|
94
|
+
|
|
95
|
+
A detailed configuration example is available at:
|
|
96
|
+
[src/modelmark/config.py](https://github.com/gloptim77/ModelMark/blob/main/src/modelmark/config.py)
|
|
97
|
+
|
|
98
|
+
A detailed example model is available at:
|
|
99
|
+
[src/modelmark/models/linear.py](https://github.com/gloptim77/ModelMark/blob/main/src/modelmark/models/linear.py)
|
|
100
|
+
|
|
101
|
+
## How the Benchmark Works
|
|
102
|
+
|
|
103
|
+
The benchmark consists of:
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
F × O × M × S
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
where:
|
|
110
|
+
|
|
111
|
+
| Symbol | Meaning | Example |
|
|
112
|
+
|---|---|---|
|
|
113
|
+
| `F` | Number of dataset files in the configuration | `{"ETTh1": ..., "Weather": ...}` → `F = 2` |
|
|
114
|
+
| `O` | Number of input/output size configurations | `[32, 64, 128]` → `O = 3` |
|
|
115
|
+
| `M` | Number of models | `{"Linear": ..., "LSTM": ...}` → `M = 2` |
|
|
116
|
+
| `S` | Number of seeds | `[42, 43, 44]` → `S = 3` |
|
|
117
|
+
|
|
118
|
+
ModelMark repeats the training/evaluation process for each combination and stores the mean result over `S` runs. Using more seeds generally makes the comparison more fair and statistically stable.
|
|
119
|
+
|
|
120
|
+
## Reported Metrics
|
|
121
|
+
|
|
122
|
+
The report includes statistics such as:
|
|
123
|
+
|
|
124
|
+
| Metric | Description |
|
|
125
|
+
|---|---|
|
|
126
|
+
| Time | Average training time per epoch |
|
|
127
|
+
| Params | Total number of model parameters |
|
|
128
|
+
| GFLOPs | Average GFLOPs per batch |
|
|
129
|
+
| Peak Memory | Maximum memory observed during a training iteration |
|
|
130
|
+
|
|
131
|
+
The report also includes the evaluation metrics configured in `test_config` and your machine metadata.
|
|
132
|
+
|
|
133
|
+
## Examples
|
|
134
|
+
|
|
135
|
+
Run `modelmark init`, it will create config at `modelmark_files/config.py` and model's example folder at `models/` with Linear model file inside:
|
|
136
|
+
|
|
137
|
+
- Configuration example: [src/modelmark/config.py](https://github.com/gloptim77/ModelMark/blob/main/src/modelmark/config.py)
|
|
138
|
+
- Linear model example: [src/modelmark/models/linear.py](https://github.com/gloptim77/ModelMark/blob/main/src/modelmark/models/linear.py)
|
|
139
|
+
|
|
140
|
+
## Troubleshooting
|
|
141
|
+
|
|
142
|
+
If something does not work:
|
|
143
|
+
|
|
144
|
+
1. Check the application log:
|
|
145
|
+
`modelmark_files/modelmark.log`
|
|
146
|
+
2. Try restarting ModelMark:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
modelmark restart
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
3. If the issue persists, delete the `modelmark_files` folder and run:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
modelmark init
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
When opening an issue on GitHub, please include the relevant part of your log file.
|
|
159
|
+
|
|
160
|
+
If you have questions or want to inspect the source code, see the
|
|
161
|
+
[ModelMark GitHub repository](https://github.com/gloptim77/ModelMark/tree/main).
|
|
@@ -15,23 +15,23 @@ class CausalDataset(Dataset):
|
|
|
15
15
|
Sliding-window dataset for ETT.
|
|
16
16
|
|
|
17
17
|
Returns:
|
|
18
|
-
x: [
|
|
19
|
-
y: [
|
|
18
|
+
x: [input_len, num_features]
|
|
19
|
+
y: [output_len, 1]
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
22
|
def __init__(
|
|
23
23
|
self,
|
|
24
24
|
data_config: dict,
|
|
25
|
-
|
|
26
|
-
|
|
25
|
+
input_len: int,
|
|
26
|
+
output_len: int,
|
|
27
27
|
split: str = "train",
|
|
28
28
|
mean: np.ndarray | None = None,
|
|
29
29
|
std: np.ndarray | None = None,
|
|
30
30
|
):
|
|
31
31
|
super().__init__()
|
|
32
32
|
|
|
33
|
-
self.
|
|
34
|
-
self.
|
|
33
|
+
self.input_len = input_len
|
|
34
|
+
self.output_len = output_len
|
|
35
35
|
|
|
36
36
|
# Extract config
|
|
37
37
|
data_path = config.data_path + data_config["path"]
|
|
@@ -54,12 +54,15 @@ class CausalDataset(Dataset):
|
|
|
54
54
|
train_end = int(n * train_ratio)
|
|
55
55
|
val_end = int(n * (train_ratio + val_ratio))
|
|
56
56
|
|
|
57
|
+
# Train can be random
|
|
57
58
|
if split == "train":
|
|
58
59
|
start = 0
|
|
59
60
|
end = train_end
|
|
61
|
+
# Val never intersects with train
|
|
60
62
|
elif split == "val":
|
|
61
63
|
start = train_end
|
|
62
64
|
end = val_end
|
|
65
|
+
# Test never intersects with train or val
|
|
63
66
|
elif split == "test":
|
|
64
67
|
start = val_end
|
|
65
68
|
end = n
|
|
@@ -89,23 +92,24 @@ class CausalDataset(Dataset):
|
|
|
89
92
|
self.data = data[start:end]
|
|
90
93
|
|
|
91
94
|
# Number of valid windows
|
|
92
|
-
self.length = len(self.data) -
|
|
95
|
+
self.length = len(self.data) - input_len - output_len + 1
|
|
93
96
|
|
|
94
97
|
if self.length <= 0:
|
|
95
98
|
raise ValueError(
|
|
96
99
|
f"Split '{split}' is too short for "
|
|
97
|
-
f"
|
|
100
|
+
f"input_len={input_len}, output_len={output_len}"
|
|
98
101
|
)
|
|
99
102
|
|
|
100
103
|
def __len__(self):
|
|
101
104
|
return self.length
|
|
102
105
|
|
|
103
106
|
def __getitem__(self, idx):
|
|
107
|
+
|
|
104
108
|
x_start = idx
|
|
105
|
-
x_end = x_start + self.
|
|
109
|
+
x_end = x_start + self.input_len
|
|
106
110
|
|
|
107
111
|
y_start = x_end
|
|
108
|
-
y_end = y_start + self.
|
|
112
|
+
y_end = y_start + self.output_len
|
|
109
113
|
|
|
110
114
|
x = self.data[x_start:x_end, self.input_indices]
|
|
111
115
|
y = self.data[y_start:y_end, self.output_indices]
|
|
@@ -10,29 +10,29 @@ config = load_config()
|
|
|
10
10
|
|
|
11
11
|
class Loader:
|
|
12
12
|
|
|
13
|
-
def __init__(self, file_config : dict,
|
|
13
|
+
def __init__(self, file_config : dict, input_len : int, output_len : int):
|
|
14
14
|
|
|
15
|
-
self.get_dataloaders(file_config,
|
|
15
|
+
self.get_dataloaders(file_config, input_len, output_len)
|
|
16
16
|
logger.debug(f"Dataset len stats: train={len(self.train_loader)} val={len(self.val_loader)} test={len(self.test_loader)}")
|
|
17
17
|
|
|
18
|
-
def get_dataloaders(self, file_config : dict,
|
|
18
|
+
def get_dataloaders(self, file_config : dict, input_len : int, output_len : int) -> tuple[DataLoader, DataLoader, DataLoader]:
|
|
19
19
|
"""Load the data, pack to datasets, create the loaders and return them"""
|
|
20
20
|
|
|
21
21
|
train_ds = CausalDataset(data_config = file_config,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
input_len = input_len,
|
|
23
|
+
output_len = output_len,
|
|
24
24
|
split = "train")
|
|
25
25
|
|
|
26
26
|
val_ds = CausalDataset(data_config = file_config,
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
input_len = input_len,
|
|
28
|
+
output_len = output_len,
|
|
29
29
|
split = "val",
|
|
30
30
|
mean = train_ds.mean,
|
|
31
31
|
std = train_ds.std)
|
|
32
32
|
|
|
33
33
|
test_ds = CausalDataset(data_config = file_config,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
input_len = input_len,
|
|
35
|
+
output_len = output_len,
|
|
36
36
|
split = "test",
|
|
37
37
|
mean = train_ds.mean,
|
|
38
38
|
std = train_ds.std)
|
|
@@ -21,22 +21,24 @@ class Parser:
|
|
|
21
21
|
formatter_class=argparse.RawTextHelpFormatter,
|
|
22
22
|
description = constants.PARSER_DESC
|
|
23
23
|
)
|
|
24
|
+
|
|
25
|
+
# Create a subparser container
|
|
26
|
+
subparsers = self.parser.add_subparsers(dest="command", required=True)
|
|
24
27
|
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
)
|
|
28
|
+
# Define your action words (subcommands)
|
|
29
|
+
subparsers.add_parser("init", help = "Test init, create the modelmark_files/, customizable config.py file and models/ with examples.")
|
|
30
|
+
subparsers.add_parser("load", help = "Dataset download, create the data/ folder and download ETT dataset there.")
|
|
31
|
+
subparsers.add_parser("run", help = "Run the test.")
|
|
32
|
+
subparsers.add_parser("clear", help = "Remove the modelmark_files folder.")
|
|
33
|
+
subparsers.add_parser("reset", help = "Runs clean and init.")
|
|
34
|
+
subparsers.add_parser("help", help = "Print the info above.")
|
|
35
|
+
|
|
36
|
+
self.args = self.parser.parse_args()
|
|
32
37
|
|
|
33
38
|
# Run without args / help request - print help
|
|
34
39
|
if len(sys.argv) == 1:
|
|
35
40
|
self.parser.print_help()
|
|
36
41
|
sys.exit(1)
|
|
37
|
-
|
|
38
|
-
# Parse argument values
|
|
39
|
-
self.args = self.parser.parse_args()
|
|
40
42
|
|
|
41
43
|
# Setup other
|
|
42
44
|
pd.set_option('display.colheader_justify', 'center')
|
|
@@ -45,38 +47,38 @@ class Parser:
|
|
|
45
47
|
"""Select the task and run"""
|
|
46
48
|
|
|
47
49
|
# Config initialization #
|
|
48
|
-
if self.args.
|
|
50
|
+
if self.args.command == "init":
|
|
49
51
|
self.init_config()
|
|
50
52
|
return 0
|
|
51
53
|
|
|
52
54
|
# Dataset download #
|
|
53
|
-
if self.args.
|
|
55
|
+
if self.args.command == "load":
|
|
54
56
|
download_dataset("ett")
|
|
55
57
|
return 0
|
|
56
58
|
|
|
57
59
|
# Run the test #
|
|
58
|
-
if self.args.
|
|
60
|
+
if self.args.command == "run":
|
|
59
61
|
return None
|
|
60
62
|
|
|
61
63
|
# Clean the config folder #
|
|
62
|
-
if self.args.
|
|
64
|
+
if self.args.command == "clear":
|
|
63
65
|
self.clear_config()
|
|
64
66
|
return 0
|
|
65
67
|
|
|
66
68
|
# Reset the modelmark config #
|
|
67
|
-
if self.args.
|
|
69
|
+
if self.args.command == "reset":
|
|
68
70
|
self.reset_config()
|
|
69
71
|
return 0
|
|
70
72
|
|
|
71
73
|
# Print the modelmark usage #
|
|
72
|
-
if self.args.
|
|
74
|
+
if self.args.command == "help":
|
|
73
75
|
self.parser.print_help()
|
|
74
76
|
return 0
|
|
75
77
|
|
|
76
78
|
# Check if task is correct #
|
|
77
|
-
if self.args.
|
|
78
|
-
logger.error(f"Unknown
|
|
79
|
-
console.print(f"Unknown
|
|
79
|
+
if self.args.command != "run":
|
|
80
|
+
logger.error(f"Unknown command: {self.args.command}, run 'modelmark help' for more info")
|
|
81
|
+
console.print(f"Unknown command: {self.args.command}, run 'modelmark help' for more info", style="red")
|
|
80
82
|
return 1
|
|
81
83
|
|
|
82
84
|
# Otherwise return error
|
|
@@ -9,6 +9,7 @@ import torch.nn as nn
|
|
|
9
9
|
from modelmark.models.gru import GRUModel
|
|
10
10
|
from modelmark.models.conv import ConvModel
|
|
11
11
|
from modelmark.models.lstm import LSTMModel
|
|
12
|
+
from modelmark.models.transformer import TransformerModel
|
|
12
13
|
from modelmark.models.linear import Linear
|
|
13
14
|
# Either custom (uncomment)
|
|
14
15
|
#from models.linear import Linear
|
|
@@ -85,7 +86,8 @@ test_config = {
|
|
|
85
86
|
"MAE": nn.L1Loss(),
|
|
86
87
|
},
|
|
87
88
|
"seeds": [1, 2, 3],
|
|
88
|
-
"
|
|
89
|
+
"input_len": [96, 96, 96], # len should be equal to output_len
|
|
90
|
+
"output_len": [96, 192, 336], # len should be equal to input_len
|
|
89
91
|
}
|
|
90
92
|
|
|
91
93
|
# Other
|
|
@@ -24,11 +24,4 @@ USER_MODEL_PATH = USER_DIR / "models" / "linear.py"
|
|
|
24
24
|
PARSER_DESC = """MODELMARK
|
|
25
25
|
|
|
26
26
|
Python tool to measure the performance of a custom neural network model
|
|
27
|
-
and compare it to other popular architectures."""
|
|
28
|
-
PARSER_HELP = """\nModelmark available TASKs:
|
|
29
|
-
init - Test init, create the modelmark_files/, customizable config.py file and models/ with examples.
|
|
30
|
-
load - Dataset download, create the data/ folder and download ETT dataset there.
|
|
31
|
-
run - Run the test.
|
|
32
|
-
clear - Remove the modelmark_files folder.
|
|
33
|
-
reset - Runs clean and init.
|
|
34
|
-
"""
|
|
27
|
+
and compare it to other popular architectures."""
|