Comments (1)
There is also a bug in train function of Sarsa.ipynb . action = agent.sample(state) after while True should be deleted.
Correct code is:
def train(cfg,env,agent):
print('开始训练!')
print(f'环境:{cfg.env_name}, 算法:{cfg.algo_name}, 设备:{cfg.device}')
rewards = [] # 记录奖励
for i_ep in range(cfg.train_eps):
ep_reward = 0 # 记录每个回合的奖励
state = env.reset() # 重置环境,即开始新的回合
action = agent.sample(state)
while True:
#action = agent.sample(state) should be deleted
next_state, reward, done, _ = env.step(action) # 与环境进行一次动作交互
next_action = agent.sample(next_state)
agent.update(state, action, reward, next_state, next_action,done) # 算法更新
state = next_state # 更新状态
action = next_action
ep_reward += reward
if done:
break
rewards.append(ep_reward)
print(f"回合:{i_ep+1}/{cfg.train_eps},奖励:{ep_reward:.1f},Epsilon:{agent.epsilon}")
print('完成训练!')
return {"rewards":rewards}
from easy-rl.
Related Issues (20)
- 随书代码在哪 HOT 6
- 第五章勘误 HOT 1
- 内容勘误? HOT 3
- 添加参考文献 HOT 1
- SAC代码问题 HOT 2
- 4.3 REINFORCE:蒙特卡洛策略梯度 HOT 1
- 最新的版本,可以出PDF吗 HOT 2
- value_iteration 算法不收敛 ? HOT 1
- 错别字 HOT 2
- DuelingDQN.ipynb中可能存在的两个BUG~
- 我在运行DQN代码时,初始的state总会多一个值。
- 图6.8左下角标识应该是“动作价值(Q)”? HOT 1
- DDPG算法实现出现问题
- 关于书中DDPG算法的疑问
- PPO算法的实现, 为啥要给概率取对数? HOT 2
- 连续动作空间的PPO算法 HOT 2
- dqn算法问题
- 纸质版是怎么做的? HOT 1
- 关于条件全期望公式的推导的问题 HOT 1
- notebooks/Q-learning/QLearning.ipynb的绘图代码存在一个小瑕疵 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easy-rl.