Closed muzaffersenkal closed 5 years ago
This problem usually occurs if you try to reshape a Variable not a Cupy array, you can try to determine whether rois
is a Variable at the time you are calling reshape
.
This problem usually occurs if you try to reshape a Variable not a Cupy array, you can try to determine whether
rois
is a Variable at the time you are callingreshape
.
Thank you, I changed that block :
if rois.__class__.__name__ == "ndarray":
_, num_channels, height, width = rois.shape
rois = self.xp.reshape(rois,(num_timesteps, -1, num_channels, height, width))
for i, roi in enumerate(rois, start=1):
roi_image = self.variable_to_image(roi[0])
paste_location = i * image.width, 0
dest_image.paste(roi_image.resize((self.image_size.width, self.image_size.height)), paste_location)
It works now. Isn't that the way it is?
the more interesting question is, whether the variable rois
always contains a Variable
or if this just happens some times. If it is always a Variable, you can just access the ndarray
by writing rois.array
You are right @Bartzi . I have checked. rois
always contains a Variable
. So I just access with rois.array
.
Final code
def render_extracted_regions(self, dest_image, image, rois, num_timesteps):
_, num_channels, height, width = rois.array.shape
rois = self.xp.reshape(rois.array,(num_timesteps, -1, num_channels, height, width))
for i, roi in enumerate(rois, start=1):
roi_image = self.array_to_image(roi[0])
paste_location = i * image.width, 0
dest_image.paste(roi_image.resize((self.image_size.width, self.image_size.height)), paste_location)
Also i changed roi_image = self.array_to_image(roi[0])
it was accessing self.variable_to_image
.
By the way, it just happen to me ? Why did I get this error?
Thanks
I think it happens because you are using Chainer and Cupy 6.4. They changed something in the newer versions, so that some functions automatically produce a Variable
.
It makes sense. Thank you :)
Hi all,
python3 chainer/train_svhn.py datasets/svhn/curriculum.json logs --char-map datasets/svhn/svhn_char_map.json --blank-label 0 -b 16 --gpu 0
When i train with svhn datasets , I'm getting this error
Exception in main training loop: reshape() got an unexpected keyword argument 'order' Traceback (most recent call last):............................] 0.05% File "/usr/local/lib/python3.5/dist-packages/chainer/training/trainer.py", line 319, in run entry.extension(self)imated time to finish: 0:00:00. File "/home/user/Desktop/see/chainer/insights/bbox_plotter.py", line 128, in __call__ self.render_rois(predictions, rois, bboxes, iteration, self.image.copy(), backprop_vis=backprop_visualizations) File "/home/user/Desktop/see/chainer/insights/bbox_plotter.py", line 143, in render_rois self.render_extracted_regions(dest_image, image, rois, num_timesteps) File "/home/user/Desktop/see/chainer/insights/bbox_plotter.py", line 201, in render_extracted_regions rois = self.xp.reshape(rois,(num_timesteps, -1, num_channels, height, width)) File "/usr/local/lib/python3.5/dist-packages/cupy/manipulation/shape.py", line 33, in reshape return a.reshape(newshape, order=order) TypeError: reshape() got an unexpected keyword argument 'order'
I know it's about cupy.
Versions: Chainer == 6.4 cupy-cuda101 ? 6.4 Cuda compilation tools, release 10.1, V10.1.243
I couldnt fix this issue . But when i do comment this line
rois = self.xp.reshape(rois,(num_timesteps, -1, num_channels, height, width))
(and below for loop ) in bbox_plotter.py . Training works fine. How can i fix this error ?if I don't run this function(in bbox ) , will it have an effect on the result?