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

Let DataLoader(..., batchsize=0) produce one batch #145

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
4 changes: 3 additions & 1 deletion src/eachobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ The original data is preserved in the `data` field of the DataLoader.
- `data`: The data to be iterated over. The data type has to be supported by
[`numobs`](@ref) and [`getobs`](@ref).
- `batchsize`: If less than 0, iterates over individual observations.
Otherwise, each iteration (except possibly the last) yields a mini-batch
If 0, then one mini-batch containing all `numobs(x)` observations.
If larger than 0, each iteration (except possibly the last) yields a mini-batch
containing `batchsize` observations. Default `1`.
- `buffer`: If `buffer=true` and supported by the type of `data`,
a buffer will be allocated and reused for memory efficiency.
Expand Down Expand Up @@ -149,6 +150,7 @@ function DataLoader(
if !(collate ∈ (Val(nothing), Val(true), Val(false)))
throw(ArgumentError("`collate` must be one of `nothing`, `true` or `false`."))
end
batchsize = batchsize == 0 ? numobs(data) : batchsize
return DataLoader(data, batchsize, buffer, partial, shuffle, parallel, collate, rng)
end

Expand Down