You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jupyter运行交易强化学习代码遇stable_baselines系列错误求助

交易强化学习代码迁移问题
  • 运行一份交易强化学习Jupyter代码时,原导入语句触发ModuleNotFoundError:
    from stable_baselines.common.vec_env import DummyVecEnv
    from stable_baselines import A2C
    
  • 得知stable_baselines已被stable_baselines3替代,安装stable_baselines3后修改导入代码为:
    from stable_baselines3.common.vec_env import DummyVecEnv
    from stable_baselines3 import A2C
    
  • 但执行模型初始化代码model = A2C('MlpLstmPolicy', env, verbose=1)时触发ValueError,报错栈信息如下:
    ValueError                                Traceback (most recent call last)
    Input In [84], in <cell line: 1>()
    ----> 1 model = A2C('MlpLstmPolicy', env, verbose=1) 
          2 model.learn(total_timesteps=1000000)
    
    File /Applications/Anaconda/anaconda3/lib/python3.9/site-packages/stable_baselines3/a2c/a2c.py:85, in A2C.__init__(self, policy, env, learning_rate, n_steps, gamma, gae_lambda, ent_coef, vf_coef, max_grad_norm, rms_prop_eps, use_rms_prop, use_sde, sde_sample_freq, normalize_advantage, tensorboard_log, create_eval_env, policy_kwargs, verbose, seed, device, _init_setup_model)
         60 def __init__(
         61     self,
         62     policy: Union[str, Type[ActorCriticPolicy]],
       (...)
         82     _init_setup_model: bool = True,
         83 ):
    ---> 85     super().__init__(
    

内容的提问来源于stack exchange,提问作者Unagi71

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 19:31:02