我有一个图像数据集(https://www.kaggle.com/iarunava/cell-images-for-detecting-malaria),我想使用神经网络来了解一张图片是否是未感染的细胞。所以我安排我的数据得到 4 个变量:
X_tests, Y_tests, X_training, Y_training
这些变量中的每一个都是类型Array{Array{Float64,1},1}
我有一个功能来构建一个简单的神经网络(来自一个例子https://smist08.wordpress.com/2018/09/24/julia-flux-for-machine-learning/):
function simple_nn(X_tests, Y_tests, X_training, Y_training)
input = 100*100*3
hl1 = 32
m = Chain(
Dense(input, 32, relu),
Dense(32, 2),
softmax) |> gpu
loss(x, y) = crossentropy(m(x), y)
accuracy(x, y) = mean(onecold(m(x)) .== onecold(y))
dataset = [(X_training,Y_training)]
evalcb = () -> @show(loss(X_training, Y_training))
opt = ADAM(params(m))
Flux.train!(loss, dataset, opt, cb = throttle(evalcb, 10))
println("acc X,Y ", accuracy(X_training, Y_training))
println("acc tX, tY ", accuracy(X_tests, Y_tests))
end
执行后出现此错误simple_nn(X_tests, Y_tests, X_training, Y_training)
:
ERROR: DimensionMismatch("matrix A has dimensions (32,30000), vector B has length 2668")
...
错误在这一行:Flux.train!(loss, dataset, opt, cb = throttle(evalcb, 10))
我不知道这些函数在做什么,它们采用什么参数,它们返回什么,我在互联网上找不到任何文档。我只能找到例子。所以我有两个问题:我怎样才能使它适用于我的数据集?是否有 Flux 函数的文档,例如 sklearn?(例如这样:https ://scikit-learn.org/stable/modules/generated/sklearn.svm.SVC.html )