遇到一个bug

Will finalize trainer extensions and updater before reraising the exception.
Traceback (most recent call last):
  File "/home/zlee/PycharmProjects/hyperface-youtube/hyperface-master/scripts/train.py", line 176, in <module>
    trainer.run()
  File "/home/zlee/PycharmProjects/hyperface-youtube/venv/local/lib/python2.7/site-packages/chainer/training/trainer.py", line 329, in run
    six.reraise(*sys.exc_info())
  File "/home/zlee/PycharmProjects/hyperface-youtube/venv/local/lib/python2.7/site-packages/chainer/training/trainer.py", line 315, in run
    update()
  File "/home/zlee/PycharmProjects/hyperface-youtube/venv/local/lib/python2.7/site-packages/chainer/training/updaters/standard_updater.py", line 165, in update
    self.update_core()
  File "/home/zlee/PycharmProjects/hyperface-youtube/venv/local/lib/python2.7/site-packages/chainer/training/updaters/standard_updater.py", line 179, in update_core
    optimizer.update(loss_func, **in_arrays)
  File "/home/zlee/PycharmProjects/hyperface-youtube/venv/local/lib/python2.7/site-packages/chainer/optimizer.py", line 680, in update
    loss = lossfun(*args, **kwds)
  File "/home/zlee/PycharmProjects/hyperface-youtube/hyperface-master/scripts/models.py", line 114, in __call__
    h_landmark *= _disconnect(m_landmark)
  File "/home/zlee/PycharmProjects/hyperface-youtube/hyperface-master/scripts/models.py", line 22, in _disconnect
    return chainer.Variable(x.data)
  File "/home/zlee/PycharmProjects/hyperface-youtube/venv/local/lib/python2.7/site-packages/chainer/variable.py", line 505, in __init__
    raise TypeError(msg)
TypeError: numpy.ndarray or cuda.ndarray are expected.
Actual: <type 'cupy.cuda.memory.MemoryPointer'>

在调用函数时出现的问题:

def _disconnect(x):
    print("zlee", type(x), type(x.data))
    return chainer.Variable(x.data)

我打印了一下,是如下类型:

('zlee', <type 'cupy.core.core.ndarray'>, <type 'cupy.cuda.memory.MemoryPointer'>)

改正的方案如下所示:

def _disconnect(x):
    x = cupy.asnumpy(x)
    print("zlee : ", type(x),type(x.data))
    return chainer.Variable(x.data)

另外加入 import cupy