cleaner chunk util
This commit is contained in:
parent
b3ef370456
commit
0a6b6e1d6f
@ -4,7 +4,10 @@ using Base.Iterators: partition
|
|||||||
|
|
||||||
partitionr(xs, n) = take(partition(xs, n), length(xs)÷n)
|
partitionr(xs, n) = take(partition(xs, n), length(xs)÷n)
|
||||||
|
|
||||||
|
chunk(xs, n) = (partitionr(xs, length(xs)÷n)...,)
|
||||||
|
|
||||||
batches(xs, n) = (Batch([xs...]) for xs in partitionr(xs, n))
|
batches(xs, n) = (Batch([xs...]) for xs in partitionr(xs, n))
|
||||||
|
seqs(xs, n) = (Seq([xs...]) for xs in partitionr(xs, n))
|
||||||
|
|
||||||
# Stateful iteration
|
# Stateful iteration
|
||||||
|
|
||||||
|
@ -21,5 +21,3 @@ onecold(y::AbstractVector, labels = 1:length(y)) =
|
|||||||
|
|
||||||
onecold(y::AbstractMatrix, l...) =
|
onecold(y::AbstractMatrix, l...) =
|
||||||
squeeze(mapslices(y -> onecold(y, l...), y, 2), 2)
|
squeeze(mapslices(y -> onecold(y, l...), y, 2), 2)
|
||||||
|
|
||||||
chunk(xs, n) = Base.Iterators.partition(xs, length(xs)÷n)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user