Updated diffusion section of thesis + adding metrics to diffusion experiments
This commit is contained in:
@@ -537,12 +537,17 @@ NRV + Load & & & & & & & & & \\
|
|||||||
& 4 & 512 & 32334.73 & 38000.40 & 135.92 & 146.10 & 78.82 & 83.99 \\
|
& 4 & 512 & 32334.73 & 38000.40 & 135.92 & 146.10 & 78.82 & 83.99 \\
|
||||||
& 8 & 512 & 35177.39 & 41104.28 & 141.79 & 152.13 & 83.79 & 89.13 \\
|
& 8 & 512 & 35177.39 & 41104.28 & 141.79 & 152.13 & 83.79 & 89.13 \\
|
||||||
\midrule
|
\midrule
|
||||||
NRV + Load + PV + Wind & & & & & & & & & \\
|
NRV + Load + PV\\ + Wind & & & & & & & & & \\
|
||||||
& 4 & 256 & 31594.55 & 39872.46 & 134.11 & 149.34 & 77.52 & 85.91 \\
|
& 4 & 256 & 31594.55 & 39872.46 & 134.11 & 149.34 & 77.52 & 85.91 \\
|
||||||
& 8 & 256 & 31481.22 & 39704.37 & 133.45 & 148.59 & 77.26 & 85.62 \\
|
& 8 & 256 & 31481.22 & 39704.37 & 133.45 & 148.59 & 77.26 & 85.62 \\
|
||||||
& 4 & 512 & 31368.31 & 39024.27 & 134.02 & 147.91 & 76.58 & 84.18 \\
|
& 4 & 512 & 31368.31 & 39024.27 & 134.02 & 147.91 & 76.58 & 84.18 \\
|
||||||
& 8 & 512 & 34566.66 & 42397.86 & 140.13 & 154.00 & 82.09 & 89.87 \\
|
& 8 & 512 & 34566.66 & 42397.86 & 140.13 & 154.00 & 82.09 & 89.87 \\
|
||||||
|
\midrule
|
||||||
|
NRV + Load + PV\\ + Wind + Net Position \\+ QE (5 dim) & & & & & & & & & \\
|
||||||
|
& 4 & 256 & 30130.37 & 39906.53 & 130.92 & 149.78 & 75.02 & 84.88 \\
|
||||||
|
& 8 & 256 & 28560.67 & 37675.15 & 127.77 & 145.39 & 73.77 & 83.37 \\
|
||||||
|
& 4 & 512 & & & & & & & \\
|
||||||
|
& 8 & 512 & 27421.85 & 35238.98 & 125.32 & 141.02 & 72.73 & 80.92 \\
|
||||||
\bottomrule
|
\bottomrule
|
||||||
\end{tabular}
|
\end{tabular}
|
||||||
\end{adjustbox}
|
\end{adjustbox}
|
||||||
@@ -550,8 +555,19 @@ NRV + Load + PV + Wind & & & & & & & & & \\
|
|||||||
\label{tab:autoregressive_gru_model_results}
|
\label{tab:autoregressive_gru_model_results}
|
||||||
\end{table}
|
\end{table}
|
||||||
|
|
||||||
|
TODO: Talk about the results + show plots of the samples with GRU model. Talk about the over/underestimation of the quantiles for the models. Plots have been made for this.
|
||||||
|
|
||||||
|
TODO: non autoregressive stuff?
|
||||||
|
|
||||||
\newpage
|
\newpage
|
||||||
\subsection{Diffusion}
|
\subsection{Diffusion}
|
||||||
|
% TODO: needed to explain again?
|
||||||
|
Another type of model that can be used to generatively model the NRV is the diffusion model. This type of model is very popular for image generation. In the context of images, the diffusion model is trained by iteratively adding noise to a training image until there is only noise left. From this noise, the model tries to reverse the diffusion process to get the original image back. To sample new images using this model, a noise vector is sampled and iteratively denoised by the model. This process results in a new image.
|
||||||
|
\\\\
|
||||||
|
This training process can also be used for other data types. An image is just a 2D grid of data points. A time series can be seen as a 1D sequence of data points. The diffusion model can thus be trained on the NRV data to generate new samples for a certain day based on a given input.
|
||||||
|
\\\\
|
||||||
|
Once the diffusion model is trained, it can be used efficiently to generate new samples. The model can generate samples in parallel, which is not possible with autoregressive models. A batch of noise vectors can be sampled and passed through the model in one batch to generate the new samples. The generated samples contain the 96 NRV values for the next day without needing to sample every quarter sequentially.
|
||||||
|
\\\\
|
||||||
|
TODO: Visualization of the diffusion model in the context of the NRV data.
|
||||||
|
\\\\
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
BIN
Reports/Thesis/verslag 3.synctex.gz
Normal file
BIN
Reports/Thesis/verslag 3.synctex.gz
Normal file
Binary file not shown.
BIN
Reports/Thesis/verslag 4.synctex.gz
Normal file
BIN
Reports/Thesis/verslag 4.synctex.gz
Normal file
Binary file not shown.
BIN
Reports/Thesis/verslag 5.synctex.gz
Normal file
BIN
Reports/Thesis/verslag 5.synctex.gz
Normal file
Binary file not shown.
BIN
Reports/Thesis/verslag 6.synctex.gz
Normal file
BIN
Reports/Thesis/verslag 6.synctex.gz
Normal file
Binary file not shown.
BIN
Reports/Thesis/verslag 7.synctex.gz
Normal file
BIN
Reports/Thesis/verslag 7.synctex.gz
Normal file
Binary file not shown.
BIN
Reports/Thesis/verslag 8.synctex.gz
Normal file
BIN
Reports/Thesis/verslag 8.synctex.gz
Normal file
Binary file not shown.
@@ -1,4 +1,4 @@
|
|||||||
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2023.9.17) 23 APR 2024 16:32
|
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2023.9.17) 24 APR 2024 21:49
|
||||||
entering extended mode
|
entering extended mode
|
||||||
restricted \write18 enabled.
|
restricted \write18 enabled.
|
||||||
file:line:error style messages enabled.
|
file:line:error style messages enabled.
|
||||||
@@ -1521,7 +1521,32 @@ Underfull \hbox (badness 10000) in paragraph at lines 491--511
|
|||||||
|
|
||||||
[]
|
[]
|
||||||
|
|
||||||
[25 <./images/quantile_regression/rnn/RNN_diagram.png>] [26] [27]) [28] (./verslag.aux (./sections/introduction.aux) (./sections/background.aux) (./sections/literature_study.aux))
|
[25 <./images/quantile_regression/rnn/RNN_diagram.png>] [26] [27]
|
||||||
|
Underfull \hbox (badness 10000) in paragraph at lines 565--573
|
||||||
|
|
||||||
|
[]
|
||||||
|
|
||||||
|
|
||||||
|
Underfull \hbox (badness 10000) in paragraph at lines 565--573
|
||||||
|
|
||||||
|
[]
|
||||||
|
|
||||||
|
|
||||||
|
Underfull \hbox (badness 10000) in paragraph at lines 565--573
|
||||||
|
|
||||||
|
[]
|
||||||
|
|
||||||
|
|
||||||
|
Underfull \hbox (badness 10000) in paragraph at lines 565--573
|
||||||
|
|
||||||
|
[]
|
||||||
|
|
||||||
|
|
||||||
|
Underfull \hbox (badness 10000) in paragraph at lines 565--573
|
||||||
|
|
||||||
|
[]
|
||||||
|
|
||||||
|
) [28] (./verslag.aux (./sections/introduction.aux) (./sections/background.aux) (./sections/literature_study.aux))
|
||||||
|
|
||||||
LaTeX Warning: There were undefined references.
|
LaTeX Warning: There were undefined references.
|
||||||
|
|
||||||
@@ -1539,13 +1564,13 @@ Package logreq Info: Writing requests to 'verslag.run.xml'.
|
|||||||
Here is how much of TeX's memory you used:
|
Here is how much of TeX's memory you used:
|
||||||
26750 strings out of 476025
|
26750 strings out of 476025
|
||||||
486953 string characters out of 5790017
|
486953 string characters out of 5790017
|
||||||
1877388 words of memory out of 5000000
|
1883388 words of memory out of 5000000
|
||||||
46684 multiletter control sequences out of 15000+600000
|
46684 multiletter control sequences out of 15000+600000
|
||||||
603223 words of font info for 88 fonts, out of 8000000 for 9000
|
603223 words of font info for 88 fonts, out of 8000000 for 9000
|
||||||
1141 hyphenation exceptions out of 8191
|
1141 hyphenation exceptions out of 8191
|
||||||
83i,16n,131p,1405b,5180s stack positions out of 10000i,1000n,20000p,200000b,200000s
|
83i,16n,131p,1405b,5180s stack positions out of 10000i,1000n,20000p,200000b,200000s
|
||||||
</Users/victormylle/Library/texlive/2023/texmf-var/fonts/pk/ljfour/public/bbm/bbm12.600pk></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertinust1math/LibertinusT1Math.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinBiolinumT.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinBiolinumTB.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinLibertineT.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinLibertineTB.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinLibertineTI.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/stix/stix-mathcal.pfb>
|
</Users/victormylle/Library/texlive/2023/texmf-var/fonts/pk/ljfour/public/bbm/bbm12.600pk></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertinust1math/LibertinusT1Math.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinBiolinumT.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinBiolinumTB.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinLibertineT.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinLibertineTB.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/libertine/LinLibertineTI.pfb></usr/local/texlive/2023/texmf-dist/fonts/type1/public/stix/stix-mathcal.pfb>
|
||||||
Output written on verslag.pdf (29 pages, 4067551 bytes).
|
Output written on verslag.pdf (29 pages, 4068911 bytes).
|
||||||
PDF statistics:
|
PDF statistics:
|
||||||
425 PDF objects out of 1000 (max. 8388607)
|
425 PDF objects out of 1000 (max. 8388607)
|
||||||
322 compressed objects within 4 object streams
|
322 compressed objects within 4 object streams
|
||||||
|
|||||||
Binary file not shown.
@@ -240,7 +240,7 @@ class DiffusionTrainer:
|
|||||||
self.model = torch.load("checkpoint.pt")
|
self.model = torch.load("checkpoint.pt")
|
||||||
self.model.to(self.device)
|
self.model.to(self.device)
|
||||||
|
|
||||||
_, generated_sampels = self.test(test_loader, None, task)
|
_, generated_sampels = self.test(test_loader, -1, task)
|
||||||
# self.policy_evaluator.plot_profits_table()
|
# self.policy_evaluator.plot_profits_table()
|
||||||
|
|
||||||
optimal_penalty, profit, charge_cycles = (
|
optimal_penalty, profit, charge_cycles = (
|
||||||
@@ -392,6 +392,9 @@ class DiffusionTrainer:
|
|||||||
self, data_loader: torch.utils.data.DataLoader, epoch: int, task: Task = None
|
self, data_loader: torch.utils.data.DataLoader, epoch: int, task: Task = None
|
||||||
):
|
):
|
||||||
all_crps = []
|
all_crps = []
|
||||||
|
all_inversed_crps = []
|
||||||
|
all_inversed_mae = []
|
||||||
|
all_inversed_mse = []
|
||||||
generated_samples = {}
|
generated_samples = {}
|
||||||
for inputs, targets, idx_batch in data_loader:
|
for inputs, targets, idx_batch in data_loader:
|
||||||
inputs, targets = inputs.to(self.device), targets.to(self.device)
|
inputs, targets = inputs.to(self.device), targets.to(self.device)
|
||||||
@@ -413,12 +416,58 @@ class DiffusionTrainer:
|
|||||||
crps = crps_from_samples(samples_batched, targets)
|
crps = crps_from_samples(samples_batched, targets)
|
||||||
crps_mean = crps.mean(axis=1)
|
crps_mean = crps.mean(axis=1)
|
||||||
|
|
||||||
|
if epoch == -1:
|
||||||
|
inversed_samples_batched = self.data_processor.inverse_transform(
|
||||||
|
samples_batched
|
||||||
|
)
|
||||||
|
inversed_targets = self.data_processor.inverse_transform(targets)
|
||||||
|
|
||||||
|
inversed_crps = crps_from_samples(
|
||||||
|
inversed_samples_batched, inversed_targets
|
||||||
|
)
|
||||||
|
inversed_crps_mean = inversed_crps.mean(axis=1)
|
||||||
|
all_inversed_crps.extend(inversed_crps_mean.tolist())
|
||||||
|
|
||||||
|
inversed_expanded_targets = inversed_targets.unsqueeze(1).expand(
|
||||||
|
-1, number_of_samples, -1
|
||||||
|
)
|
||||||
|
|
||||||
|
inversed_mae = np.abs(
|
||||||
|
inversed_samples_batched - inversed_expanded_targets
|
||||||
|
)
|
||||||
|
inversed_mae_mean = inversed_mae.mean()
|
||||||
|
all_inversed_mae.extend(inversed_mae_mean.tolist())
|
||||||
|
|
||||||
|
inversed_mse = np.square(
|
||||||
|
inversed_samples_batched - inversed_expanded_targets
|
||||||
|
)
|
||||||
|
inversed_mse_mean = inversed_mse.mean()
|
||||||
|
all_inversed_mse.extend(inversed_mse_mean.tolist())
|
||||||
|
|
||||||
# add all values from crps_mean to all_crps
|
# add all values from crps_mean to all_crps
|
||||||
all_crps.extend(crps_mean.tolist())
|
all_crps.extend(crps_mean.tolist())
|
||||||
|
|
||||||
all_crps = np.array(all_crps)
|
all_crps = np.array(all_crps)
|
||||||
mean_crps = all_crps.mean()
|
mean_crps = all_crps.mean()
|
||||||
|
|
||||||
|
if epoch == -1:
|
||||||
|
all_inversed_crps = np.array(all_inversed_crps)
|
||||||
|
mean_inversed_crps = all_inversed_crps.mean()
|
||||||
|
|
||||||
|
task.get_logger().report_single_value(
|
||||||
|
name="test_CRPSLoss", value=mean_inversed_crps
|
||||||
|
)
|
||||||
|
|
||||||
|
mean_inversed_mae = np.array(all_inversed_mae).mean()
|
||||||
|
task.get_logger().report_single_value(
|
||||||
|
name="test_MSELoss", value=mean_inversed_mae
|
||||||
|
)
|
||||||
|
|
||||||
|
mean_inversed_mse = np.array(all_inversed_mse).mean()
|
||||||
|
task.get_logger().report_single_value(
|
||||||
|
name="test_L1Loss", value=mean_inversed_mse
|
||||||
|
)
|
||||||
|
|
||||||
if self.best_score is None or mean_crps < self.best_score:
|
if self.best_score is None or mean_crps < self.best_score:
|
||||||
self.save_checkpoint(mean_crps, task, epoch)
|
self.save_checkpoint(mean_crps, task, epoch)
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ clearml_helper = ClearMLHelper(project_name="Thesis/NrvForecast")
|
|||||||
task = clearml_helper.get_task(
|
task = clearml_helper.get_task(
|
||||||
task_name="AQR: GRU (8 - 512) + Load + PV + Wind + NP + QE (dim 5)"
|
task_name="AQR: GRU (8 - 512) + Load + PV + Wind + NP + QE (dim 5)"
|
||||||
)
|
)
|
||||||
task.execute_remotely(queue_name="default", exit_process=True)
|
# task.execute_remotely(queue_name="default", exit_process=True)
|
||||||
|
|
||||||
from src.policies.PolicyEvaluator import PolicyEvaluator
|
from src.policies.PolicyEvaluator import PolicyEvaluator
|
||||||
from src.policies.simple_baseline import BaselinePolicy, Battery
|
from src.policies.simple_baseline import BaselinePolicy, Battery
|
||||||
@@ -24,7 +24,6 @@ from torch.nn import MSELoss, L1Loss
|
|||||||
import torch.nn as nn
|
import torch.nn as nn
|
||||||
from src.models.time_embedding_layer import TimeEmbedding, TrigonometricTimeEmbedding
|
from src.models.time_embedding_layer import TimeEmbedding, TrigonometricTimeEmbedding
|
||||||
|
|
||||||
|
|
||||||
#### Data Processor ####
|
#### Data Processor ####
|
||||||
data_config = DataConfig()
|
data_config = DataConfig()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user