tidymodels / brulee

High-Level Modeling Functions with 'torch'
https://brulee.tidymodels.org/
Other
67 stars 7 forks source link

reproducible fits within a session #1

Closed topepo closed 4 years ago

topepo commented 4 years ago

Current using torch::torch_manual_seed(sample.int(10^5, 1)) but getting different results with the same R seed. If both of these are re-run, the same results occur, so we need to find a way to set the torch seed repeatedly.

library(lantern)
suppressPackageStartupMessages(library(tidymodels))

data(ames)

ames$Sale_Price <- log10(ames$Sale_Price)

set.seed(1)
torch_mlp(x = as.matrix(ames[, c("Longitude", "Latitude")]),
          y = ames$Sale_Price, penalty = 0.10, epochs = 10)
#> Multilayer perceptron via torch
#> 
#> relu activation
#> 2 features, 3 hidden units, 11 model coefficients
#> weight decay: 0.1 
#> final validation RMSE after 10 epochs: 83.2622

set.seed(1)
torch_mlp(x = as.matrix(ames[, c("Longitude", "Latitude")]),
          y = ames$Sale_Price, penalty = 0.10, epochs = 10)
#> Multilayer perceptron via torch
#> 
#> relu activation
#> 2 features, 3 hidden units, 11 model coefficients
#> weight decay: 0.1 
#> final validation RMSE after 10 epochs: 5.77386

Created on 2020-10-14 by the reprex package (v0.3.0)

dfalbel commented 4 years ago

This was a bug in torch. Will be fixed in https://github.com/mlverse/torch/pull/303

github-actions[bot] commented 3 years ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.