Added GRU results to thesis + intermediate samples of diffusion model

This commit is contained in:
Victor Mylle
2024-05-06 23:28:42 +00:00
parent d7f4c1849b
commit d9b6f34e97
25 changed files with 353 additions and 161 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 215 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 196 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 185 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

View File

@@ -48,20 +48,13 @@ A lot of data is available but only the most relevant data needs to be used. Exp
\input{sections/results/gru}
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
\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.
\\\\
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. It combines the parallel sample generation of the non-autoregressive models while the quarter NRV values still depend on each other. 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.

View File

@@ -41,27 +41,96 @@ NRV & & & & & & & & \\
& 8 & 512 & 37681.71 & 40379.14 & 146.62 & 151.05 & 83.08 & 76.42 \\
\midrule
NRV + Load & & & & & & & & & \\
& 2 & 256 & 33202.80 & 38427.91 & 138.02 & 147.27 & 79.62 & 84.17 \\
& 4 & 256 & 33600.73 & 38984.44 & 138.62 & 147.91 & 81.03 & 85.91 \\
& 8 & 256 & 32828.61 & 38343.98 & 136.82 & 146.44 & 79.42 & 84.22 \\
& 2 & 512 & 35979.57 & 41496.77 & 144.16 & 153.53 & 83.50 & 88.26 \\
& 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 \\
& 2 & 256 & 38427.91 & 40024.14 & 147.27 & 150.06 & 84.17 & 76.04 \\
& 4 & 256 & 38984.44 & 40480.73 & 147.91 & 151.24 & 85.91 & 75.82 \\
& 8 & 256 & 38343.98 & 39135.60 & 146.44 & 148.85 & 84.22 & 76.19 \\
& 2 & 512 & 41496.77 & 40808.04 & 153.53 & 151.89 & 88.26 & 75.43 \\
& 4 & 512 & 38000.40 & 40260.01 & 146.10 & 150.57 & 83.99 & 75.38 \\
& 8 & 512 & 41104.28 & 39907.44 & 152.13 & 150.11 & 89.13 & 76.42 \\
\midrule
NRV + Load + PV\\ + Wind & & & & & & & & & \\
& 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 \\
& 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 \\
& 4 & 256 & 39872.46 & 40708.93 & 149.34 & 151.32 & 85.91 & 75.93 \\
& 8 & 256 & 39704.37 & 40292.25 & 148.59 & 151.19 & 85.62 & 75.94 \\
& 4 & 512 & 39024.27 & 41580.29 & 147.91 & 153.39 & 84.18 & 75.84 \\
& 8 & 512 & 42397.86 & 41043.88 & 154.00 & 152.63 & 89.87 & 76.35 \\
\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 \\
& 4 & 256 & 39906.53 & 40881.92 & 149.78 & 152.34 & 84.88 & 76.15 \\
& 8 & 256 & 37675.15 & 40159.91 & 145.39 & 150.42 & 83.37 & 75.89 \\
& 4 & 512 & & 40613.54 & & 151.17 & & 75.33 \\
& 8 & 512 & 35238.98 & 39896.57 & 141.02 & 149.96 & 80.92 & 75.92 \\
\bottomrule
\end{tabular}
\end{adjustbox}
\caption{Autoregressive GRU quantile regression model results. All the models used a dropout of 0.2 .}
\label{tab:autoregressive_gru_model_results}
\end{table}
The results show the same behavior for the GRU model as for the linear and non-linear models. The performance of the autoregressive model increases a bit when more features are added. The performance of the non-autoregressive model does not increase that much when adding new features. The reason for this is the same as for the linear and non-linear models. There is a large input size for the non-autoregressive model, which makes it harder to learn the dependencies between the features. The non-autoregressive model has to predict 96 quarters, which is a complex task. When comparing the results of the autoregressive GRU model and the non-autoregressive GRU model, the same observation can be made for the linear and non-linear models. The CRPS is always lower for the non-autoregressive model while the MSE and MAE are higher most of the time.
% TODO: explain from which models the examples come from
\begin{figure}[H]
\centering
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png}
\end{subfigure}
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png}
\end{subfigure}
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png}
\end{subfigure}
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png}
\caption{Autoregressive GRU model}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png}
\caption{Non-autoregressive GRU model}
\end{subfigure}
\caption{Comparison of the autoregressive and non-autoregressive GRU model examples.}
\label{fig:gru_model_sample_comparison}
\end{figure}
The examples from the test set using the GRU models are shown in Figure \ref{fig:gru_model_sample_comparison}. Again the same behavior can be observed for the linear and non-linear models. The non-autoregressive examples stay around zero and do not follow the trend of the real NRV values. The autoregressive examples look a lot better visually and follow the trend of the real NRV values much more.
\begin{figure}[ht]
\centering
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/quantile_performance/AQR_GRU_QP_Train.jpeg}
\caption{AR - Train}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/quantile_performance/AQR_GRU_QP_Test.jpeg}
\caption{AR - Test}
\end{subfigure}
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/quantile_performance/NAQR_GRU_QP_Train.jpeg}
\caption{NAR - Train}
\end{subfigure}
\hfill
\begin{subfigure}[b]{0.49\textwidth}
\includegraphics[width=\textwidth]{images/quantile_regression/quantile_performance/NAQR_GRU_QP_Test.jpeg}
\caption{NAR - Test}
\end{subfigure}
\caption{Over/underestimation of the quantiles for the autoregressive and non-autoregressive GRU models. Both the quantile performance for the training and test set are shown. The plots are generated using the input features NRV, Load, Wind, PV, Net Position, and the quarter embedding (only for the autoregressive model).}
\label{fig:gru_model_quantile_over_underestimation}
\end{figure}
The plots in Figure \ref{fig:gru_model_quantile_over_underestimation} show the over/underestimation of the learned quantiles for the GRU models. The fraction of real NRV values under the predicted quantiles of the training set is very close to the ideal fraction. The autoregressive model, however, shows a slight underestimation for almost all quantiles. Looking at the test set, the lower quantiles are overestimated for the autoregressive model while the higher quantiles are underestimated. The quantile predictions of the test set for the non-autoregressive model are all underestimated. This means a lower fraction of real NRV values is below the quantiles than wanted.

View File

@@ -75,18 +75,22 @@
\newlabel{tab:gru_model_architecture}{{7}{33}{GRU Model Architecture\relax }{table.caption.19}{}}
\@writefile{lot}{\contentsline {table}{\numberline {8}{\ignorespaces Autoregressive GRU quantile regression model results. All the models used a dropout of 0.2 .\relax }}{34}{table.caption.20}\protected@file@percent }
\newlabel{tab:autoregressive_gru_model_results}{{8}{34}{Autoregressive GRU quantile regression model results. All the models used a dropout of 0.2 .\relax }{table.caption.20}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {6.3}Diffusion}{35}{subsection.6.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {7}Policies for battery optimization}{35}{section.7}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {7.1}Baselines}{35}{subsection.7.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {7.2}Policies using NRV predictions}{35}{subsection.7.2}\protected@file@percent }
\abx@aux@page{6}{36}
\abx@aux@page{7}{36}
\abx@aux@page{8}{36}
\abx@aux@page{9}{36}
\@writefile{lof}{\contentsline {figure}{\numberline {12}{\ignorespaces Comparison of the autoregressive and non-autoregressive GRU model examples.\relax }}{35}{figure.caption.21}\protected@file@percent }
\newlabel{fig:gru_model_sample_comparison}{{12}{35}{Comparison of the autoregressive and non-autoregressive GRU model examples.\relax }{figure.caption.21}{}}
\@writefile{lof}{\contentsline {figure}{\numberline {13}{\ignorespaces Over/underestimation of the quantiles for the autoregressive and non-autoregressive GRU models. Both the quantile performance for the training and test set are shown. The plots are generated using the input features NRV, Load, Wind, PV, Net Position, and the quarter embedding (only for the autoregressive model).\relax }}{36}{figure.caption.22}\protected@file@percent }
\newlabel{fig:gru_model_quantile_over_underestimation}{{13}{36}{Over/underestimation of the quantiles for the autoregressive and non-autoregressive GRU models. Both the quantile performance for the training and test set are shown. The plots are generated using the input features NRV, Load, Wind, PV, Net Position, and the quarter embedding (only for the autoregressive model).\relax }{figure.caption.22}{}}
\@writefile{toc}{\contentsline {subsection}{\numberline {6.3}Diffusion}{37}{subsection.6.3}\protected@file@percent }
\@writefile{toc}{\contentsline {section}{\numberline {7}Policies for battery optimization}{37}{section.7}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {7.1}Baselines}{37}{subsection.7.1}\protected@file@percent }
\@writefile{toc}{\contentsline {subsection}{\numberline {7.2}Policies using NRV predictions}{37}{subsection.7.2}\protected@file@percent }
\abx@aux@page{6}{38}
\abx@aux@page{7}{38}
\abx@aux@page{8}{38}
\abx@aux@page{9}{38}
\abx@aux@read@bbl@mdfivesum{5DC935CC8C8FAB8A3CAF97A486ED2386}
\abx@aux@read@bblrerun
\abx@aux@defaultrefcontext{0}{dumas_deep_2022}{nyt/global//global/global}
\abx@aux@defaultrefcontext{0}{lu_scenarios_2022}{nyt/global//global/global}
\abx@aux@defaultrefcontext{0}{poggi_electricity_2023}{nyt/global//global/global}
\abx@aux@defaultrefcontext{0}{weron_electricity_2014}{nyt/global//global/global}
\gdef \@abspage@last{37}
\gdef \@abspage@last{39}

View File

@@ -1,4 +1,4 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2023.9.17) 6 MAY 2024 16:04
This is pdfTeX, Version 3.141592653-2.6-1.40.25 (TeX Live 2023) (preloaded format=pdflatex 2023.9.17) 7 MAY 2024 00:43
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
@@ -1407,32 +1407,74 @@ Underfull \hbox (badness 4582) in paragraph at lines 135--135
[]\T1/LinuxLibertineT-TLF/m/n/12 Figure 11: |Over/underestimation of the quan-tiles for the au-tore-gres-sive and non-
[]
) [31 <./images/quantile_regression/aqr_non_linear_model_samples/AQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_864.png> <./images/quantile_regression/naqr_non_linear_model_samples/NAQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_864.png> <./images/quantile_regression/aqr_non_linear_model_samples/AQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_4320.png> <./images/quantile_regression/naqr_non_linear_model_samples/NAQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_4320.png> <./images/quantile_regression/aqr_non_linear_model_samples/AQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_6336.png> <./images/quantile_regression/naqr_non_linear_model_samples/NAQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_6336.png> <./images/quantile_regression/aqr_non_linear_model_samples/AQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_7008.png> <./images/quantile_regression/naqr_non_linear_model_samples/NAQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_7008.png>] (./sections/results/gru.tex [32 <./images/quantile_regression/quantile_performance/AQR_NL_Quantile_Performance_Training.jpeg> <./images/quantile_regression/quantile_performance/AQR_NL_Quantile_Performance_Test.jpeg> <./images/quantile_regression/quantile_performance/NAQR_NL_Quantile_Performance_Training.jpeg> <./images/quantile_regression/quantile_performance/NAQR_NL_Quantile_Performance_Test.jpeg>]) [33] [34]
Underfull \hbox (badness 10000) in paragraph at lines 59--67
) [31 <./images/quantile_regression/aqr_non_linear_model_samples/AQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_864.png> <./images/quantile_regression/naqr_non_linear_model_samples/NAQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_864.png> <./images/quantile_regression/aqr_non_linear_model_samples/AQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_4320.png> <./images/quantile_regression/naqr_non_linear_model_samples/NAQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_4320.png> <./images/quantile_regression/aqr_non_linear_model_samples/AQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_6336.png> <./images/quantile_regression/naqr_non_linear_model_samples/NAQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_6336.png> <./images/quantile_regression/aqr_non_linear_model_samples/AQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_7008.png> <./images/quantile_regression/naqr_non_linear_model_samples/NAQR_NL_NRV_Load_Wind_PV_NP_QE-Sample_7008.png>] (./sections/results/gru.tex [32 <./images/quantile_regression/quantile_performance/AQR_NL_Quantile_Performance_Training.jpeg> <./images/quantile_regression/quantile_performance/AQR_NL_Quantile_Performance_Test.jpeg> <./images/quantile_regression/quantile_performance/NAQR_NL_Quantile_Performance_Training.jpeg> <./images/quantile_regression/quantile_performance/NAQR_NL_Quantile_Performance_Test.jpeg>] [33]
<images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png, id=437, 1180.8918pt x 595.5048pt>
File: images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png Graphic file (type png)
<use images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png>
Package pdftex.def Info: images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png used on input line 75.
(pdftex.def) Requested size: 223.07211pt x 112.49284pt.
<images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png, id=438, 1180.8918pt x 595.5048pt>
File: images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png Graphic file (type png)
<use images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png>
Package pdftex.def Info: images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png used on input line 79.
(pdftex.def) Requested size: 223.07211pt x 112.49284pt.
<images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png, id=439, 1180.8918pt x 595.5048pt>
File: images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png Graphic file (type png)
<use images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png>
Package pdftex.def Info: images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png used on input line 82.
(pdftex.def) Requested size: 223.07211pt x 112.49284pt.
<images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png, id=440, 1180.8918pt x 595.5048pt>
File: images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png Graphic file (type png)
<use images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png>
Package pdftex.def Info: images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png used on input line 86.
(pdftex.def) Requested size: 223.07211pt x 112.49284pt.
<images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png, id=441, 1180.8918pt x 595.5048pt>
File: images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png Graphic file (type png)
<use images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png>
Package pdftex.def Info: images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png used on input line 89.
(pdftex.def) Requested size: 223.07211pt x 112.49284pt.
<images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png, id=442, 1180.8918pt x 595.5048pt>
File: images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png Graphic file (type png)
<use images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png>
Package pdftex.def Info: images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png used on input line 93.
(pdftex.def) Requested size: 223.07211pt x 112.49284pt.
<images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png, id=443, 1180.8918pt x 595.5048pt>
File: images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png Graphic file (type png)
<use images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png>
Package pdftex.def Info: images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png used on input line 96.
(pdftex.def) Requested size: 223.07211pt x 112.49284pt.
<images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png, id=444, 1180.8918pt x 595.5048pt>
File: images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png Graphic file (type png)
<use images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png>
Package pdftex.def Info: images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png used on input line 101.
(pdftex.def) Requested size: 223.07211pt x 112.49284pt.
[34]
<images/quantile_regression/quantile_performance/AQR_GRU_QP_Train.jpeg, id=450, 883.8621pt x 609.9588pt>
File: images/quantile_regression/quantile_performance/AQR_GRU_QP_Train.jpeg Graphic file (type jpg)
<use images/quantile_regression/quantile_performance/AQR_GRU_QP_Train.jpeg>
Package pdftex.def Info: images/quantile_regression/quantile_performance/AQR_GRU_QP_Train.jpeg used on input line 114.
(pdftex.def) Requested size: 223.07211pt x 153.94125pt.
<images/quantile_regression/quantile_performance/AQR_GRU_QP_Test.jpeg, id=451, 883.8621pt x 609.9588pt>
File: images/quantile_regression/quantile_performance/AQR_GRU_QP_Test.jpeg Graphic file (type jpg)
<use images/quantile_regression/quantile_performance/AQR_GRU_QP_Test.jpeg>
Package pdftex.def Info: images/quantile_regression/quantile_performance/AQR_GRU_QP_Test.jpeg used on input line 119.
(pdftex.def) Requested size: 223.07211pt x 153.94125pt.
<images/quantile_regression/quantile_performance/NAQR_GRU_QP_Train.jpeg, id=452, 883.8621pt x 609.9588pt>
File: images/quantile_regression/quantile_performance/NAQR_GRU_QP_Train.jpeg Graphic file (type jpg)
<use images/quantile_regression/quantile_performance/NAQR_GRU_QP_Train.jpeg>
Package pdftex.def Info: images/quantile_regression/quantile_performance/NAQR_GRU_QP_Train.jpeg used on input line 124.
(pdftex.def) Requested size: 223.07211pt x 153.94125pt.
<images/quantile_regression/quantile_performance/NAQR_GRU_QP_Test.jpeg, id=453, 883.8621pt x 609.9588pt>
File: images/quantile_regression/quantile_performance/NAQR_GRU_QP_Test.jpeg Graphic file (type jpg)
<use images/quantile_regression/quantile_performance/NAQR_GRU_QP_Test.jpeg>
Package pdftex.def Info: images/quantile_regression/quantile_performance/NAQR_GRU_QP_Test.jpeg used on input line 129.
(pdftex.def) Requested size: 223.07211pt x 153.94125pt.
Underfull \hbox (badness 4582) in paragraph at lines 132--132
[]\T1/LinuxLibertineT-TLF/m/n/12 Figure 13: |Over/underestimation of the quan-tiles for the au-tore-gres-sive and non-
[]
Underfull \hbox (badness 10000) in paragraph at lines 59--67
[]
Underfull \hbox (badness 10000) in paragraph at lines 59--67
[]
Underfull \hbox (badness 10000) in paragraph at lines 59--67
[]
Underfull \hbox (badness 10000) in paragraph at lines 59--67
[]
) [35] [36] (./verslag.aux (./sections/introduction.aux) (./sections/background.aux) (./sections/policies.aux) (./sections/literature_study.aux))
) [35 <./images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png> <./images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_864.png> <./images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png> <./images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_4320.png> <./images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png> <./images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_6336.png> <./images/quantile_regression/aqr_gru_model_examples/AQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png> <./images/quantile_regression/naqr_gru_model_examples/NAQR_GRU_NRV_Load_Wind_PV_NP_QE-Sample_7008.png>] [36 <./images/quantile_regression/quantile_performance/AQR_GRU_QP_Train.jpeg> <./images/quantile_regression/quantile_performance/AQR_GRU_QP_Test.jpeg> <./images/quantile_regression/quantile_performance/NAQR_GRU_QP_Train.jpeg> <./images/quantile_regression/quantile_performance/NAQR_GRU_QP_Test.jpeg>]) [37] [38] (./verslag.aux (./sections/introduction.aux) (./sections/background.aux) (./sections/policies.aux) (./sections/literature_study.aux))
LaTeX Warning: There were undefined references.
@@ -1448,18 +1490,18 @@ Package logreq Info: Writing requests to 'verslag.run.xml'.
)
Here is how much of TeX's memory you used:
26989 strings out of 476025
498139 string characters out of 5790017
27081 strings out of 476025
505488 string characters out of 5790017
1883388 words of memory out of 5000000
46866 multiletter control sequences out of 15000+600000
46940 multiletter control sequences out of 15000+600000
603223 words of font info for 88 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
83i,16n,131p,2100b,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>
Output written on verslag.pdf (37 pages, 6373408 bytes).
Output written on verslag.pdf (39 pages, 7863303 bytes).
PDF statistics:
542 PDF objects out of 1000 (max. 8388607)
412 compressed objects within 5 object streams
99 named destinations out of 1000 (max. 500000)
426 words of extra memory for PDF output out of 10000 (max. 10000000)
575 PDF objects out of 1000 (max. 8388607)
423 compressed objects within 5 object streams
103 named destinations out of 1000 (max. 500000)
486 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file not shown.

Binary file not shown.

View File

@@ -25,7 +25,7 @@
\contentsline {subsubsection}{\numberline {6.2.1}Linear Model}{22}{subsubsection.6.2.1}%
\contentsline {subsubsection}{\numberline {6.2.2}Non-Linear Model}{29}{subsubsection.6.2.2}%
\contentsline {subsubsection}{\numberline {6.2.3}GRU Model}{32}{subsubsection.6.2.3}%
\contentsline {subsection}{\numberline {6.3}Diffusion}{35}{subsection.6.3}%
\contentsline {section}{\numberline {7}Policies for battery optimization}{35}{section.7}%
\contentsline {subsection}{\numberline {7.1}Baselines}{35}{subsection.7.1}%
\contentsline {subsection}{\numberline {7.2}Policies using NRV predictions}{35}{subsection.7.2}%
\contentsline {subsection}{\numberline {6.3}Diffusion}{37}{subsection.6.3}%
\contentsline {section}{\numberline {7}Policies for battery optimization}{37}{section.7}%
\contentsline {subsection}{\numberline {7.1}Baselines}{37}{subsection.7.1}%
\contentsline {subsection}{\numberline {7.2}Policies using NRV predictions}{37}{subsection.7.2}%

View File

@@ -22,6 +22,7 @@ def sample_diffusion(
beta_start=1e-4,
beta_end=0.02,
ts_length=96,
intermediate_samples: bool = False,
):
device = next(model.parameters()).device
beta = torch.linspace(beta_start, beta_end, noise_steps).to(device)
@@ -34,6 +35,7 @@ def sample_diffusion(
inputs = inputs.repeat(n, 1, 1)
model.eval()
intermediate_samples_list = []
with torch.no_grad():
x = torch.randn(inputs.shape[0], ts_length).to(device)
for i in reversed(range(1, noise_steps)):
@@ -54,7 +56,17 @@ def sample_diffusion(
* (x - ((1 - _alpha) / (torch.sqrt(1 - _alpha_hat))) * predicted_noise)
+ torch.sqrt(_beta) * noise
)
# evenly spaces 4 intermediate samples to append between 1 and noise_steps
if intermediate_samples:
spacing = (noise_steps - 1) // 4
if i % spacing == 0:
intermediate_samples_list.append(x)
x = torch.clamp(x, -1.0, 1.0)
if len(intermediate_samples_list) > 0:
return x, intermediate_samples_list
return x
@@ -105,7 +117,13 @@ class DiffusionTrainer:
"""
return torch.randint(low=1, high=self.noise_steps, size=(n,))
def sample(self, model: DiffusionModel, n: int, inputs: torch.tensor):
def sample(
self,
model: DiffusionModel,
n: int,
inputs: torch.tensor,
intermediate_samples=False,
):
x = sample_diffusion(
model,
n,
@@ -114,7 +132,9 @@ class DiffusionTrainer:
self.beta_start,
self.beta_end,
self.ts_length,
intermediate_samples,
)
model.train()
return x
@@ -271,6 +291,87 @@ class DiffusionTrainer:
if task:
task.close()
def plot_from_samples(self, samples, target):
ci_99_upper = np.quantile(samples, 0.995, axis=0)
ci_99_lower = np.quantile(samples, 0.005, axis=0)
ci_95_upper = np.quantile(samples, 0.975, axis=0)
ci_95_lower = np.quantile(samples, 0.025, axis=0)
ci_90_upper = np.quantile(samples, 0.95, axis=0)
ci_90_lower = np.quantile(samples, 0.05, axis=0)
ci_50_lower = np.quantile(samples, 0.25, axis=0)
ci_50_upper = np.quantile(samples, 0.75, axis=0)
sns.set_theme()
time_steps = np.arange(0, 96)
fig, ax = plt.subplots(figsize=(20, 10))
ax.plot(
time_steps,
samples.mean(axis=0),
label="Mean of NRV samples",
linewidth=3,
)
# ax.fill_between(time_steps, ci_lower, ci_upper, color='b', alpha=0.2, label='Full Interval')
ax.fill_between(
time_steps,
ci_99_lower,
ci_99_upper,
color="b",
alpha=0.2,
label="99% Interval",
)
ax.fill_between(
time_steps,
ci_95_lower,
ci_95_upper,
color="b",
alpha=0.2,
label="95% Interval",
)
ax.fill_between(
time_steps,
ci_90_lower,
ci_90_upper,
color="b",
alpha=0.2,
label="90% Interval",
)
ax.fill_between(
time_steps,
ci_50_lower,
ci_50_upper,
color="b",
alpha=0.2,
label="50% Interval",
)
ax.plot(target, label="Real NRV", linewidth=3)
# full_interval_patch = mpatches.Patch(color='b', alpha=0.2, label='Full Interval')
ci_99_patch = mpatches.Patch(color="b", alpha=0.3, label="99% Interval")
ci_95_patch = mpatches.Patch(color="b", alpha=0.4, label="95% Interval")
ci_90_patch = mpatches.Patch(color="b", alpha=0.5, label="90% Interval")
ci_50_patch = mpatches.Patch(color="b", alpha=0.6, label="50% Interval")
ax.legend(
handles=[
ci_99_patch,
ci_95_patch,
ci_90_patch,
ci_50_patch,
ax.lines[0],
ax.lines[1],
]
)
ax.set_ylim([-1500, 1500])
return fig
def debug_plots(self, task, training: bool, data_loader, sample_indices, epoch):
for actual_idx, idx in sample_indices.items():
features, target, _ = data_loader.dataset[idx]
@@ -280,86 +381,69 @@ class DiffusionTrainer:
self.model.eval()
with torch.no_grad():
samples = self.sample(self.model, 100, features).cpu().numpy()
samples, intermediates = (
self.sample(self.model, 100, features, True)
)
samples = samples.cpu().numpy()
samples = self.data_processor.inverse_transform(samples)
target = self.data_processor.inverse_transform(target)
ci_99_upper = np.quantile(samples, 0.995, axis=0)
ci_99_lower = np.quantile(samples, 0.005, axis=0)
# list to tensor intermediate samples
intermediates = torch.stack(intermediates)
ci_95_upper = np.quantile(samples, 0.975, axis=0)
ci_95_lower = np.quantile(samples, 0.025, axis=0)
ci_90_upper = np.quantile(samples, 0.95, axis=0)
ci_90_lower = np.quantile(samples, 0.05, axis=0)
ci_50_lower = np.quantile(samples, 0.25, axis=0)
ci_50_upper = np.quantile(samples, 0.75, axis=0)
sns.set_theme()
time_steps = np.arange(0, 96)
fig, ax = plt.subplots(figsize=(20, 10))
ax.plot(
time_steps,
samples.mean(axis=0),
label="Mean of NRV samples",
linewidth=3,
)
# ax.fill_between(time_steps, ci_lower, ci_upper, color='b', alpha=0.2, label='Full Interval')
ax.fill_between(
time_steps,
ci_99_lower,
ci_99_upper,
color="b",
alpha=0.2,
label="99% Interval",
)
ax.fill_between(
time_steps,
ci_95_lower,
ci_95_upper,
color="b",
alpha=0.2,
label="95% Interval",
)
ax.fill_between(
time_steps,
ci_90_lower,
ci_90_upper,
color="b",
alpha=0.2,
label="90% Interval",
)
ax.fill_between(
time_steps,
ci_50_lower,
ci_50_upper,
color="b",
alpha=0.2,
label="50% Interval",
fig = self.plot_from_samples(samples, target)
intermediate_fig1 = self.plot_from_samples(
self.data_processor.inverse_transform(intermediates[0].cpu().numpy()), target
)
ax.plot(target, label="Real NRV", linewidth=3)
# full_interval_patch = mpatches.Patch(color='b', alpha=0.2, label='Full Interval')
ci_99_patch = mpatches.Patch(color="b", alpha=0.3, label="99% Interval")
ci_95_patch = mpatches.Patch(color="b", alpha=0.4, label="95% Interval")
ci_90_patch = mpatches.Patch(color="b", alpha=0.5, label="90% Interval")
ci_50_patch = mpatches.Patch(color="b", alpha=0.6, label="50% Interval")
ax.legend(
handles=[
ci_99_patch,
ci_95_patch,
ci_90_patch,
ci_50_patch,
ax.lines[0],
ax.lines[1],
]
intermediate_fig2 = self.plot_from_samples(
self.data_processor.inverse_transform(intermediates[1].cpu().numpy()), target
)
ax.set_ylim([-1500, 1500])
intermediate_fig3 = self.plot_from_samples(
self.data_processor.inverse_transform(intermediates[2].cpu().numpy()), target
)
intermediate_fig4 = self.plot_from_samples(
self.data_processor.inverse_transform(intermediates[3].cpu().numpy()), target
)
# report the intermediate figs to clearml
task.get_logger().report_matplotlib_figure(
title=f"Training Intermediates {actual_idx}" if training else f"Testing Intermediates {actual_idx}",
series=f"Sample intermediate 1",
iteration=epoch,
figure=intermediate_fig1,
report_image=True
)
task.get_logger().report_matplotlib_figure(
title=f"Training Intermediates {actual_idx}" if training else f"Testing Intermediates {actual_idx}",
series=f"Sample intermediate 2",
iteration=epoch,
figure=intermediate_fig2,
report_image=True
)
task.get_logger().report_matplotlib_figure(
title=f"Training Intermediates {actual_idx}" if training else f"Testing Intermediates {actual_idx}",
series=f"Sample intermediate 3",
iteration=epoch,
figure=intermediate_fig3,
report_image=True
)
task.get_logger().report_matplotlib_figure(
title=f"Training Intermediates {actual_idx}" if training else f"Testing Intermediates {actual_idx}",
series=f"Sample intermediate 4",
iteration=epoch,
figure=intermediate_fig4,
report_image=True
)
task.get_logger().report_matplotlib_figure(
title="Training" if training else "Testing",

View File

@@ -2,7 +2,7 @@ from src.utils.clearml import ClearMLHelper
clearml_helper = ClearMLHelper(project_name="Thesis/NrvForecast")
task = clearml_helper.get_task(
task_name="Diffusion Training: hidden_sizes=[1024, 1024, 1024], lr=0.0001, time_dim=8 + Load + PV + Wind + NP"
task_name="Diffusion Training: hidden_sizes=[256, 256, 256], lr=0.0001, time_dim=8"
)
task.execute_remotely(queue_name="default", exit_process=True)
@@ -19,19 +19,19 @@ from src.policies.PolicyEvaluator import PolicyEvaluator
data_config = DataConfig()
data_config.NRV_HISTORY = True
data_config.LOAD_HISTORY = True
data_config.LOAD_FORECAST = True
data_config.LOAD_HISTORY = False
data_config.LOAD_FORECAST = False
data_config.PV_FORECAST = True
data_config.PV_HISTORY = True
data_config.PV_FORECAST = False
data_config.PV_HISTORY = False
data_config.WIND_FORECAST = True
data_config.WIND_HISTORY = True
data_config.WIND_FORECAST = False
data_config.WIND_HISTORY = False
data_config.QUARTER = True
data_config.DAY_OF_WEEK = True
data_config.QUARTER = False
data_config.DAY_OF_WEEK = False
data_config.NOMINAL_NET_POSITION = True
data_config.NOMINAL_NET_POSITION = False
data_config = task.connect(data_config, name="data_features")
@@ -45,7 +45,7 @@ print("Input dim: ", inputDim)
model_parameters = {
"epochs": 15000,
"learning_rate": 0.0001,
"hidden_sizes": [1024, 1024, 1024],
"hidden_sizes": [256, 256, 256],
"time_dim": 8,
}

View File

@@ -2,7 +2,7 @@ from src.utils.clearml import ClearMLHelper
#### ClearML ####
clearml_helper = ClearMLHelper(project_name="Thesis/NAQR: GRU")
task = clearml_helper.get_task(task_name="NAQR: GRU (2 - 256) + Load")
task = clearml_helper.get_task(task_name="NAQR: GRU (8 - 512) + Load + PV + Wind + NP")
task.execute_remotely(queue_name="default", exit_process=True)
from src.policies.PolicyEvaluator import PolicyEvaluator
@@ -30,13 +30,13 @@ data_config.NRV_HISTORY = True
data_config.LOAD_HISTORY = True
data_config.LOAD_FORECAST = True
data_config.WIND_FORECAST = False
data_config.WIND_HISTORY = False
data_config.WIND_FORECAST = True
data_config.WIND_HISTORY = True
data_config.PV_FORECAST = False
data_config.PV_HISTORY = False
data_config.PV_FORECAST = True
data_config.PV_HISTORY = True
data_config.NOMINAL_NET_POSITION = False
data_config.NOMINAL_NET_POSITION = True
data_config = task.connect(data_config, name="data_features")