Git Product home page Git Product logo

Comments (16)

jcjohnson avatar jcjohnson commented on September 26, 2024 1

@AishaAlaagib The underlying root cause here is that this code was written using a very old version of PyTorch (I think maybe 0.2?), and there have been a bunch of breaking changes to PyTorch since then which means that the code makes many assumptions about the shapes and types of tensors which will not hold in more recent PyTorch releases.

For this error in particular, the module network implements forward passes for a couple different types of program representations, and tries to route to the correct implementation based on the type and shape of the program object: https://github.com/facebookresearch/clevr-iep/blob/master/iep/models/module_net.py#L233.

In this case, it looks like this line got executed: https://github.com/facebookresearch/clevr-iep/blob/master/iep/models/module_net.py#L234 (which expects the program to be in some JSON format); however based on your output from print(f) I think your program is actually a 2D tensor, so this line should have executed: https://github.com/facebookresearch/clevr-iep/blob/master/iep/models/module_net.py#L236 (which assumes the program is stored as a tensor).

You should debug around here to see why the wrong branch of this condition executed.

from clevr-iep.

GGaoYipeng avatar GGaoYipeng commented on September 26, 2024

I'm getting the same error.. Were you able to fix it ?

from clevr-iep.

1245994042 avatar 1245994042 commented on September 26, 2024

I'm getting the same error.. Were you able to fix it ?

sorry. I don't fix it. If u solve it, plz help me to do this.

from clevr-iep.

GGaoYipeng avatar GGaoYipeng commented on September 26, 2024

okay, I will try.

from clevr-iep.

1245994042 avatar 1245994042 commented on September 26, 2024

from clevr-iep.

GGaoYipeng avatar GGaoYipeng commented on September 26, 2024

I have sent an email to you.

from clevr-iep.

1245994042 avatar 1245994042 commented on September 26, 2024

我已向您发出电子邮件。

But i didn't get any email…

from clevr-iep.

yizhouzhao avatar yizhouzhao commented on September 26, 2024

change the seq2seq.py > function reinforce_sample > forloop into

for t in range(T):
# logprobs is N x 1 x V
logprobs, h, c = self.decoder(encoded, cur_input, h0=h, c0=c)
logprobs = logprobs / temperature
probs = F.softmax(logprobs.view(N, -1),dim=None) # Now N x V
if argmax:
_, cur_output = probs.max(1)
cur_output = cur_output.unsqueeze(0)
else:
cur_output = probs.multinomial() # Now N x 1
self.multinomial_outputs.append(cur_output)
self.multinomial_probs.append(probs)
cur_output_data = cur_output.data.cpu()
#not_done = logical_not(done)
not_done= np.where(done.data.cpu().numpy() == 0)
#y[:, t][not_done] = cur_output_data[not_done]
y[not_done, t] = cur_output_data[not_done]
done = logical_or(done, cur_output_data.cpu() == self.END)
cur_input = cur_output
if done.sum() == N:
break

from clevr-iep.

PuPuLL avatar PuPuLL commented on September 26, 2024

Hi
i got same issue
have u solve it ?
if you did plz let me know
Thanks!

from clevr-iep.

yizhouzhao avatar yizhouzhao commented on September 26, 2024

@PuPuLL I have solved it. My above comment is the code. The problem is that the different supports of indexing a tensor array in Pytorch 0.1 and Pytorch 0.4.

from clevr-iep.

1245994042 avatar 1245994042 commented on September 26, 2024

@PuPuLL I have solved it. My above comment is the code. The problem is that the different supports of indexing a tensor array in Pytorch 0.1 and Pytorch 0.4.

OK,I will try it. Thx!

from clevr-iep.

1245994042 avatar 1245994042 commented on September 26, 2024

change the seq2seq.py > function reinforce_sample > forloop into

for t in range(T):

logprobs is N x 1 x V

logprobs, h, c = self.decoder(encoded, cur_input, h0=h, c0=c)
logprobs = logprobs / temperature
probs = F.softmax(logprobs.view(N, -1),dim=None) # Now N x V
if argmax:
_, cur_output = probs.max(1)
cur_output = cur_output.unsqueeze(0)
else:
cur_output = probs.multinomial() # Now N x 1
self.multinomial_outputs.append(cur_output)
self.multinomial_probs.append(probs)
cur_output_data = cur_output.data.cpu()
#not_done = logical_not(done)
not_done= np.where(done.data.cpu().numpy() == 0)
#y[:, t][not_done] = cur_output_data[not_done]
y[not_done, t] = cur_output_data[not_done]
done = logical_or(done, cur_output_data.cpu() == self.END)
cur_input = cur_output
if done.sum() == N:
break

sorry,I just got the message.
Thx!

from clevr-iep.

PuPuLL avatar PuPuLL commented on September 26, 2024

@PuPuLL I have solved it. My above comment is the code. The problem is that the different supports of indexing a tensor array in Pytorch 0.1 and Pytorch 0.4.

that works! thank you

from clevr-iep.

AishaAlaagib avatar AishaAlaagib commented on September 26, 2024

Hi,

I am using python 3.4 and pytorch 1.1.0
I got the same error like yours and I fix it after I got error

Traceback (most recent call last):
File "clevr-iep/iep/train_model.py", line 490, in
main(args)
File "clevr-iep/iep/train_model.py", line 151, in main
train_loop(args, train_loader, val_loader)
File "clevr-iep/iep/train_model.py", line 240, in train_loop
scores = execution_engine(feats_var, programs_pred)
File "/home/aalaagib/anaconda3/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/home/aalaagib/data/clevr-iep/iep/models/module_net.py", line 239, in forward
final_module_outputs = self._forward_modules_json(feats, program)
File "/home/aalaagib/data/clevr-iep/iep/models/module_net.py", line 171, in _forward_modules_json
f_str = programs.function_to_str(f)
File "/home/aalaagib/data/clevr-iep/iep/programs.py", line 129, in function_to_str
if f['value_inputs']:
IndexError: too many indices for tensor of dimension 1

I have print f which is
tensor([28, 4, 21, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], device='cuda:0')
I hope if someone can help me
Thanks.

from clevr-iep.

AishaAlaagib avatar AishaAlaagib commented on September 26, 2024

@jcjohnson Thanks alot. you are right the problem in the pytorch version.
I have reshape the program first and made this change
elif type(program) is torch.Tensor and program.dim() <= 2:
final_module_outputs = self._forward_modules_ints(feats, program)

So it works now. Thanks again.

from clevr-iep.

luyishisi avatar luyishisi commented on September 26, 2024

我解决了这个问题,现在他可以很好的run在torch1.7 以及cuda 11以上版本了
I solved this problem, now he can run well on torch1.7 and cuda 11 and above
https://github.com/luyishisi/clevr-iep

from clevr-iep.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.