dong_iccv_2017 icon indicating copy to clipboard operation
dong_iccv_2017 copied to clipboard

ValueError: some of the strides of a given numpy array are negative.

Open XinCynthia opened this issue 6 years ago • 9 comments

I have successfully run train_text_embedding_flowers.sh, but when I run train_flowers.sh there is an error like following: Traceback (most recent call last): File "/home/xin/PycharmProjects/newcolorchage/train.py", line 149, in preprocess(img, desc, len_desc, txt_encoder) File "/home/xin/PycharmProjects/newcolorchage/train.py", line 68, in preprocess desc[sorted_indices, ...].transpose(0, 1), ValueError: some of the strides of a given numpy array are negative. This is currently not supported, but will be added in future releases.

could you please tell me why this happened? Thank you very much!

XinCynthia avatar Aug 07 '18 01:08 XinCynthia

I got an IndexError when I tried to run train_text_embedding_flowers.sh, as the raw_desc in read_lua_file.py is NoneType. It has bothered me for a long time.

zhouqzzw avatar Dec 05 '18 01:12 zhouqzzw

@rookie-zzw Could you elaborate your issue? e.g. stack traces.. I made this code long time ago, so detailed description would help me understand the issue.

woozzu avatar Dec 06 '18 15:12 woozzu

@woozzu Thank you very much for your reply. Stack traces are as follows: Traceback (most recent call last): File "D:/code/code for Semantic Image Synthesis via Adversarial Learning/train_text_embedding.py", line 80, in std=[0.229, 0.224, 0.225]) File "D:\code\code for Semantic Image Synthesis via Adversarial Learning\data.py", line 31, in init self.data = self._load_dataset(img_root, caption_root, classes_fllename, word_embedding) File "D:\code\code for Semantic Image Synthesis via Adversarial Learning\data.py", line 46, in _load_dataset desc, len_desc = self._get_word_vectors(raw_desc, word_embedding) File "D:\code\code for Semantic Image Synthesis via Adversarial Learning\data.py", line 57, in _get_word_vectors for i in range(desc.shape[1]): IndexError: tuple index out of range

zhouqzzw avatar Dec 10 '18 01:12 zhouqzzw

@rookie-zzw I have no problem when running it on my machine. Can you describe about your environment? e.g. python/pytorch version. And, did you accurately follow the README?

BTW, if you are interested in related projects like this, please check out our recent paper (TAGAN)

woozzu avatar Dec 10 '18 04:12 woozzu

@woozzu I use python 3.5.2 and pytorch 0.4.1 on my machine, and I do follow the README. Surprising, I just read the paper you mentioned a few days ago! It is very meaningful and it is worth learning.

zhouqzzw avatar Dec 10 '18 04:12 zhouqzzw

@rookie-zzw hmm.. that's strange. Can you confirm that raw_desc in this line is None? If so, I think the dataset might be the problem. Please double check the paths in CONFIG, or re-download the dataset.

woozzu avatar Dec 10 '18 05:12 woozzu

@woozzu I tried the solution you suggested, but every time I step through that line, I get the following error: Unable to display children: Error resolving variables Trackback(most recent call last): File "C:\Program Files\JetBrains\PyCharm 2017.3\helpers\pydev_pydevd_bundle\pydevd_comm.py", line 1029, in do_it _typeName, val_dict = pydevd_vars.resolve_compound_variable(self.thread_i, self.frame_id, self.scope, self.attributes) TypeError: 'NoneType' object is not iterable

zhouqzzw avatar Dec 11 '18 01:12 zhouqzzw

@rookie-zzw I'm sorry but I can't reproduce your error. If you can use pdb or something for debugging, printing any suspicious variables might be helpful to find the culprit.

woozzu avatar Dec 11 '18 03:12 woozzu

I had the same error and and was able to fix it by copying the numpy array (the indices are thus turned positive) :

packed_desc = nn.utils.rnn.pack_padded_sequence(
        desc[sorted_indices.copy(), ...].transpose(0, 1),
        len_desc[sorted_indices]

IvonaTau avatar Jun 07 '19 12:06 IvonaTau