如何更改此训练参数(旧版本代码)并在培训器扩展中使用此参数。在Chainer: 5.4.0中使用这段代码需要做哪些必要的修改。
ValueError: train argument is not supported anymore. Use
chainer.using_configAutoEncoder/StackedAutoEncoder/Regression.py(https://github.com/quolc/chainer-ML-examples/blob/master/mnist-stacked-autoencoder/net.py)
Train.py(sae.py)
for epoch in range(0, n_epoch):
print(' epoch {}'.format(epoch+1))
perm = np.random.permutation(N)
permed_data = np.array(input_data[perm])
sum_loss = 0
start = time.time()
for i in range(0, N, batchsize):
x = chainer.Variable(permed_data[i:i+batchsize])
y = chainer.Variable(permed_data[i:i+batchsize])
optimizer.update(model, x, y)
sum_loss += float(model.loss.data) * len(y.data)
end = time.time()
throughput = N / (end - start)
print(' train mean loss={}, throughput={} data/sec'.format(sum_loss
/ N, throughput))
sys.stdout.flush()
# prepare train data for next layer
x = chainer.Variable(np.array(train_data))
train_data_for_next_layer = cuda.to_cpu(ae.encode(x, train=False).data)错误地指出了两个不同的部分: 1. optimizer.update(模型,x,y) 2.为下一层第二行准备训练数据,其中它们不匹配每一层中的节点数。错误代码如下所示。
InvalidType:
Invalid operation is performed in: LinearFunction (Forward)
Expect: prod(in_types[0].shape[1:]) == in_types[1].shape[1]
Actual: 784 != 250发布于 2019-05-06 09:19:28
至于训练论点,细节写在这里:v2.html
v1中的下拉列表使用了train参数,但现在Chainer使用配置来管理它的阶段:无论是否在培训中。所以,有两件事要做。首先,从脚本中删除train参数。第二,在上下文中移动推理代码。
with chainer.using_config(‘train’, False):
# define the inference process为下一层第二线准备训练数据,其中它们不匹配每个层中的节点数。
你能分享这些错误信息吗?
https://stackoverflow.com/questions/56000599
复制相似问题