【发布时间】:2018-02-22 11:14:24
【问题描述】:
我收到此错误:
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))
【问题讨论】:
-
对 Flux 不太熟悉,但如果您发布完整的错误消息,人们可能会更容易提供帮助 :)
-
您的代码由于油门而引发 undefvar 错误。你能修好吗?
标签: machine-learning neural-network julia flux-machine-learning