tabnet icon indicating copy to clipboard operation
tabnet copied to clipboard

Reproducibility is achieved only on second and subsequent runs of `tabnet_pretrain()`

Open cgoo4 opened this issue 2 years ago • 0 comments

Reprex:

library(tabnet)
library(tidymodels)
library(modeldata)

data("lending_club", package = "modeldata")

rec <-
  lending_club |>
  recipe() |>
  update_role(Class, new_role = "outcome") |>
  update_role(-has_role("outcome"), new_role = "predictor")

re_run <- \(x){
  set.seed(1)

  pre <- rec |>
    tabnet_pretrain(
      lending_club,
      device = "cpu",
      verbose = TRUE
    )
}

# Reproducible on second & subsequent runs
walk(1:5, re_run)
#> [Epoch 001] Loss: 147.732330
#> [Epoch 002] Loss: 26.149096
#> [Epoch 003] Loss: 10.889544
#> [Epoch 004] Loss: 8.871026
#> [Epoch 005] Loss: 7.879140
#> [Epoch 001] Loss: 17.072802
#> [Epoch 002] Loss: 7.753736
#> [Epoch 003] Loss: 4.936627
#> [Epoch 004] Loss: 4.208411
#> [Epoch 005] Loss: 4.171945
#> [Epoch 001] Loss: 17.072802
#> [Epoch 002] Loss: 7.753736
#> [Epoch 003] Loss: 4.936627
#> [Epoch 004] Loss: 4.208411
#> [Epoch 005] Loss: 4.171945
#> [Epoch 001] Loss: 17.072802
#> [Epoch 002] Loss: 7.753736
#> [Epoch 003] Loss: 4.936627
#> [Epoch 004] Loss: 4.208411
#> [Epoch 005] Loss: 4.171945
#> [Epoch 001] Loss: 17.072802
#> [Epoch 002] Loss: 7.753736
#> [Epoch 003] Loss: 4.936627
#> [Epoch 004] Loss: 4.208411
#> [Epoch 005] Loss: 4.171945

Created on 2024-01-14 with reprex v2.1.0

cgoo4 avatar Jan 14 '24 11:01 cgoo4