ChenFeng87 / network_inference

2 stars 1 forks source link

RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead #3

Closed gui11aume closed 2 years ago

gui11aume commented 2 years ago

When I run python predict_stable_state.py in the MISA repository after following the instructions, I get the error below. I am using Python3.8, and numpy version 1.22.3. Are they the right versions?

python predict_stable_state.py

---------- Use this part to predict the steady state ----------

--   You need to wait about 120 seconds

----------   import the DNN model  ----------

----------   import DNN is finish  ----------

----------   prediction the time serie by DNN  ----------
Traceback (most recent call last):
  File "predict_stable_state.py", line 69, in <module>
    yy1 = np.array(y)
  File "/home/gfilion/miniconda3/envs/temp/lib/python3.8/site-packages/torch/tensor.py", line 486, in __array__
    return self.numpy()
RuntimeError: Can't call numpy() on Variable that requires grad. Use var.detach().numpy() instead.
ChenFeng87 commented 2 years ago

We have modified the code so that it works with python 3.8. Thank you very much for your comments.