patwa67 / CNNGWP

2 stars 0 forks source link

Error in GP_deviance: Infinite values of the Deviance Function #1

Closed amizeranschi closed 4 years ago

amizeranschi commented 4 years ago

Hello,

I am attempting to reproduce the simulated data example from https://doi.org/10.3389/fgene.2020.00025 using the script from this repository. However, I'm running into an error:

[...]
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
Quitting from lines 3-130 (CNNGWPBOQTLMAS2010.spin.Rmd)
Error in GP_deviance(beta = row, X = X, Y = Y, nug_thres = nug_thres,  :
  Infinite values of the Deviance Function,
            unable to find optimum parameters
Calls: <Anonymous> ... eval -> eval -> <Anonymous> -> apply -> FUN -> GP_deviance

Execution halted

Any advice for how to deal with this would be much appreciated.

My R session is as follows:

> devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 4.0.0 (2020-04-24)
 os       CentOS Linux 7 (Core)       
 system   x86_64, linux-gnu           
 ui       X11                         
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       Europe/Bucharest            
 date     2020-06-03                  

─ Packages ───────────────────────────────────────────────────────────────────
 package               * version date       lib source        
 assertthat              0.2.1   2019-03-21 [1] CRAN (R 4.0.0)
 backports               1.1.7   2020-05-13 [1] CRAN (R 4.0.0)
 base64enc               0.1-3   2015-07-28 [1] CRAN (R 4.0.0)
 callr                   3.4.3   2020-03-28 [1] CRAN (R 4.0.0)
 cli                     2.0.2   2020-02-28 [1] CRAN (R 4.0.0)
 codetools               0.2-16  2018-12-24 [1] CRAN (R 4.0.0)
 crayon                  1.3.4   2017-09-16 [1] CRAN (R 4.0.0)
 data.table              1.12.8  2019-12-09 [1] CRAN (R 4.0.0)
 desc                    1.2.0   2018-05-01 [1] CRAN (R 4.0.0)
 devtools                2.3.0   2020-04-10 [1] CRAN (R 4.0.0)
 digest                  0.6.25  2020-02-23 [1] CRAN (R 4.0.0)
 ellipsis                0.3.1   2020-05-15 [1] CRAN (R 4.0.0)
 fansi                   0.4.1   2020-01-08 [1] CRAN (R 4.0.0)
 foreach                 1.5.0   2020-03-30 [1] CRAN (R 4.0.0)
 fs                      1.4.1   2020-04-04 [1] CRAN (R 4.0.0)
 generics                0.0.2   2018-11-29 [1] CRAN (R 4.0.0)
 glue                    1.4.1   2020-05-13 [1] CRAN (R 4.0.0)
 iterators               1.0.12  2019-07-26 [1] CRAN (R 4.0.0)
 jsonlite                1.6.1   2020-02-02 [1] CRAN (R 4.0.0)
 keras                 * 2.3.0.0 2020-05-19 [1] CRAN (R 4.0.0)
 lattice                 0.20-41 2020-04-02 [1] CRAN (R 4.0.0)
 magrittr                1.5     2014-11-22 [1] CRAN (R 4.0.0)
 Matrix                  1.2-18  2019-11-27 [1] CRAN (R 4.0.0)
 memoise                 1.1.0   2017-04-21 [1] CRAN (R 4.0.0)
 pkgbuild                1.0.8   2020-05-07 [1] CRAN (R 4.0.0)
 pkgload                 1.1.0   2020-05-29 [1] CRAN (R 4.0.0)
 prettyunits             1.1.1   2020-01-24 [1] CRAN (R 4.0.0)
 processx                3.4.2   2020-02-09 [1] CRAN (R 4.0.0)
 ps                      1.3.3   2020-05-08 [1] CRAN (R 4.0.0)
 R6                      2.4.1   2019-11-12 [1] CRAN (R 4.0.0)
 rBayesianOptimization * 1.1.0   2016-09-14 [1] CRAN (R 4.0.0)
 Rcpp                    1.0.4.6 2020-04-09 [1] CRAN (R 4.0.0)
 remotes                 2.1.1   2020-02-15 [1] CRAN (R 4.0.0)
 reticulate              1.16    2020-05-27 [1] CRAN (R 4.0.0)
 rlang                   0.4.6   2020-05-02 [1] CRAN (R 4.0.0)
 rprojroot               1.3-2   2018-01-03 [1] CRAN (R 4.0.0)
 sessioninfo             1.1.1   2018-11-05 [1] CRAN (R 4.0.0)
 tensorflow              2.2.0   2020-05-11 [1] CRAN (R 4.0.0)
 testthat                2.3.2   2020-03-02 [1] CRAN (R 4.0.0)
 tfruns                  1.4     2018-08-25 [1] CRAN (R 4.0.0)
 usethis                 1.6.1   2020-04-29 [1] CRAN (R 4.0.0)
 whisker                 0.4     2019-08-28 [1] CRAN (R 4.0.0)
 withr                   2.2.0   2020-04-20 [1] CRAN (R 4.0.0)
 zeallot                 0.1.0   2018-01-28 [1] CRAN (R 4.0.0)
amizeranschi commented 4 years ago

P.S. I'm running the script like this:

Rscript -e 'library(rmarkdown); setwd("/the/path"); rmarkdown::render("CNNGWPBOQTLMAS2010.R", "html_document")'
patwa67 commented 4 years ago

Do you have access to an earlier version of R, for example 3.6? The problem seems to be with the Gaussian process in the Bayesian optimization package. I have not tried the code in R 4.0.

Patrik

Den ons 3 juni 2020 21:35amizeranschi notifications@github.com skrev:

P.S. I'm running the script like this:

Rscript -e 'library(rmarkdown); setwd("/the/path"); rmarkdown::render("CNNGWPBOQTLMAS2010.R", "html_document")'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/patwa67/CNNGWP/issues/1#issuecomment-638416826, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFS7SJKFPRQ4ISMI3S5BDULRU2QY7ANCNFSM4NR56YPQ .

amizeranschi commented 4 years ago

Hi Patrik,

Thanks for the reply. I tried running with R 3.6.1 and ran into the exact same issue.

> devtools::session_info()
─ Session info ───────────────────────────────────────────────────────────────
 setting  value                       
 version  R version 3.6.1 (2019-07-05)
 os       CentOS Linux 7 (Core)       
 system   x86_64, linux-gnu           
 ui       X11                         
 language (EN)                        
 collate  en_US.UTF-8                 
 ctype    en_US.UTF-8                 
 tz       Europe/Bucharest            
 date     2020-06-04                  

─ Packages ───────────────────────────────────────────────────────────────────
 package               * version date       lib source        
 assertthat              0.2.1   2019-03-21 [1] CRAN (R 3.6.1)
 backports               1.1.7   2020-05-13 [1] CRAN (R 3.6.1)
 base64enc               0.1-3   2015-07-28 [1] CRAN (R 3.6.1)
 callr                   3.4.3   2020-03-28 [1] CRAN (R 3.6.1)
 cli                     2.0.2   2020-02-28 [1] CRAN (R 3.6.1)
 codetools               0.2-16  2018-12-24 [1] CRAN (R 3.6.3)
 crayon                  1.3.4   2017-09-16 [1] CRAN (R 3.6.1)
 data.table              1.12.8  2019-12-09 [1] CRAN (R 3.6.1)
 desc                    1.2.0   2018-05-01 [1] CRAN (R 3.6.1)
 devtools                2.3.0   2020-04-10 [1] CRAN (R 3.6.1)
 digest                  0.6.25  2020-02-23 [1] CRAN (R 3.6.1)
 ellipsis                0.3.1   2020-05-15 [1] CRAN (R 3.6.1)
 fansi                   0.4.1   2020-01-08 [1] CRAN (R 3.6.1)
 foreach                 1.5.0   2020-03-30 [1] CRAN (R 3.6.1)
 fs                      1.4.1   2020-04-04 [1] CRAN (R 3.6.1)
 generics                0.0.2   2018-11-29 [1] CRAN (R 3.6.1)
 glue                    1.4.1   2020-05-13 [1] CRAN (R 3.6.1)
 iterators               1.0.12  2019-07-26 [1] CRAN (R 3.6.1)
 jsonlite                1.6.1   2020-02-02 [1] CRAN (R 3.6.1)
 keras                 * 2.3.0.0 2020-05-19 [1] CRAN (R 3.6.1)
 lattice                 0.20-41 2020-04-02 [1] CRAN (R 3.6.3)
 magrittr                1.5     2014-11-22 [1] CRAN (R 3.6.1)
 Matrix                  1.2-18  2019-11-27 [1] CRAN (R 3.6.3)
 memoise                 1.1.0   2017-04-21 [1] CRAN (R 3.6.1)
 pkgbuild                1.0.8   2020-05-07 [1] CRAN (R 3.6.1)
 pkgload                 1.1.0   2020-05-29 [1] CRAN (R 3.6.1)
 prettyunits             1.1.1   2020-01-24 [1] CRAN (R 3.6.1)
 processx                3.4.2   2020-02-09 [1] CRAN (R 3.6.1)
 ps                      1.3.3   2020-05-08 [1] CRAN (R 3.6.1)
 R6                      2.4.1   2019-11-12 [1] CRAN (R 3.6.1)
 rBayesianOptimization * 1.1.0   2016-09-14 [1] CRAN (R 3.6.1)
 Rcpp                    1.0.4.6 2020-04-09 [1] CRAN (R 3.6.1)
 remotes                 2.1.1   2020-02-15 [1] CRAN (R 3.6.1)
 reticulate              1.16    2020-05-27 [1] CRAN (R 3.6.1)
 rlang                   0.4.6   2020-05-02 [1] CRAN (R 3.6.1)
 rprojroot               1.3-2   2018-01-03 [1] CRAN (R 3.6.1)
 sessioninfo             1.1.1   2018-11-05 [1] CRAN (R 3.6.1)
 tensorflow              2.2.0   2020-05-11 [1] CRAN (R 3.6.1)
 testthat                2.3.2   2020-03-02 [1] CRAN (R 3.6.1)
 tfruns                  1.4     2018-08-25 [1] CRAN (R 3.6.1)
 usethis                 1.6.1   2020-04-29 [1] CRAN (R 3.6.1)
 whisker                 0.4     2019-08-28 [1] CRAN (R 3.6.1)
 withr                   2.2.0   2020-04-20 [1] CRAN (R 3.6.1)
 zeallot                 0.1.0   2018-01-28 [1] CRAN (R 3.6.1)
patwa67 commented 4 years ago

I cannot find the GPfit package in your output. Try to uninstall rBayesianOptimization, then install GPfit and after that rBayesianOptimization. Run the script using only Rscript so you can see what the output is.

Den tors 4 juni 2020 14:29amizeranschi notifications@github.com skrev:

Hi Patrik,

Thanks for the reply. I tried running with R 3.6.1 and ran into the exact same issue.

devtools::session_info()

─ Session info ───────────────────────────────────────────────────────────────

setting value

version R version 3.6.1 (2019-07-05)

os CentOS Linux 7 (Core)

system x86_64, linux-gnu

ui X11

language (EN)

collate en_US.UTF-8

ctype en_US.UTF-8

tz Europe/Bucharest

date 2020-06-04

─ Packages ───────────────────────────────────────────────────────────────────

package * version date lib source

assertthat 0.2.1 2019-03-21 [1] CRAN (R 3.6.1)

backports 1.1.7 2020-05-13 [1] CRAN (R 3.6.1)

base64enc 0.1-3 2015-07-28 [1] CRAN (R 3.6.1)

callr 3.4.3 2020-03-28 [1] CRAN (R 3.6.1)

cli 2.0.2 2020-02-28 [1] CRAN (R 3.6.1)

codetools 0.2-16 2018-12-24 [1] CRAN (R 3.6.3)

crayon 1.3.4 2017-09-16 [1] CRAN (R 3.6.1)

data.table 1.12.8 2019-12-09 [1] CRAN (R 3.6.1)

desc 1.2.0 2018-05-01 [1] CRAN (R 3.6.1)

devtools 2.3.0 2020-04-10 [1] CRAN (R 3.6.1)

digest 0.6.25 2020-02-23 [1] CRAN (R 3.6.1)

ellipsis 0.3.1 2020-05-15 [1] CRAN (R 3.6.1)

fansi 0.4.1 2020-01-08 [1] CRAN (R 3.6.1)

foreach 1.5.0 2020-03-30 [1] CRAN (R 3.6.1)

fs 1.4.1 2020-04-04 [1] CRAN (R 3.6.1)

generics 0.0.2 2018-11-29 [1] CRAN (R 3.6.1)

glue 1.4.1 2020-05-13 [1] CRAN (R 3.6.1)

iterators 1.0.12 2019-07-26 [1] CRAN (R 3.6.1)

jsonlite 1.6.1 2020-02-02 [1] CRAN (R 3.6.1)

keras * 2.3.0.0 2020-05-19 [1] CRAN (R 3.6.1)

lattice 0.20-41 2020-04-02 [1] CRAN (R 3.6.3)

magrittr 1.5 2014-11-22 [1] CRAN (R 3.6.1)

Matrix 1.2-18 2019-11-27 [1] CRAN (R 3.6.3)

memoise 1.1.0 2017-04-21 [1] CRAN (R 3.6.1)

pkgbuild 1.0.8 2020-05-07 [1] CRAN (R 3.6.1)

pkgload 1.1.0 2020-05-29 [1] CRAN (R 3.6.1)

prettyunits 1.1.1 2020-01-24 [1] CRAN (R 3.6.1)

processx 3.4.2 2020-02-09 [1] CRAN (R 3.6.1)

ps 1.3.3 2020-05-08 [1] CRAN (R 3.6.1)

R6 2.4.1 2019-11-12 [1] CRAN (R 3.6.1)

rBayesianOptimization * 1.1.0 2016-09-14 [1] CRAN (R 3.6.1)

Rcpp 1.0.4.6 2020-04-09 [1] CRAN (R 3.6.1)

remotes 2.1.1 2020-02-15 [1] CRAN (R 3.6.1)

reticulate 1.16 2020-05-27 [1] CRAN (R 3.6.1)

rlang 0.4.6 2020-05-02 [1] CRAN (R 3.6.1)

rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.6.1)

sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.6.1)

tensorflow 2.2.0 2020-05-11 [1] CRAN (R 3.6.1)

testthat 2.3.2 2020-03-02 [1] CRAN (R 3.6.1)

tfruns 1.4 2018-08-25 [1] CRAN (R 3.6.1)

usethis 1.6.1 2020-04-29 [1] CRAN (R 3.6.1)

whisker 0.4 2019-08-28 [1] CRAN (R 3.6.1)

withr 2.2.0 2020-04-20 [1] CRAN (R 3.6.1)

zeallot 0.1.0 2018-01-28 [1] CRAN (R 3.6.1)

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/patwa67/CNNGWP/issues/1#issuecomment-638816731, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFS7SJNM4PRN3CP6FKXAMSTRU6HR7ANCNFSM4NR56YPQ .

amizeranschi commented 4 years ago

I couldn't find any reference to the GPfit package in the CNNGWPBOQTLMAS2010.R script, so I didn't install it myself. The script only loads two packages: keras and rBayesianOptimization. Should GPfit have been installed and loaded automatically? Is it a dependency of rBayesianOptimization?

Regardless, I've done as you suggested: uninstalled rBayesianOptimization, installed GPfit and reinstalled rBayesianOptimization, after which I ran the script directly via Rscript.

Is there a way to disable the TensorFlow warnings? Here's the output before the error occurs:

[...]
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
elapsed = 416.96    Round = 12  filter = 81.0000    kernel = 41.0000    lambda = 0.8214 Value = -Inf 
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
[...]
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
elapsed = 277.96    Round = 13  filter = 40.0000    kernel = 18.0000    lambda = 0.9416 Value = -Inf 
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
[...]
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
elapsed = 270.80    Round = 14  filter = 36.0000    kernel = 16.0000    lambda = 0.4031 Value = -Inf 
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
[...]
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
elapsed = 210.00    Round = 15  filter = 29.0000    kernel = 10.0000    lambda = 0.5105 Value = -Inf 
Error in GP_deviance(beta = row, X = X, Y = Y, nug_thres = nug_thres,  : 
  Infinite values of the Deviance Function, 
            unable to find optimum parameters 
Calls: BayesianOptimization ... eval -> eval -> <Anonymous> -> apply -> FUN -> GP_deviance
In addition: There were 15 warnings (use warnings() to see them)
Execution halted
patwa67 commented 4 years ago

Yes, rBayesianOptimization depends on GPfit. Do you have all the output, it seems as if the MSE goes to infinity at some point.

Den tors 4 juni 2020 19:53amizeranschi notifications@github.com skrev:

I couldn't find any reference to the GPfit package in the CNNGWPBOQTLMAS2010.R script, so I didn't install it myself. The script only loads two packages: keras and rBayesianOptimization. Should GPfit have been installed and loaded automatically? Is it a dependency of rBayesianOptimization?

Regardless, I've done as you suggested: uninstalled rBayesianOptimization, installed GPfit and reinstalled rBayesianOptimization, after which I ran the script directly via Rscript.

Is there a way to disable the TensorFlow warnings? Here's the output before the error occurs:

[...] WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. elapsed = 416.96 Round = 12 filter = 81.0000 kernel = 41.0000 lambda = 0.8214 Value = -Inf WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. [...] WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. elapsed = 277.96 Round = 13 filter = 40.0000 kernel = 18.0000 lambda = 0.9416 Value = -Inf WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. [...] WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. elapsed = 270.80 Round = 14 filter = 36.0000 kernel = 16.0000 lambda = 0.4031 Value = -Inf WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. [...] WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. elapsed = 210.00 Round = 15 filter = 29.0000 kernel = 10.0000 lambda = 0.5105 Value = -Inf Error in GP_deviance(beta = row, X = X, Y = Y, nug_thres = nug_thres, : Infinite values of the Deviance Function, unable to find optimum parameters Calls: BayesianOptimization ... eval -> eval -> -> apply -> FUN -> GP_deviance In addition: There were 15 warnings (use warnings() to see them) Execution halted

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/patwa67/CNNGWP/issues/1#issuecomment-639009405, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFS7SJMF4VT3EBU5ZYTZHA3RU7NQFANCNFSM4NR56YPQ .

amizeranschi commented 4 years ago

Looks like it's going to -Inf from the start. What could be causing this?

elapsed = 236.64        Round = 1   filter = 31.0000        kernel = 49.0000        lambda = 0.6193 Value = -Inf
elapsed = 327.28        Round = 2   filter = 58.0000        kernel = 29.0000        lambda = 0.8493 Value = -Inf
elapsed = 371.52        Round = 3   filter = 68.0000        kernel = 17.0000        lambda = 0.9276 Value = -Inf
elapsed = 330.90        Round = 4   filter = 62.0000        kernel = 17.0000        lambda = 0.1269 Value = -Inf
elapsed = 323.35        Round = 5   filter = 54.0000        kernel = 48.0000        lambda = 0.3151 Value = -Inf
patwa67 commented 4 years ago

Check if y and X are numeric.

Den tors 4 juni 2020 21:34amizeranschi notifications@github.com skrev:

Looks like it's going to -Inf from the start. What could be causing this?

elapsed = 236.64 Round = 1 filter = 31.0000 kernel = 49.0000 lambda = 0.6193 Value = -Inf elapsed = 327.28 Round = 2 filter = 58.0000 kernel = 29.0000 lambda = 0.8493 Value = -Inf elapsed = 371.52 Round = 3 filter = 68.0000 kernel = 17.0000 lambda = 0.9276 Value = -Inf elapsed = 330.90 Round = 4 filter = 62.0000 kernel = 17.0000 lambda = 0.1269 Value = -Inf elapsed = 323.35 Round = 5 filter = 54.0000 kernel = 48.0000 lambda = 0.3151 Value = -Inf

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/patwa67/CNNGWP/issues/1#issuecomment-639071790, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFS7SJIO5E2YUUBSECWDRXDRU7ZMVANCNFSM4NR56YPQ .

amizeranschi commented 4 years ago

They are.

class(Xtrain) = matrix; typeof(Xtrain) = double; class(ytrain) = numeric; typeof(ytrain) = double.

patwa67 commented 4 years ago

Very strange, it runs fine for me. I think you need to run parts of the code to find where the error is. Start with loading the data and running the cnngwp function with the optimal values from the paper to see what that outputs. You can change to verbose=1 under #Fit model.

Den tors 4 juni 2020 21:58amizeranschi notifications@github.com skrev:

They are.

class(Xtrain) = matrix; typeof(Xtrain) = double; class(ytrain) = numeric; typeof(ytrain) = double.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/patwa67/CNNGWP/issues/1#issuecomment-639083536, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFS7SJKOQ5DWDSO5L5GEMDTRU74GZANCNFSM4NR56YPQ .

amizeranschi commented 4 years ago

Are you running things on Linux or Windows?

Could you share the output of devtools::session_info()?

patwa67 commented 4 years ago

I'm using RStudio with R3.6.1 on Ubuntu 19.10. Otherwise the same setup as you use, but I run the script via RStudio. My guess is that the data is not in the correct format in your case.

Den fre 5 juni 2020 13:25amizeranschi notifications@github.com skrev:

Are you running things on Linux or Windows?

Could you share the output of devtools::session_info()?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/patwa67/CNNGWP/issues/1#issuecomment-639422797, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFS7SJOIWBVPNF4BZXD7KUTRVDI2LANCNFSM4NR56YPQ .

amizeranschi commented 4 years ago

Alright. I'll have a go at debugging this within the following days and post here about any progress.

Thanks a lot for your help so far.

amizeranschi commented 4 years ago

I tried running the script on Windows 10, from RStudio. The outcome was the same, the MSE becomes -Inf after the first epoch:

elapsed = 340.00    Round = 1   filter = 71.0000    kernel = 16.0000    lambda = 0.2281 Value = -Inf
elapsed = 283.06    Round = 2   filter = 60.0000    kernel = 11.0000    lambda = 0.3123 Value = -Inf
elapsed = 374.09    Round = 3   filter = 90.0000    kernel = 18.0000    lambda = 0.2075 Value = -Inf
elapsed = 194.56    Round = 4   filter = 29.0000    kernel = 28.0000    lambda = 0.1620 Value = -Inf

I'm quite new to DL in general. It would help a lot if you could be more specific about what you meant in your previous message:

Start with loading the data and running
the cnngwp function with the optimal values from the paper to see what that
outputs. You can change to verbose=1 under #Fit model.

Do you also get those TF warning messages and do you know of any way to get rid of them? Lots of these are printed and it makes it difficult to track the actual useful output.

WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.
WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.

I found a seemingly related issue, where someone mentioned that the warnings could be caused by having multiple outputs https://stackoverflow.com/questions/46438247/unable-to-save-weights-while-using-pre-trained-vgg16-model.

patwa67 commented 4 years ago

Start with loading the data and running the cnngwp function with the optimal values from the paper to see what that outputs. You can change to verbose=1 under #Fit model.

By this I mean that you should run the code line by line instead of the whole script and look at the output. The cnngwp function needs three input values. For example cnngwp(64,27,0.571).

Den mån 8 juni 2020 13:28amizeranschi notifications@github.com skrev:

I tried running the script on Windows 10, from RStudio. The outcome was the same, the MSE becomes -Inf after the first epoch:

elapsed = 340.00 Round = 1 filter = 71.0000 kernel = 16.0000 lambda = 0.2281 Value = -Inf elapsed = 283.06 Round = 2 filter = 60.0000 kernel = 11.0000 lambda = 0.3123 Value = -Inf elapsed = 374.09 Round = 3 filter = 90.0000 kernel = 18.0000 lambda = 0.2075 Value = -Inf elapsed = 194.56 Round = 4 filter = 29.0000 kernel = 28.0000 lambda = 0.1620 Value = -Inf

I'm quite new to DL in general. It would help a lot if you could be more specific about what you meant in your previous message:

Start with loading the data and running the cnngwp function with the optimal values from the paper to see what that outputs. You can change to verbose=1 under #Fit model.

Do you also get those TF warning messages and do you know of any way to get rid of them? Lots of these are printed and it makes it difficult to track the actual useful output.

WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping. WARNING:tensorflow:Can save best model only with val_mean_squared_error available, skipping.

I found a seemingly related issue, where someone mentioned that the warnings could be caused by having multiple outputs https://stackoverflow.com/questions/46438247/unable-to-save-weights-while-using-pre-trained-vgg16-model .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/patwa67/CNNGWP/issues/1#issuecomment-640544995, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFS7SJKUXST7KKLH6GSLWXTRVTDNLANCNFSM4NR56YPQ .

amizeranschi commented 4 years ago

It looks like the main problem comes from the following line:

  MSEmin <- min(history$metrics$val_mean_squared_error)

The history list doesn't contain an element called val_mean_squared_error. This results in MSEmin getting the value Inf:

> min(history$metrics$val_mean_squared_error)
[1] Inf
Warning message:
In min(history$metrics$val_mean_squared_error) :
  no non-missing arguments to min; returning Inf

In my case, this is the structure of the list history$metrics:

> names(history$metrics)
[1] "loss"     "mse"      "val_loss" "val_mse"

I solved the main issue by replacing:

MSEmin <- min(history$metrics$val_mean_squared_error)

with:

MSEmin <- min(history$metrics$val_mse)

It looks like the TensorFlow warnings were related to this, as well, as they also mentioned missing val_mean_squared_error values. I got rid of them by changing the line:

monitor = "val_mean_squared_error",

to:

monitor = "val_mse",

in the cp_callback creation code.

I'm not sure why the history object contains val_mse instead of val_mean_squared_error elements, as it seemed to be expected in the code.

In the end, this was the final output for me, which is quite similar to the optimal values mentioned in the article (interestingly, the kernel value was the exactly the same):

 Best Parameters Found:
Round = 15  filter = 80.0000        kernel = 27.0000        lambda = 0.6729 Value = -62.7409

The final MSE was only slightly worse compared to the one from the article: 62.74 vs. 62.34, respectively.

Should I submit a pull request for the modifications mentioned above?

patwa67 commented 4 years ago

Great that you found the problem. It is strange that it works for me. I will add a comment in the code, you don't need a pull request at this stage. In the paper, I repeated the BO 25 times and averaged over the three parameters (filter, kernel and lambda) to get modelaveraged(MA) estimates. Then I ran only the cnngwp function with these MA estimates, changing the code under #Prediction of yhat based on the best model. One should repeat this procedure also, lets say 25 times, and average over yhat. This will result in ensemble test predictions that further will decrease test MSE. The BO MA and ensemble prediction is imoprtant to stabilize and decrease test MSE.

Den mån 8 juni 2020 20:47amizeranschi notifications@github.com skrev:

It looks like the main problem comes from the following line:

MSEmin <- min(history$metrics$val_mean_squared_error)

The history list doesn't contain an element called val_mean_squared_error. This results in MSEmin getting the value Inf:

min(history$metrics$val_mean_squared_error) [1] Inf Warning message: In min(history$metrics$val_mean_squared_error) : no non-missing arguments to min; returning Inf

In my case, this is the structure of the list history$metrics:

names(history$metrics) [1] "loss" "mse" "val_loss" "val_mse"

I solved the main issue by replacing:

MSEmin <- min(history$metrics$val_mean_squared_error)

with:

MSEmin <- min(history$metrics$val_mse)

It looks like the TensorFlow warnings were related to this, as well, as they also mentioned missing val_mean_squared_error values. I got rid of them by changing the line:

monitor = "val_mean_squared_error",

to:

monitor = "val_mse",

in the cp_callback creation code.

I'm not sure why the history object contains val_mse instead of val_mean_squared_error elements, as it seemed to be expected in the code.

In the end, this was the final output for me, which is quite similar to the optimal values mentioned in the article (interestingly, the kernel value was the exactly the same):

Best Parameters Found: Round = 15 filter = 80.0000 kernel = 27.0000 lambda = 0.6729 Value = -62.7409

The final MSE was only slightly worse compared to the one from the article: 62.74 vs. 62.34, respectively.

Should I submit a pull request for the modifications mentioned above?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/patwa67/CNNGWP/issues/1#issuecomment-640805793, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFS7SJIZOOGLPA7LFBZUPHTRVUW2RANCNFSM4NR56YPQ .

amizeranschi commented 4 years ago

Alright. Thanks a lot for all this information and for your help.