Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions R/learner_torch_methods.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ train_loop = function(ctx, cbs) {
while (ctx$step < length(ctx$loader_train)) {
ctx$step = ctx$step + 1
ctx$batch = dataloader_next(train_iterator)
if (is.null(ctx$batch)) {
stop("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()")
}
ctx$batch$x = lapply(ctx$batch$x, function(x) x$to(device = ctx$device))
ctx$batch$y = ctx$batch$y$to(device = ctx$device)
ctx$optimizer$zero_grad()
Expand Down
Loading