Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[R-package] current_iter in LightGBM R Model Objects Shares Memory Across Independent Models #6806

Open
TaaviU opened this issue Jan 29, 2025 · 0 comments

Comments

@TaaviU
Copy link

TaaviU commented Jan 29, 2025

Description

In the LightGBM R package, the current_iter attribute of independently trained models appears to share the same memory reference. This results in unexpected behavior where querying current_iter from one model affects the value of current_iter in another independent model.

Reproducible example

library(lightgbm)

m1 <- lgb.train(params = list(objective = "regression", metric = "rmse"),
                data = lgb.Dataset(matrix(runif(1000), ncol = 10), label = runif(100)),
                nrounds = 50)
n1 <- m1$current_iter() 

print(n1) # 50 as expected

m2 <- lgb.train(params = list(objective = "regression", metric = "rmse"),
                data = lgb.Dataset(matrix(runif(1000), ncol = 10), label = runif(100)),
                nrounds = 30)
n2 <- m2$current_iter()

print(n2) # 30 as expected

print(n1) # Expected: 50, Actual: 30

Environment info

LightGBM version: 4.5.0

@jameslamb jameslamb changed the title current_iter in LightGBM R Model Objects Shares Memory Across Independent Models [R-package] current_iter in LightGBM R Model Objects Shares Memory Across Independent Models Jan 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants