Skip to content

Commit 7aa270f

Browse files
0.15.9
documentation
1 parent 1e8eb07 commit 7aa270f

3 files changed

Lines changed: 29 additions & 19 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ build-backend = "setuptools.build_meta"
77

88
[project]
99
name = "spotpython"
10-
version = "0.15.8"
10+
version = "0.15.9"
1111
authors = [
1212
{ name="T. Bartz-Beielstein", email="tbb@bartzundbartz.de" }
1313
]

src/spotpython/light/regression/netlightregression.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
class NetLightRegression(L.LightningModule):
99
"""
1010
A LightningModule class for a regression neural network model.
11+
This is a very simple basic class. An enhanced version of this class is available
12+
as nn_linear_regression.py in the same directory.
1113
1214
Attributes:
1315
l1 (int):
@@ -76,7 +78,6 @@ class NetLightRegression(L.LightningModule):
7678
0 Non-trainable params
7779
15.9 K Total params
7880
0.064 Total estimated model params size (MB)
79-
8081
─────────────────────────────────────────────────────────────
8182
Validate metric DataLoader 0
8283
─────────────────────────────────────────────────────────────
@@ -89,7 +90,6 @@ class NetLightRegression(L.LightningModule):
8990
hp_metric 29010.7734375
9091
val_loss 29010.7734375
9192
─────────────────────────────────────────────────────────────
92-
9393
[{'val_loss': 28981.529296875, 'hp_metric': 28981.529296875}]
9494
"""
9595

@@ -155,7 +155,9 @@ def __init__(
155155
if self.hparams.l1 < 4:
156156
raise ValueError("l1 must be at least 4")
157157

158-
# TODO: Implement a hidden_sizes generator function
158+
# TODO: Implement a hidden_sizes generator function.
159+
# This function is implemented in the updadated version of this class which
160+
# is available as nn_linear_regression.py in the same directory.
159161
hidden_sizes = [self.hparams.l1, self.hparams.l1 // 2, self.hparams.l1 // 2, self.hparams.l1 // 4]
160162
# n_low = _L_in // 4
161163
# # ensure that n_high is larger than n_low

src/spotpython/light/regression/nn_linear_regressor.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,14 @@ class NNLinearRegressor(L.LightningModule):
6969
trainer.fit(net_light_base, train_loader)
7070
trainer.validate(net_light_base, val_loader)
7171
trainer.test(net_light_base, test_loader)
72-
73-
| Name | Type | Params | In sizes | Out sizes
72+
| Name | Type | Params | In sizes | Out sizes
7473
-------------------------------------------------------------
7574
0 | layers | Sequential | 15.9 K | [8, 10] | [8, 1]
7675
-------------------------------------------------------------
7776
15.9 K Trainable params
7877
0 Non-trainable params
7978
15.9 K Total params
8079
0.064 Total estimated model params size (MB)
81-
8280
─────────────────────────────────────────────────────────────
8381
Validate metric DataLoader 0
8482
─────────────────────────────────────────────────────────────
@@ -91,7 +89,6 @@ class NNLinearRegressor(L.LightningModule):
9189
hp_metric 29010.7734375
9290
val_loss 29010.7734375
9391
─────────────────────────────────────────────────────────────
94-
9592
[{'val_loss': 28981.529296875, 'hp_metric': 28981.529296875}]
9693
"""
9794

@@ -114,17 +111,28 @@ def __init__(
114111
Initializes the NNLinearRegressor object.
115112
116113
Args:
117-
l1 (int): The number of neurons in the first hidden layer.
118-
epochs (int): The number of epochs to train the model for.
119-
batch_size (int): The batch size to use during training.
120-
initialization (str): The initialization method to use for the weights.
121-
act_fn (nn.Module): The activation function to use in the hidden layers.
122-
optimizer (str): The optimizer to use during training.
123-
dropout_prob (float): The probability of dropping out a neuron during training.
124-
lr_mult (float): The learning rate multiplier for the optimizer.
125-
patience (int): The number of epochs to wait before early stopping.
126-
_L_in (int): The number of input features. Not a hyperparameter, but needed to create the network.
127-
_L_out (int): The number of output classes. Not a hyperparameter, but needed to create the network.
114+
l1 (int):
115+
The number of neurons in the first hidden layer.
116+
epochs (int):
117+
The number of epochs to train the model for.
118+
batch_size (int):
119+
The batch size to use during training.
120+
initialization (str):
121+
The initialization method to use for the weights.
122+
act_fn (nn.Module):
123+
The activation function to use in the hidden layers.
124+
optimizer (str):
125+
The optimizer to use during training.
126+
dropout_prob (float):
127+
The probability of dropping out a neuron during training.
128+
lr_mult (float):
129+
The learning rate multiplier for the optimizer.
130+
patience (int):
131+
The number of epochs to wait before early stopping.
132+
_L_in (int):
133+
The number of input features. Not a hyperparameter, but needed to create the network.
134+
_L_out (int):
135+
The number of output classes. Not a hyperparameter, but needed to create the network.
128136
_torchmetric (str):
129137
The metric to use for the loss function. If `None`,
130138
then "mean_squared_error" is used.

0 commit comments

Comments
 (0)