Как возобновить сохраненный снимок в цепочке с помощью Python - PullRequest
0 голосов
/ 27 февраля 2019

Как возобновить обучение из сохраненного снимка в цепочке. Я пытался реализовать DCGAN с помощью цепочки, используя следующую ссылку github:

https://github.com/chainer/chainer/blob/master/examples/dcgan/train_dcgan.py

Когда я пытаюсь дать *Параметр 1006 * показывает ошибку несоответствия формы в сети.

В коде Python есть опция для создания моментального снимка, с которого мы должны возобновить обучение. Эти снимки автоматически сохраняются в папке результатов.также указывается в качестве аргумента в коде. Поэтому я попытался возобновить обучение из сохраненного снимка, введя следующую команду.

$ python train.py --resume 'snapshot.npz'

где train.py - модифицированный код с меткой для набора данных dcgan ciphar10.

Ошибка, полученная с помощью приведенной выше команды:

chainer.utils.type_check.InvalidType: 
Invalid operation is performed in: LinearFunction (Forward)

Expect: x.shape[1] == W.shape[1]
Actual: 110 != 100

Когда я запускаю файл python с помощью приведенной ниже команды, ошибки не возникает:

$ python train.py

Полная ошибкаслед:

Exception in main training loop: 
Invalid operation is performed in: LinearFunction (Forward)
Expect: x.shape[1] == W.shape[1]
Actual: 110 != 100
Traceback (most recent call last):
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py, line 315, in run
    update()
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/training/updaters/standard_updater.py, line 165, in update
    self.update_core()
  File /home/964769/Lakshmi/DCGAN/updater_with_label.py, line 50, in update_core
    x_fake = gen(z,labels)
  File /home/964769/Lakshmi/DCGAN/net_with_label.py, line 61, in call
    h = F.reshape(F.relu(self.bn0(self.l0(F.concat((z,t),axis=1)))),
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/link.py, line 242, in call
    out = forward(args, *kwargs)
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/links/connection/linear.py, line 138, in forward
    return linear.linear(x, self.W, self.b, n_batch_axes=n_batch_axes)
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py, line 288, in linear
    y, = LinearFunction().apply(args)
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/function_node.py, line 245, in apply
    self.check_data_type_forward(in_data)
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/function_node.py, line 330, in check_data_type_forward
    self.check_type_forward(in_type)
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py, line 27, in check_type_forward
    x_type.shape[1] == w_type.shape[1],
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/utils/typecheck.py, line 546, in expect
    expr.expect()
  File/home/964769/anaconda3/lib/python3.6/site-packages/chainer/utils/typecheck.py, line 483, in expect
    '{0} {1} {2}'.format(left, self.inv, right))
Will finalize trainer extensions and updater before reraising the exception.
Traceback (most recent call last):
  Filetrain.py, line 140, in 
    main()
  Filetrain.py, line 135, in main
    trainer.run()
  File/home/964769/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py, line 329, in run
    six.reraise(sys.exc_info())
  File /home/964769/anaconda3/lib/python3.6/site-packages/six.py, line 686, in reraise
    raise value
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py, line 315, in run
    update()
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/training/updaters/standard_updater.py, line 165, in update
    self.update_core()
  File /home/964769/Lakshmi/DCGAN/updater_with_label.py, line 50, in update_core
    x_fake = gen(z,labels)
  File /home/964769/Lakshmi/DCGAN/net_with_label.py, line 61, in call
    h = F.reshape(F.relu(self.bn0(self.l0(F.concat((z,t),axis=1)))),
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/link.py, line 242, in call
    out = forward(args, **kwargs)
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/links/connection/linear.py, line 138, in forward
    return linear.linear(x, self.W, self.b, n_batch_axes=n_batch_axes)
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py, line 288, in linear
    y, = LinearFunction().apply(args)
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/function_node.py, line 245, in apply
    self.check_data_type_forward(in_data)
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/function_node.py, line 330, in check_data_type_forward
    self.check_type_forward(in_type)
  File /home/964769/anaconda3/lib/python3.6/site-packages/chainer/functions/connection/linear.py, line 27, in checktype_forward
    x_type.shape[1] == w_type.shape[1],
  File "/home/964769/anaconda3/lib/python3.6/site-packages/chainer/utils/typecheck.py, line 546, in expect
    expr.expect()
  File/home/964769/anaconda3/lib/python3.6/site-packages/chainer/utils/type_check.py", line 483, in expect
    '{0} {1} {2}'.format(left, self.inv, right))
chainer.utils.type_check.InvalidType: 
Invalid operation is performed in: LinearFunction (Forward)
Expect: x.shape[1] == W.shape[1]
Actual: 110 != 100
...