Comments (2)
THat's our mistake, we relied on a deprecated function from earlier pandas versions. Try this:
from pandas import DataFrame
moving_average = lambda x, span: DataFrame({'x':np.asarray(x)}).x.ewm(span=span).mean().values
We've also updated it on github
from practical_rl.
that worked, but a span value should be passed to the moving_average lambda function, here is the cell code that made it work
`
from IPython.display import clear_output
from pandas import DataFrame
moving_average = lambda x, span: DataFrame({'x':np.asarray(x)}).x.ewm(span=span).mean().values
rewards_sarsa, rewards_ql = [], []
for i in range(5000):
rewards_sarsa.append(play_and_train(env, agent_sarsa))
rewards_ql.append(play_and_train(env, agent_ql))
#Note: agent.epsilon stays constant
if i %100 ==0:
clear_output(True)
print('EVSARSA mean reward =', np.mean(rewards_sarsa[-100:]))
print('QLEARNING mean reward =', np.mean(rewards_ql[-100:]))
plt.title("epsilon = %s" % agent_ql.epsilon)
plt.plot(moving_average(rewards_sarsa,100), label='ev_sarsa')
plt.plot(moving_average(rewards_ql,100), label='qlearning')
plt.grid()
plt.legend()
plt.ylim(-500, 0)
plt.show()
`
from practical_rl.
Related Issues (20)
- Remove mentions of python2 from week7/practice
- PyTorch notebooks should detect GPU and run on it if it's available
- Backport changes from PyTorch version of DQN Atari into the TF notebook
- Complete code HOT 1
- Week 1: Incorrect "Reflecting on results" HOT 2
- Colab no longer bundles Atari ROMs in their Gym installation HOT 1
- The links can't be opened now HOT 2
- class DQN uses global variable in assert
- CrossEntropy Exercise not working despite every step being marked as correct HOT 1
- Week2 Seminar-VI frozen lake problem HOT 1
- Equation of state-action value function in seminar_vi week 02 HOT 2
- Can I get answer for my confusion in week07_seq2seq/practice_torch
- In Coursera branch, why do the last commit deleted the grading module for week1? HOT 2
- Issue with Slides in Materials of #4 HOT 5
- Videos of Week 05 have issues of not being shown
- Is it still possible to submit assignments to coursera? HOT 5
- `week09_policy_II` – `trpo` slides has an invalid link HOT 4
- Questioning Regards Conjugate Gradient Algorithm HOT 1
- week06_policy_based - invalid link
- The link for OpenAI recommended reading material is not working anymore
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 practical_rl.