AI4Finance-Foundation / FinRL

FinRL: Financial Reinforcement Learning. 🔥
https://ai4finance.org
MIT License
9.93k stars 2.4k forks source link

Error: element 0 of tensors does not require grad and does not have a grad_fn #459

Closed ghaffari903 closed 2 years ago

ghaffari903 commented 2 years ago

Anyone can help how to resolve this error, eleganrRL and ray are ok! but stable_baseline3

error

Athe-kunal commented 2 years ago

The total time steps should be an integer, not float value 1e4. So type cast it to int(1e4) and pass to total timesteps

ghaffari903 commented 2 years ago

thank you, without changing any thing sometimes it works, sometimes it doesn't,

@Athe-kunal 1- do you have any demo to elegantrl agents parameter optimaztion? 2- It seems models dont use indicatores, how can i see it more precisely? 3- and why any change in break_step doesnt effect on train time and results(how to realy increase episodes)?

Athe-kunal commented 2 years ago

Hi @ghaffari903

  1. I will be working on an HPO pipeline for ElegantRL shortly and will mention it in the group after developing it
  2. Can you please provide more information on this
  3. Not very well versed in ElegantRL, but try to change the total_steps. Not sure, please ask in the ElegantRL repo
ghaffari903 commented 2 years ago

Hi, @Athe-kunal, thank you

777

ElegantRL+ ==============Get Backtest Results=========== Annual return -0.421698 Cumulative returns -0.454655 Annual volatility 0.460959 Sharpe ratio -0.961994 Calmar ratio -0.630856 Stability 0.297484 Max drawdown -0.668454 Omega ratio 0.858203 Sortino ratio -1.356868 Skew NaN Kurtosis NaN Tail ratio 0.993333 Daily value at risk -0.059835 dtype: float64

ElegantRL ==============Get Backtest Results=========== Annual return -0.421698 Cumulative returns -0.454655 Annual volatility 0.460959 Sharpe ratio -0.961994 Calmar ratio -0.630856 Stability 0.297484 Max drawdown -0.668454 Omega ratio 0.858203 Sortino ratio -1.356868 Skew NaN Kurtosis NaN Tail ratio 0.993333 Daily value at risk -0.059835 dtype: float64

tic:XTP.csv length:2609 Shape of DataFrame: (279, 10) Annual return -0.245044 Cumulative returns -0.267442 Annual volatility 0.266308 Sharpe ratio -0.925726 Calmar ratio -0.518248 Stability 0.223953 Max drawdown -0.472831 Omega ratio 0.861573 Sortino ratio -1.234706 Skew NaN Kurtosis NaN Tail ratio 0.837889 Daily value at risk -0.034530 dtype: float64

ElegantRL+ uses fundamntal indicators but ElegantRL uses technical indicators!!!!!!!!!!!!!!!!!! it seems none of them is used and changing training timesteps doesnt work!

Do you suggest I use stable_baseline3 instead of elegant? stable_baseline3 sometimes shows "Error: element 0 of tensors does not require grad and does not have a grad_fn" What is the difference between them?

ghaffari903 commented 2 years ago

@BruceYanghy would you please help to handle this error?

"element 0 of tensors does not require grad and does not have a grad_fn"

ghaffari903 commented 2 years ago

Any help is appreciated

ghaffari903 commented 2 years ago

Dears, I fixed the error! error