我得到了这个错误:
DimensionMismatch("second dimension of A, 1, does not match length of x, 20")
以获取以下代码。我正在尝试在一些样本data
上训练一个模型。我正在使用Julia中的Flux
机器学习库。
我检查了我的尺寸,它们对我来说似乎是正确的。有什么问题吗?
using Flux
using Flux: mse
data = [(i,i) for i in 1:20]
x = [i for i in 1:20]
y = [i for i in 1:20]
m = Chain(
Dense(1, 10, relu),
Dense(10, 1),
softmax)
opt = ADAM(params(m))
loss(x, y) = mse(m(x), y)
evalcb = () -> @show(loss(x, y))
accuracy(x, y) = mean(argmax(m(x)) .== argmax(y))
#this line gives the error
Flux.train!(loss, data, opt,cb = throttle(evalcb, 10))
转载请注明出处:http://www.jubohx.com/article/20230427/1753779.html