chunks util
This commit is contained in:
parent
d9ed5676c2
commit
d9abb8f0ce
|
@ -1,4 +1,4 @@
|
|||
export AArray, onehot, onecold
|
||||
export AArray, onehot, onecold, chunks
|
||||
|
||||
const AArray = AbstractArray
|
||||
|
||||
|
@ -6,6 +6,9 @@ onehot(T::Type, label, labels) = T[i == label for i in labels]
|
|||
onehot(label, labels) = onehot(Int, label, labels)
|
||||
onecold(pred, labels = 1:length(pred)) = labels[findfirst(pred, maximum(pred))]
|
||||
|
||||
chunks(r::UnitRange, step::Integer) = (step*(i-1)+1:step*i for i in 1:(r.stop÷step))
|
||||
chunks(xs, step) = (xs[i] for i in chunks(1:length(xs), step))
|
||||
|
||||
initn(dims...) = randn(Float32, dims...)/1000
|
||||
|
||||
function train!(m, train, test = []; epoch = 1, batch = 10, η = 0.1)
|
||||
|
|
Loading…
Reference in New Issue