changed model to require less compute
Browse files- app.py +1 -1
- model_training/__pycache__/model.cpython-313.pyc +0 -0
- model_training/args.txt +3 -3
- model_training/model.py +3 -2
- model_training/run_training.py +4 -3
- saved_models/tiny_vgg_less_compute_model.pth +0 -3
- saved_models/tiny_vgg_less_compute_settings.yaml +0 -13
- saved_models/tiny_vgg_model.pth +2 -2
- saved_models/tiny_vgg_settings.yaml +4 -3
app.py
CHANGED
@@ -204,7 +204,7 @@ def create_app():
|
|
204 |
'''
|
205 |
# Used to serve with panel serve in command line
|
206 |
save_dir = FILE_PATH + '/saved_models'
|
207 |
-
base_name = '
|
208 |
|
209 |
mod_path = f'{save_dir}/{base_name}_model.pth' # Path to the saved model state dict
|
210 |
settings_path = f'{save_dir}/{base_name}_settings.yaml' # Path to the saved model kwargs
|
|
|
204 |
'''
|
205 |
# Used to serve with panel serve in command line
|
206 |
save_dir = FILE_PATH + '/saved_models'
|
207 |
+
base_name = 'tiny_vgg'
|
208 |
|
209 |
mod_path = f'{save_dir}/{base_name}_model.pth' # Path to the saved model state dict
|
210 |
settings_path = f'{save_dir}/{base_name}_settings.yaml' # Path to the saved model kwargs
|
model_training/__pycache__/model.cpython-313.pyc
DELETED
Binary file (6.18 kB)
|
|
model_training/args.txt
CHANGED
@@ -1,12 +1,12 @@
|
|
1 |
--num-workers
|
2 |
0
|
3 |
--num-epochs
|
4 |
-
|
5 |
--batch-size
|
6 |
100
|
7 |
--learning-rate
|
8 |
0.001
|
9 |
--patience
|
10 |
-
|
11 |
--min-delta
|
12 |
-
0.
|
|
|
1 |
--num-workers
|
2 |
0
|
3 |
--num-epochs
|
4 |
+
100
|
5 |
--batch-size
|
6 |
100
|
7 |
--learning-rate
|
8 |
0.001
|
9 |
--patience
|
10 |
+
20
|
11 |
--min-delta
|
12 |
+
0.0005
|
model_training/model.py
CHANGED
@@ -69,6 +69,7 @@ class TinyVGG(nn.Module):
|
|
69 |
num_convs (int): Number of consecutive convolutional layers + ReLU activations in each VGG block.
|
70 |
in_channels (int): Number of channels in the input.
|
71 |
hidden_channels (int): Number of hidden channels between convolutional layers.
|
|
|
72 |
num_classes (int): Number of class labels.
|
73 |
|
74 |
'''
|
@@ -77,6 +78,7 @@ class TinyVGG(nn.Module):
|
|
77 |
num_convs: int,
|
78 |
in_channels: int,
|
79 |
hidden_channels: int,
|
|
|
80 |
num_classes: int):
|
81 |
super().__init__()
|
82 |
|
@@ -90,8 +92,7 @@ class TinyVGG(nn.Module):
|
|
90 |
self.vgg_body = nn.Sequential(*self.all_blks)
|
91 |
self.classifier = nn.Sequential(
|
92 |
nn.Flatten(),
|
93 |
-
nn.LazyLinear(
|
94 |
-
nn.LazyLinear(2048), nn.ReLU(), nn.Dropout(0.5),
|
95 |
nn.LazyLinear(num_classes)
|
96 |
)
|
97 |
|
|
|
69 |
num_convs (int): Number of consecutive convolutional layers + ReLU activations in each VGG block.
|
70 |
in_channels (int): Number of channels in the input.
|
71 |
hidden_channels (int): Number of hidden channels between convolutional layers.
|
72 |
+
fc_hidden_dim (int): Number of output (hidden) features for the first linear layer of the classifer.
|
73 |
num_classes (int): Number of class labels.
|
74 |
|
75 |
'''
|
|
|
78 |
num_convs: int,
|
79 |
in_channels: int,
|
80 |
hidden_channels: int,
|
81 |
+
fc_hidden_dim: int,
|
82 |
num_classes: int):
|
83 |
super().__init__()
|
84 |
|
|
|
92 |
self.vgg_body = nn.Sequential(*self.all_blks)
|
93 |
self.classifier = nn.Sequential(
|
94 |
nn.Flatten(),
|
95 |
+
nn.LazyLinear(fc_hidden_dim), nn.ReLU(), nn.Dropout(0.5),
|
|
|
96 |
nn.LazyLinear(num_classes)
|
97 |
)
|
98 |
|
model_training/run_training.py
CHANGED
@@ -17,13 +17,13 @@ parser = argparse.ArgumentParser(fromfile_prefix_chars = '@')
|
|
17 |
parser.add_argument('-nw', '--num-workers', help = 'Number of workers for dataloaders.',
|
18 |
type = int, default = 0)
|
19 |
parser.add_argument('-ne', '--num-epochs', help = 'Number of epochs to train model for.',
|
20 |
-
type = int, default =
|
21 |
parser.add_argument('-bs', '--batch-size', help = 'Size of batches to split training set.',
|
22 |
type = int, default = 100)
|
23 |
parser.add_argument('-lr', '--learning-rate', help = 'Learning rate for the optimizer.',
|
24 |
type = float, default = 0.001)
|
25 |
parser.add_argument('-p', '--patience', help = 'Number of epochs to wait before early stopping.',
|
26 |
-
type = int, default =
|
27 |
parser.add_argument('-md', '--min-delta', help = 'Minimum decrease in loss to reset patience.',
|
28 |
type = float, default = 0.001)
|
29 |
|
@@ -62,6 +62,7 @@ if __name__ == '__main__':
|
|
62 |
'num_convs': 2,
|
63 |
'in_channels': 1,
|
64 |
'hidden_channels': 10,
|
|
|
65 |
'num_classes': len(train_dl.dataset.classes)
|
66 |
}
|
67 |
|
@@ -87,4 +88,4 @@ if __name__ == '__main__':
|
|
87 |
device = utils.DEVICE,
|
88 |
save_mod = True,
|
89 |
save_dir = save_dir,
|
90 |
-
mod_name = mod_name)
|
|
|
17 |
parser.add_argument('-nw', '--num-workers', help = 'Number of workers for dataloaders.',
|
18 |
type = int, default = 0)
|
19 |
parser.add_argument('-ne', '--num-epochs', help = 'Number of epochs to train model for.',
|
20 |
+
type = int, default = 25)
|
21 |
parser.add_argument('-bs', '--batch-size', help = 'Size of batches to split training set.',
|
22 |
type = int, default = 100)
|
23 |
parser.add_argument('-lr', '--learning-rate', help = 'Learning rate for the optimizer.',
|
24 |
type = float, default = 0.001)
|
25 |
parser.add_argument('-p', '--patience', help = 'Number of epochs to wait before early stopping.',
|
26 |
+
type = int, default = 10)
|
27 |
parser.add_argument('-md', '--min-delta', help = 'Minimum decrease in loss to reset patience.',
|
28 |
type = float, default = 0.001)
|
29 |
|
|
|
62 |
'num_convs': 2,
|
63 |
'in_channels': 1,
|
64 |
'hidden_channels': 10,
|
65 |
+
'fc_hidden_dim': 64,
|
66 |
'num_classes': len(train_dl.dataset.classes)
|
67 |
}
|
68 |
|
|
|
88 |
device = utils.DEVICE,
|
89 |
save_mod = True,
|
90 |
save_dir = save_dir,
|
91 |
+
mod_name = mod_name)
|
saved_models/tiny_vgg_less_compute_model.pth
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:94a16b55d2a65b58c30bcad6dcee77d7e45e15221577795aa4de97a508fddced
|
3 |
-
size 38494248
|
|
|
|
|
|
|
|
saved_models/tiny_vgg_less_compute_settings.yaml
DELETED
@@ -1,13 +0,0 @@
|
|
1 |
-
mod_kwargs:
|
2 |
-
hidden_channels: 6
|
3 |
-
in_channels: 1
|
4 |
-
num_blks: 2
|
5 |
-
num_classes: 10
|
6 |
-
num_convs: 2
|
7 |
-
train_kwargs:
|
8 |
-
batch_size: 100
|
9 |
-
learning_rate: 0.001
|
10 |
-
min_delta: 0.0005
|
11 |
-
num_epochs: 50
|
12 |
-
num_workers: 0
|
13 |
-
patience: 10
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
saved_models/tiny_vgg_model.pth
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:883adf921aeb35183d6c770234e241280b916d49be5493aefb32d22d7a85dd22
|
3 |
+
size 150450
|
saved_models/tiny_vgg_settings.yaml
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
mod_kwargs:
|
|
|
2 |
hidden_channels: 10
|
3 |
in_channels: 1
|
4 |
num_blks: 2
|
@@ -7,7 +8,7 @@ mod_kwargs:
|
|
7 |
train_kwargs:
|
8 |
batch_size: 100
|
9 |
learning_rate: 0.001
|
10 |
-
min_delta: 0.
|
11 |
-
num_epochs:
|
12 |
num_workers: 0
|
13 |
-
patience:
|
|
|
1 |
mod_kwargs:
|
2 |
+
fc_hidden_dim: 64
|
3 |
hidden_channels: 10
|
4 |
in_channels: 1
|
5 |
num_blks: 2
|
|
|
8 |
train_kwargs:
|
9 |
batch_size: 100
|
10 |
learning_rate: 0.001
|
11 |
+
min_delta: 0.0005
|
12 |
+
num_epochs: 50
|
13 |
num_workers: 0
|
14 |
+
patience: 15
|