PVNet_summation 1.1.0__tar.gz → 1.1.1__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.
Potentially problematic release.
This version of PVNet_summation might be problematic. Click here for more details.
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/PKG-INFO +1 -1
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/PVNet_summation.egg-info/PKG-INFO +1 -1
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/training/lightning_module.py +41 -10
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/training/plots.py +14 -3
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/LICENSE +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/PVNet_summation.egg-info/SOURCES.txt +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/PVNet_summation.egg-info/dependency_links.txt +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/PVNet_summation.egg-info/requires.txt +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/PVNet_summation.egg-info/top_level.txt +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/README.md +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/__init__.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/data/__init__.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/data/datamodule.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/load_model.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/models/__init__.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/models/base_model.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/models/dense_model.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/models/horizon_dense_model.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/optimizers.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/training/__init__.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/training/train.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/utils.py +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pyproject.toml +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/setup.cfg +0 -0
- {pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/tests/test_end2end.py +0 -0
{pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/training/lightning_module.py
RENAMED
|
@@ -141,6 +141,7 @@ class PVNetSummationLightningModule(pl.LightningModule):
|
|
|
141
141
|
self._val_horizon_maes: list[np.array] = []
|
|
142
142
|
if self.current_epoch==0:
|
|
143
143
|
self._val_persistence_horizon_maes: list[np.array] = []
|
|
144
|
+
self._val_loc_sum_horizon_maes: list[np.array] = []
|
|
144
145
|
|
|
145
146
|
# Plot some sample forecasts
|
|
146
147
|
val_dataset = self.trainer.val_dataloaders.dataset
|
|
@@ -159,8 +160,10 @@ class PVNetSummationLightningModule(pl.LightningModule):
|
|
|
159
160
|
batch = self.transfer_batch_to_device(batch, self.device, dataloader_idx=0)
|
|
160
161
|
with torch.no_grad():
|
|
161
162
|
y_hat = self.model(batch)
|
|
163
|
+
|
|
164
|
+
y_loc_sum = self.model.sum_of_locations(batch)
|
|
162
165
|
|
|
163
|
-
fig = plot_sample_forecasts(batch, y_hat,
|
|
166
|
+
fig = plot_sample_forecasts(batch, y_hat, y_loc_sum, self.model.output_quantiles)
|
|
164
167
|
|
|
165
168
|
plot_name = f"val_forecast_samples/sample_set_{plot_num}"
|
|
166
169
|
|
|
@@ -195,9 +198,11 @@ class PVNetSummationLightningModule(pl.LightningModule):
|
|
|
195
198
|
losses.update({f"val_step_MAE/step_{i:03}": m for i, m in enumerate(mae_step)})
|
|
196
199
|
losses.update({f"val_step_MSE/step_{i:03}": m for i, m in enumerate(mse_step)})
|
|
197
200
|
|
|
198
|
-
# Calculate the
|
|
199
|
-
# not every epoch
|
|
201
|
+
# Calculate the persistence and sum-of-locations losses - we only need to do this once per
|
|
202
|
+
# training run not every epoch
|
|
200
203
|
if self.current_epoch==0:
|
|
204
|
+
|
|
205
|
+
# Persistence
|
|
201
206
|
y_persist = batch["last_outturn"].unsqueeze(1).expand(-1, self.model.forecast_len)
|
|
202
207
|
mae_step_persist, mse_step_persist = self._calculate_step_metrics(y, y_persist)
|
|
203
208
|
self._val_persistence_horizon_maes.append(mae_step_persist)
|
|
@@ -208,6 +213,17 @@ class PVNetSummationLightningModule(pl.LightningModule):
|
|
|
208
213
|
}
|
|
209
214
|
)
|
|
210
215
|
|
|
216
|
+
# Sum of Locations
|
|
217
|
+
y_loc_sum = self.model.sum_of_locations(batch)
|
|
218
|
+
mae_step_loc_sum, mse_step_loc_sum = self._calculate_step_metrics(y, y_loc_sum)
|
|
219
|
+
self._val_loc_sum_horizon_maes.append(mae_step_loc_sum)
|
|
220
|
+
losses.update(
|
|
221
|
+
{
|
|
222
|
+
"MAE/val_location_sum": mae_step_loc_sum.mean(),
|
|
223
|
+
"MSE/val_location_sum": mse_step_loc_sum.mean()
|
|
224
|
+
}
|
|
225
|
+
)
|
|
226
|
+
|
|
211
227
|
# Log the metrics
|
|
212
228
|
self.log_dict(losses, on_step=False, on_epoch=True)
|
|
213
229
|
|
|
@@ -217,11 +233,6 @@ class PVNetSummationLightningModule(pl.LightningModule):
|
|
|
217
233
|
val_horizon_maes = np.mean(self._val_horizon_maes, axis=0)
|
|
218
234
|
self._val_horizon_maes = []
|
|
219
235
|
|
|
220
|
-
# We only run this on the first epoch
|
|
221
|
-
if self.current_epoch==0:
|
|
222
|
-
val_persistence_horizon_maes = np.mean(self._val_persistence_horizon_maes, axis=0)
|
|
223
|
-
self._val_persistence_horizon_maes = []
|
|
224
|
-
|
|
225
236
|
if isinstance(self.logger, pl.loggers.WandbLogger):
|
|
226
237
|
|
|
227
238
|
# Create the horizon accuracy curve
|
|
@@ -235,8 +246,14 @@ class PVNetSummationLightningModule(pl.LightningModule):
|
|
|
235
246
|
|
|
236
247
|
wandb.log({"val_horizon_mae_plot": horizon_mae_plot})
|
|
237
248
|
|
|
238
|
-
# Create persistence horizon accuracy curve
|
|
249
|
+
# Create persistence and location-sum horizon accuracy curve on first epoch
|
|
239
250
|
if self.current_epoch==0:
|
|
251
|
+
val_persistence_horizon_maes = np.mean(self._val_persistence_horizon_maes, axis=0)
|
|
252
|
+
del self._val_persistence_horizon_maes
|
|
253
|
+
|
|
254
|
+
val_loc_sum_horizon_maes = np.mean(self._val_loc_sum_horizon_maes, axis=0)
|
|
255
|
+
del self._val_loc_sum_horizon_maes
|
|
256
|
+
|
|
240
257
|
persist_horizon_mae_plot = wandb_line_plot(
|
|
241
258
|
x=np.arange(self.model.forecast_len),
|
|
242
259
|
y=val_persistence_horizon_maes,
|
|
@@ -244,4 +261,18 @@ class PVNetSummationLightningModule(pl.LightningModule):
|
|
|
244
261
|
ylabel="MAE",
|
|
245
262
|
title="Val persistence horizon loss curve",
|
|
246
263
|
)
|
|
247
|
-
|
|
264
|
+
|
|
265
|
+
loc_sum_horizon_mae_plot = wandb_line_plot(
|
|
266
|
+
x=np.arange(self.model.forecast_len),
|
|
267
|
+
y=val_loc_sum_horizon_maes,
|
|
268
|
+
xlabel="Horizon step",
|
|
269
|
+
ylabel="MAE",
|
|
270
|
+
title="Val location-sum horizon loss curve",
|
|
271
|
+
)
|
|
272
|
+
|
|
273
|
+
wandb.log(
|
|
274
|
+
{
|
|
275
|
+
"persistence_val_horizon_mae_plot": persist_horizon_mae_plot,
|
|
276
|
+
"location_sum_val_horizon_mae_plot": loc_sum_horizon_mae_plot,
|
|
277
|
+
}
|
|
278
|
+
)
|
|
@@ -26,12 +26,14 @@ def wandb_line_plot(
|
|
|
26
26
|
def plot_sample_forecasts(
|
|
27
27
|
batch: SumTensorBatch,
|
|
28
28
|
y_hat: torch.Tensor,
|
|
29
|
+
y_loc_sum: torch.Tensor,
|
|
29
30
|
quantiles: list[float] | None,
|
|
30
31
|
) -> plt.Figure:
|
|
31
32
|
"""Plot a batch of data and the forecast from that batch"""
|
|
32
33
|
|
|
33
34
|
y = batch["target"].cpu().numpy()
|
|
34
|
-
y_hat = y_hat.cpu().numpy()
|
|
35
|
+
y_hat = y_hat.cpu().numpy()
|
|
36
|
+
y_loc_sum = y_loc_sum.cpu().numpy()
|
|
35
37
|
times_utc = pd.to_datetime(batch["valid_times"].cpu().numpy().astype("datetime64[ns]"))
|
|
36
38
|
batch_size = y.shape[0]
|
|
37
39
|
|
|
@@ -41,9 +43,18 @@ def plot_sample_forecasts(
|
|
|
41
43
|
|
|
42
44
|
ax.plot(times_utc[i], y[i], marker=".", color="k", label=r"$y$")
|
|
43
45
|
|
|
46
|
+
ax.plot(
|
|
47
|
+
times_utc[i],
|
|
48
|
+
y_loc_sum[i],
|
|
49
|
+
marker=".",
|
|
50
|
+
linestyle="-.",
|
|
51
|
+
color="r",
|
|
52
|
+
label=r"$\hat{y}_{loc-sum}$",
|
|
53
|
+
)
|
|
54
|
+
|
|
44
55
|
if quantiles is None:
|
|
45
56
|
ax.plot(
|
|
46
|
-
times_utc[i]
|
|
57
|
+
times_utc[i],
|
|
47
58
|
y_hat[i],
|
|
48
59
|
marker=".",
|
|
49
60
|
color="r",
|
|
@@ -53,7 +64,7 @@ def plot_sample_forecasts(
|
|
|
53
64
|
cm = pylab.get_cmap("twilight")
|
|
54
65
|
for nq, q in enumerate(quantiles):
|
|
55
66
|
ax.plot(
|
|
56
|
-
times_utc[i]
|
|
67
|
+
times_utc[i],
|
|
57
68
|
y_hat[i, :, nq],
|
|
58
69
|
color=cm(q),
|
|
59
70
|
label=r"$\hat{y}$" + f"({q})",
|
|
File without changes
|
|
File without changes
|
{pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/PVNet_summation.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{pvnet_summation-1.1.0 → pvnet_summation-1.1.1}/pvnet_summation/models/horizon_dense_model.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|