+
Skip to content

Conversation

tdhock
Copy link
Contributor

@tdhock tdhock commented Sep 5, 2025

Closes #420

This PR affects this code example #420 (comment)

Before this PR we get

> inst_learner$train(sonar_task)
Error in ctx$batch$y$to(device = ctx$device) : 
  attempt to apply non-function

After this PR we get a more informative error which should be able to help the user do a fix:

Error in train_loop(ctx, callbacks) (from mlr3torch-bug.R#55) : 
  dataloader_next() returned NULL, which means there are no more samples/batches. Typically this occurs when length of sampler/batch_sampler is greater than the number of samples/batches. Please modify .length() method to return the correct number (samples for sampler, batches for batch_sampler), which should be equal to the number of times that .iter() can be called before returning coro::exhausted()

@tdhock tdhock marked this pull request as ready for review September 5, 2025 14:34
@tdhock tdhock changed the title fix batch_sampler support learner$train() informative error for incorrect sampler Sep 5, 2025
@sebffischer
Copy link
Member

thanks!

@sebffischer sebffischer merged commit d2aeb62 into mlr-org:main Sep 19, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TorchLearner: support / example for custom batch_sampler

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载