use Float32 here
This commit is contained in:
parent
a06145a145
commit
d442dd8c5b
|
@ -1,6 +1,6 @@
|
|||
using Flux, MNIST
|
||||
|
||||
data = [(trainfeatures(i), Vector{Float32}(onehot(trainlabel(i), 0:9))) for i = 1:60_000]
|
||||
data = [(Vector{Float32}(trainfeatures(i)), onehot(Float32, trainlabel(i), 0:9)) for i = 1:60_000]
|
||||
train = data[1:50_000]
|
||||
test = data[50_001:60_000]
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@ export AArray, onehot, onecold
|
|||
|
||||
const AArray = AbstractArray
|
||||
|
||||
onehot(label, labels) = [i == label for i in labels]
|
||||
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))]
|
||||
|
||||
initn(dims...) = randn(Float32, dims...)/1000
|
||||
|
|
Loading…
Reference in New Issue