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

Runtime error running example #45

Open
kb1ooo opened this issue Nov 5, 2020 · 3 comments
Open

Runtime error running example #45

kb1ooo opened this issue Nov 5, 2020 · 3 comments

Comments

@kb1ooo
Copy link

kb1ooo commented Nov 5, 2020

Just trying one of the ECG examples and getting a runtime error. I'm running pytorch 1.5.

$ python 1_train_predictor.py --data ecg --filename chfdb_chf01_275.pkl --emsize 128 --nhid 128 --save_fig --epoch 600
=> Start training from scratch
-----------------------------------------------------------------------------------------
Namespace(augment=True, batch_size=64, bptt=50, clip=10, data='ecg', device='cuda', dropout=0.2, emsize=128, epochs=600, eval_batch_size=64, filename='chfdb_chf01_275.pkl', log_interval=10, lr=0.0002, model='LSTM', nhid=128, nlayers=2, prediction_window_size=10, pretrained=False, res_connection=False, resume=False, save_fig=True, save_interval=10, seed=1111, teacher_forcing_ratio=0.7, tied=False, weight_decay=0.0001)
-----------------------------------------------------------------------------------------
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/home/marc/dev/RNN-Time-series-Anomaly-Detection/1_train_predictor.py in <module>
    318 
    319             epoch_start_time = time.time()
--> 320             train(args,model,train_dataset,epoch)
    321             val_loss = evaluate(args,model,test_dataset)
    322             print('-' * 89)

/home/marc/dev/RNN-Time-series-Anomaly-Detection/1_train_predictor.py in train(args, model, train_dataset, epoch)
    226             outSeq1 = torch.cat(outVals,dim=0)
    227             hids1 = torch.cat(hids1,dim=0)
--> 228             loss1 = criterion(outSeq1.view(args.batch_size,-1), targetSeq.view(args.batch_size,-1))
    229 
    230             '''Loss2: Teacher forcing loss'''

RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.
@lzt-pro
Copy link

lzt-pro commented Nov 9, 2020

I have the same problem. Do you find the way to love it?

@kb1ooo
Copy link
Author

kb1ooo commented Nov 10, 2020

@lzt-pro yes. Lines 228, 232, 279, 283 change occurrences of .view to .contiguous().view

@gireeshkbogu
Copy link

gireeshkbogu commented Nov 19, 2020

I get this error when I change the view to contiguous

(base)a@x86_64-apple-darwin13 RNN-Time-series-Anomaly-Detection-master %  python 1_train_predictor.py --data nyc_taxi --filename nyc_taxi.pkl --device cpu
=> Start training from scratch
-----------------------------------------------------------------------------------------
Namespace(augment=True, batch_size=64, bptt=50, clip=10, data='nyc_taxi', device='cpu', dropout=0.2, emsize=32, epochs=400, eval_batch_size=64, filename='nyc_taxi.pkl', log_interval=10, lr=0.0002, model='LSTM', nhid=32, nlayers=2, prediction_window_size=10, pretrained=False, res_connection=False, resume=False, save_fig=False, save_interval=10, seed=1111, teacher_forcing_ratio=0.7, tied=False, weight_decay=0.0001)
-----------------------------------------------------------------------------------------
Traceback (most recent call last):
  File "1_train_predictor.py", line 320, in <module>
    train(args,model,train_dataset,epoch)
  File "1_train_predictor.py", line 235, in train
    loss3 = criterion(hids1(args.batch_size,-1), hids2(args.batch_size,-1).detach())
TypeError: 'Tensor' object is not callable

BApplB added a commit to BApplB/RNN-Time-series-Anomaly-Detection that referenced this issue Mar 17, 2021
Fix to a RunTime error which occurs when running the training for PyTorch 1.6.

chickenbestlover#45
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