Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with tensor's view? #2

Closed
mckeown12 opened this issue Jun 21, 2018 · 3 comments
Closed

problem with tensor's view? #2

mckeown12 opened this issue Jun 21, 2018 · 3 comments

Comments

@mckeown12
Copy link

I am attempting to run the following:

<python 1_train_predictor.py --data nyc_taxi --filename nyc_taxi.pkl
Here is the traceback:

Traceback (most recent call last): File "1_train_predictor.py", line 322, in <module> train(args,model,train_dataset,epoch) File "1_train_predictor.py", line 230, in train loss1 = criterion(outSeq1.view(args.batch_size,-1), targetSeq.view(args.batch_size,-1)) RuntimeError: invalid argument 2: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Call .contiguous() before .view(). at /Users/soumith/code/builder/wheel/pytorch-src/aten/src/TH/generic/THTensor.cpp:280

Any ideas?

@chickenbestlover
Copy link
Owner

chickenbestlover commented Jun 21, 2018

Since I do not get the error on my computer, I have no idea why the error occurred.
But contiguous error is easy to fix. try this:
loss1 = criterion(outSeq1.contiguous().view(args.batch_size,-1), targetSeq.contiguous().view(args.batch_size,-1))

@jcardenaslie
Copy link

@chickenbestlover The fix worked for me. Thank you!

@mckeown12
Copy link
Author

mckeown12 commented Jun 25, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants