-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
I suppose that any object supports getobs and numobs should work. Recently, I ran into an error when creating Dataloader with a customized type. Not sure if I'm doing anything wrong here.
A Minimal example:
struct DD
idx::Vector{Int32}
end
getobs(d::DD, i) = d.idx[i]
numobs(d::DD) = length(d.idx)
data = DD([1,2,3,4])
DataLoader(data)This will return error:
MethodError: no method matching length(::Main.var"workspace#4".DD)
Stack trace:
1. numobs(::Type{…}, data::DD) [...show types...](http://localhost:1234/edit?id=ee1c16dc-f894-11f0-80b6-ab4c33f1313d#)
from
observation.jl:57
2 .numobs
from
SimpleTraits.jl:332
3. MLUtils.DataLoader(data::DD; buffer::Bool, parallel::Bool, shuffle::Bool, batchsize::Int64, partial::Bool, collate::Val{nothing}, rng::Random.TaskLocalRNG)
from
dataloader.jl:167
4. MLUtils.DataLoader(data::DD)
from
dataloader.jl:151
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels