Skip to content

Commit

Permalink
give meaning to batchsize=0
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Feb 11, 2023
1 parent ff2fcc1 commit fecc37c
Showing 1 changed file with 3 additions and 1 deletion.
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

0 comments on commit fecc37c

Please sign in to comment.