Skip to content

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

Description

@cgoo4

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions