例如
假设变量是:
假设网络是:
假设数据(numpy)是:
我想知道如何构建模型?
mod = mx.mod.Module(context=mx.gpu(), symbol=prediction,
data_names=['inputs_a', 'inputs_b'], label_names=['label'])
我想知道如何构建数据呢?
train_iter = mx.io.NDArrayIter(data=[data_a, data_b], label=data_label,batch_size=3,data_name=['inputs_a', 'inputs_b'],label_name='label')
但是这种格式是错误的。我在MXNet的教程和API文档中找不到这种多输入数据演示。还有一些,MXNet演示的博客很少。 那么你能告诉我正确的方法吗?或者告诉我你的演示。谢谢!
答案 0 :(得分:1)
NDArrayIter支持多个输入。以下代码片段有望捕获您想要执行的操作:
import mxnet as mx X1 = mx.sym.Variable('X1') X2 = mx.sym.Variable('X2') Y = mx.sym.Variable('Y') fcX1 = mx.sym.FullyConnected(data=X1, num_hidden=10, name='fcX1') fcX2 = mx.sym.FullyConnected(data=X2, num_hidden=10, name='fcX2') prediction = fcX1 + fcX2 graph = mx.sym.LinearRegressionOutput(data=prediction, label=Y, name='lro') model = mx.mod.Module(symbol=prediction, data_names=['X2', 'X1'], label_names=['Y']) # set x1, x2 and y to the training inputs corresponding to X1, X2 and Y data = {'X1' : x1, 'X2' : x2} label = {'Y' : y} data_iter = mx.io.NDArrayIter(data, label, batch_size) model.fit(data_iter, ...)