chickenbestlover / RNN-Time-series-Anomaly-Detection

RNN based Time-series Anomaly detector model implemented in Pytorch.
Apache License 2.0
1.17k stars 316 forks source link

1_train_predictor --save_fig error #21

Open drpetershaw opened 5 years ago

drpetershaw commented 5 years ago

When i use:

!python /content/drive/My\ Drive/PlasmaSimAI/RNN/1_train_predictor.py --data ecg --filename chfdbchf15.pkl --save_fig

in Google colab the following error occurs:

=> Start training from scratch

Namespace(augment=True, batch_size=64, bptt=50, clip=10, data='ecg', device='cuda', dropout=0.2, emsize=32, epochs=50, eval_batch_size=64, filename='chfdbchf15.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=True, save_interval=10, seed=1111, teacher_forcing_ratio=0.7, tied=False, weight_decay=0.0001)

| epoch 1 | 10/ 31 batches | ms/batch 133.2217 | loss 2.27 | epoch 1 | 20/ 31 batches | ms/batch 117.8518 | loss 1.95 | epoch 1 | 30/ 31 batches | ms/batch 117.6507 | loss 2.02

| end of epoch 1 | time: 4.70s | valid loss 1.6075 |

Traceback (most recent call last): File "/content/drive/My Drive/PlasmaSimAI/RNN/1_train_predictor.py", line 326, in generate_output(args,epoch,model,gen_dataset,startPoint=1500) File "/content/drive/My Drive/PlasmaSimAI/RNN/1_train_predictor.py", line 141, in generate_output target= preprocess_data.reconstruct(gen_dataset.cpu().numpy(), TimeseriesData.mean, TimeseriesData.std) File "/content/drive/My Drive/PlasmaSimAI/RNN/preprocess_data.py", line 18, in reconstruct return seqData*std+mean TypeError: mul(): argument 'other' (position 1) must be Tensor, not numpy.ndarray

When you remove --save_fig the code works as expected. Is this a bug or am i doing something wrong?

drpetershaw commented 5 years ago

Further digging makes me believe that it may be an issue with Pytorch compatibility as i have Pytorch Version=1.0.0

chickenbestlover commented 5 years ago

I tried to run this code in 1.0.0 with the --save_fig option and the same error occurred.

chickenbestlover commented 5 years ago

It seems that the error occurred because multiplication between Numpy array and Pytorch tensor is deprecated in Pytorch 1.0.0. I have fixed the error so check it out.