【问题标题】:BoundsError in Julia MXNet when using small batch size使用小批量时 Julia MXNet 中的 BoundsError
【发布时间】:2017-07-31 02:04:07
【问题描述】:

我正在尝试在 Julia 0.6.0 中重现一些 Python MXNet 代码,如果我尝试使用小于输出维度的批量大小,则会收到 BoundsError。如果我在玩具示例中使用更大的批量大小,则一切正常,网络会收敛到正确的解决方案,但在我的应用程序中,输出维度很大,所以这不切实际。

这是一个给出此错误的线性回归示例:

using MXNet
net = mx.Variable(:data)
net = mx.FullyConnected(net, name=:fc0, num_hidden=5)
net = mx.LinearRegressionOutput(net, name=:output)
mod = mx.FeedForward(net, context=mx.cpu(0))

batch_size = 4 # works for batch_size > 4

A = randn(5,100)
train_in = randn(100,1000)
train_out = A*train_in + .1*randn(5,1000)
train_provider = mx.ArrayDataProvider(:data=>train_in,
                                      :output_label=>train_out,
                                      shuffle=true,
                                      batch_size=batch_size)

optimizer = mx.SGD(lr=0.001, momentum=0.9, weight_decay=0.00001)
mx.fit(mod, optimizer, train_provider)

这会产生

INFO: Start training on MXNet.mx.Context[CPU0]
INFO: Initializing parameters...
INFO: Creating KVStore...
INFO: TempSpace: Total 0 MB allocated on CPU0
INFO: Start training...
ERROR: LoadError: BoundsError: attempt to access 5×4 Array{Float32,2} at index [Base.Slice(Base.OneTo(5)), 5]

如果我将批量大小增加到 5 或更大,它会按预期工作。我错过了什么?

【问题讨论】:

标签: julia mxnet


【解决方案1】:

您可以在此处跟踪此错误的解决方案:

https://github.com/dmlc/MXNet.jl/issues/264

我在两周前测试过它,不幸的是它仍在发生。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-28
    • 1970-01-01
    • 1970-01-01
    • 2023-04-08
    • 2020-04-26
    相关资源
    最近更新 更多