1 Star 0 Fork 0

天空的蔚蓝/FinRL-Meta

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test.py 1.29 KB
一键复制 编辑 原始数据 按行查看 历史
Mohammad Momayezi 提交于 2022-09-19 06:39 . Update test.py (#231)
# use three drl libraries: elegantrl, rllib, and SB3
from agents.elegantrl_models import DRLAgent as DRLAgent_erl
from agents.rllib_models import DRLAgent as DRLAgent_rllib
from agents.stablebaselines3_models import DRLAgent as DRLAgent_sb3
def test(drl_lib, env, model_name, **kwargs):
# load elegantrl needs state dim, action dim and net dim
net_dimension = kwargs.get("net_dimension", 2**7)
cwd = kwargs.get("cwd", "./" + str(model_name))
if drl_lib == "elegantrl":
episode_total_assets = DRLAgent_erl.DRL_prediction(
model_name=model_name,
cwd=cwd,
net_dimension=net_dimension,
environment=env,
)
return episode_total_assets
elif drl_lib == "rllib":
# load agent
episode_total_assets = DRLAgent_rllib.DRL_prediction(
model_name=model_name,
env=env,
agent_path=cwd,
)
return episode_total_assets
elif drl_lib == "stable_baselines3":
episode_total_assets = DRLAgent_sb3.DRL_prediction_load_from_file(
model_name=model_name, environment=env, cwd=cwd
)
return episode_total_assets
else:
raise ValueError("DRL library input is NOT supported. Please check.")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/fanchuan/FinRL-Meta.git
[email protected]:fanchuan/FinRL-Meta.git
fanchuan
FinRL-Meta
FinRL-Meta
master

搜索帮助