Chainerで学習時にエラーが出てしまい、学習できない
初めて利用します。
私は、chainerを利用してConvolutionalLSTMという機構を用いた機械学習の研究を行っております。
MovingMnistを利用した実験ではプログラムが動いたのですが、手持ちのデータを利用しようとした所エラーが出てしまい、困っております。
入力データは、320x256のbmpデータ(1チャンネル)になります。
エラー内容
/home/denko/anaconda3/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
from ._conv import register_converters as _register_converters
Exception in main training loop: Unsupported dtype object
Traceback (most recent call last):
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 299, in run
update()
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 223, in update
self.update_core()
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 228, in update_core
in_arrays = self.converter(batch, self.device)
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/dataset/convert.py", line 93, in concat_examples
[example[i] for example in batch], padding[i])))
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/dataset/convert.py", line 35, in to_device
return cuda.to_gpu(x, device)
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/backends/cuda.py", line 275, in to_gpu
return _array_to_gpu(array, device_, stream)
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/backends/cuda.py", line 322, in _array_to_gpu
return cupy.asarray(array)
File "/home/denko/anaconda3/lib/python3.6/site-packages/cupy/creation/from_data.py", line 61, in asarray
return core.array(a, dtype, False)
File "cupy/core/core.pyx", line 2070, in cupy.core.core.array
File "cupy/core/core.pyx", line 2101, in cupy.core.core.array
Will finalize trainer extensions and updater before reraising the exception.
Traceback (most recent call last):
File "train.py", line 81, in <module>
train()
File "train.py", line 69, in train
trainer.run()
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 313, in run
six.reraise(*sys.exc_info())
File "/home/denko/anaconda3/lib/python3.6/site-packages/six.py", line 693, in reraise
raise value
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/trainer.py", line 299, in run
update()
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 223, in update
self.update_core()
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/training/updater.py", line 228, in update_core
in_arrays = self.converter(batch, self.device)
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/dataset/convert.py", line 93, in concat_examples
[example[i] for example in batch], padding[i])))
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/dataset/convert.py", line 35, in to_device
return cuda.to_gpu(x, device)
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/backends/cuda.py", line 275, in to_gpu
return _array_to_gpu(array, device_, stream)
File "/home/denko/anaconda3/lib/python3.6/site-packages/chainer/backends/cuda.py", line 322, in _array_to_gpu
return cupy.asarray(array)
File "/home/denko/anaconda3/lib/python3.6/site-packages/cupy/creation/from_data.py", line 61, in asarray
return core.array(a, dtype, False)
File "cupy/core/core.pyx", line 2070, in cupy.core.core.array
File "cupy/core/core.pyx", line 2101, in cupy.core.core.array
ValueError: Unsupported dtype object
コード
--dataset_for_rr--
import numpy as np
import chainer
from PIL import Image
from chainer import cuda, Variable
class rrDataset(chainer.dataset.DatasetMixin):
def __init__(self,l,r,inf,outf):
self.rr_list = np.load('/media/denko/OS/data/rr_list/test.npy')
self.l = l
self.r = r
self.inf = inf
self.outf = outf
self.flames = self.inf + self.outf
self.num = self.r - self.l
self.xp = cuda.cupy
def __len__(self):
return self.num
def get_example(self,i):
self.ind = self.l + i
self.data = np.empty((self.flames,1,256,320),dtype=np.float32)
for j in range(self.flames):
self.bmp_name = str(int(self.rr_list[self.ind][j]))
self.year = self.bmp_name[0:4]
self.month = self.bmp_name[4:6]
self.path = '/media/denko/OS/data/bmp/' + self.year + '/' + self.month + '/' + self.bmp_name + '.bmp'
self.bmp_data = Image.open(self.path)
self.bmp_data = np.array(self.bmp_data).astype(dtype=np.float32)
self.bmp_data = self.bmp_data / 255
self.data[j,0,:,:] = self.bmp_data
self.data = Variable(np.array(self.data,dtype=np.float32))
return self.data[:self.inf,0,:,:], self.data[self.inf:self.flames,0,:,:]