Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
mcabbott committed Aug 26, 2023
1 parent 18a941f commit d93e611
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/splitobs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,13 @@ Supports any datatype implementing the [`numobs`](@ref) and
julia> splitobs(permutedims(1:100); at=0.7) # simple 70%-30% split, of a matrix
([1 2 … 69 70], [71 72 … 99 100])
julia> splitobs((x=ones(1,10), n=1:10), at=(0.5, 0.3)) # a 50%-30%-20% split, of a NamedTuple
((x = [1.0 1.0 … 1.0 1.0], n = 1:5), (x = [1.0 1.0 1.0], n = 6:8), (x = [1.0 1.0], n = 9:10))
julia> data = (x=ones(2,10), n=1:10) # a NamedTuple, consistent last dimension
(x = [1.0 1.0 … 1.0 1.0; 1.0 1.0 1.0 1.0], n = 1:10)
julia> train, test = Flux.splitobs((permutedims(1:100), 101:200), at=0.7, shuffle=true);
julia> splitobs(data, at=(0.5, 0.3)) # a 50%-30%-20% split, e.g. train/test/validation
((x = [1.0 1.0 … 1.0 1.0; 1.0 1.0 … 1.0 1.0], n = 1:5), (x = [1.0 1.0 1.0; 1.0 1.0 1.0], n = 6:8), (x = [1.0 1.0; 1.0 1.0], n = 9:10))
julia> train, test = splitobs((permutedims(1.0:100.0), 101:200), at=0.7, shuffle=true); # split a Tuple
julia> vec(test[1]) .+ 100 == test[2]
true
Expand Down

0 comments on commit d93e611

Please sign in to comment.