我在PyBrain
中有一个基本的,有效的神经网络实现# relevant imports go here
train_input = numpy.loadtxt('train_input.csv', delimiter=',')
test_input = numpy.loadtxt('test_input.csv', delimiter=',')
train_output = numpy.loadtxt('train_output.csv', delimiter=',')
test_output = numpy.loadtxt('test_output.csv', delimiter=',')
train_input = train_input / train_input.max(axis=0)
test_input = test_input / test_input.max(axis=0)
train_output = train_output / train_output.max(axis=0)
test_output = test_output / test_output.max(axis=0)
ds = SupervisedDataSet(2, 1)
for x in range(0, len(train_input) - 1):
ds.addSample(train_input[x], train_output[x])
fnn = buildNetwork( ds.indim, 25, ds.outdim, bias=True)
trainer = BackpropTrainer(fnn, ds, learningrate=0.01, momentum=0.1)
for epoch in range(0, 100000):
if epoch % 10000 == 0:
error = trainer.train()
print 'Epoch: ', epoch
print 'Error: ', error
result = numpy.array([fnn.activate(x) for x in test_input])
我可以通过将其提交到Apache Spark来运行此功能。然而,在不改变代码的情况下,我认为我从Spark中得不到任何东西。
我注意到有人投票决定关闭这个,所以也许我太模糊了。重述我的问题
for
循环,如何将其更改为通过Spark并行运行