Skip to content

Commit fecc37c

Browse files
committed
give meaning to batchsize=0
1 parent ff2fcc1 commit fecc37c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/eachobs.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ The original data is preserved in the `data` field of the DataLoader.
5656
- `data`: The data to be iterated over. The data type has to be supported by
5757
[`numobs`](@ref) and [`getobs`](@ref).
5858
- `batchsize`: If less than 0, iterates over individual observations.
59-
Otherwise, each iteration (except possibly the last) yields a mini-batch
59+
If 0, then one mini-batch containing all `numobs(x)` observations.
60+
If larger than 0, each iteration (except possibly the last) yields a mini-batch
6061
containing `batchsize` observations. Default `1`.
6162
- `buffer`: If `buffer=true` and supported by the type of `data`,
6263
a buffer will be allocated and reused for memory efficiency.
@@ -149,6 +150,7 @@ function DataLoader(
149150
if !(collate (Val(nothing), Val(true), Val(false)))
150151
throw(ArgumentError("`collate` must be one of `nothing`, `true` or `false`."))
151152
end
153+
batchsize = batchsize == 0 ? numobs(data) : batchsize
152154
return DataLoader(data, batchsize, buffer, partial, shuffle, parallel, collate, rng)
153155
end
154156

0 commit comments

Comments
 (0)