sunnyswag / StockRL

在A股(股票)市场上训练强化学习交易智能体
GNU General Public License v3.0
190 stars 81 forks source link

module 'stable_baselines3.common.logger' has no attribute 'record' #1

Closed ttys0001 closed 2 years ago

ttys0001 commented 3 years ago

File "E:\software\nutshell\stock_research\强化学习\code\RL_in_Stock\utils\env.py", line 281, in step return self.return_terminal(reward=self.get_reward()) File "E:\software\nutshell\stock_research\强化学习\code\RL_in_Stock\utils\env.py", line 190, in return_terminal logger.record("environment/GainLoss_pct", (gl_pct - 1) * 100) AttributeError: module 'stable_baselines3.common.logger' has no attribute 'record'

大佬想请教一下这个bug如何解决啊?

查了一下是因为stable_baselines3更新了,来源:https://github.com/AI4Finance-LLC/FinRL/issues/239,但是没找到在哪里改,麻烦大佬了

sunnyswag commented 3 years ago

如果着急用的话,可以先把 logger.record 注释掉,这个 repo 有定义自己的 log 输出

ttys0001 commented 3 years ago

感谢,另外想问问大佬训练每个模型大概花了多久啊?我自己训练发现很慢,感觉没用上GPU嗯

sunnyswag commented 3 years ago

48 h 吧,其实没有完全训练好,可以用 matpool 试试 用没用 GPU 可以看日志的

ttys0001 commented 3 years ago

感谢大佬,还想问问大佬几个问题

  1. 请问大佬用的什么 GPU 训练需要 48H 啊,以及这几个模型都是 48H 吗?
  2. 之前在 Release 看您说的三个算法 (SAC, TD3, DDPG) 的回测结果均做了一次修改,想问问是什么修改啊?
  3. 大佬我检查了一下日志,日志中并没有提示是否有用到 GPU 啊,是否还需要在代码中哪里手动设置需要 GPU 呢?
  4. 大佬还想请问下目前看来,这几个模型的效果有可能放到实盘中去运行吗?
sunnyswag commented 3 years ago

1、K80 跑的(因为便宜),都是48H,控制变量 2、修改了一次波动较大的值 3、不需要手动设置,你去搜搜 tf 或者 torch 的 GPU 检测命令,stable-baseline3 都已经设置好了 4、你可以试试 PPO 多线程的效果,其他的不建议进一步尝试

zhnagchulan commented 2 years ago

File "E:\software\nutshell\stock_research\强化学习\code\RL_in_Stock\utils\env.py", line 281, in step return self.return_terminal(reward=self.get_reward()) File "E:\software\nutshell\stock_research\强化学习\code\RL_in_Stock\utils\env.py", line 190, in return_terminal logger.record("environment/GainLoss_pct", (gl_pct - 1) * 100) AttributeError: module 'stable_baselines3.common.logger' has no attribute 'record'

大佬想请教一下这个bug如何解决啊?

查了一下是因为stable_baselines3更新了,来源:https://github.com/AI4Finance-LLC/FinRL/issues/239,但是没找到在哪里改,麻烦大佬了!

一个可行的解决方案: 注释这一行:from stable_baselines3.common import logger 替换为:from stable_baselines3.common import utils logger = utils.configure_logger()