Тёмный

Deep Reinforcement Learning Tutorial for Python in 20 Minutes 

Nicholas Renotte
Подписаться 273 тыс.
Просмотров 211 тыс.
50% 1

Worked with supervised learning?
Maybe you’ve dabbled with unsupervised learning.
But what about reinforcement learning?
It can be a little tricky to get all setup with RL. You need to manage environments, build your DL models and work out how to save your models down so you can reuse them. But that shouldn’t stop you!
Why?
Because they’re powering the next generation of advancements in IOT environments and even gaming and the use cases for RL are growing by the minute. That being said, getting started doesn’t need to be a pain, you can get up and running in just 20 minutes working with Keras-RL and OpenAI.
In this video you’ll learn how to:
1. Create OpenAI Gym environments like CartPole
2. Build a Deep Learning model for Reinforcement Learning using Tensorflow and Keras
3. Train a Reinforcement Learning model using Deep Q Policy based learning using Keras-RL
Github Repo for the Project: github.com/nicknochnack/Tenso...
Want to learn more about it all:
Open AI Gym: gym.openai.com/envs/
Keras RL: keras-rl.readthedocs.io/
Oh, and don't forget to connect with me!
LinkedIn: / nicholasrenotte
Facebook: / nickrenotte
GitHub: github.com/nicknochnack
Happy coding!
Nick
P.s. Let me know how you go and drop a comment if you need a hand!
Music by Lakey Inspired
Chill Day - • LAKEY INSPIRED - Chill...

Наука

Опубликовано:

 

28 авг 2020

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 458   
@prhmma
@prhmma 3 года назад
nice pace and simple work through, love it man.
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much 🙏! Got another run of RL tutorials coming up soon!
@andreapalladino7999
@andreapalladino7999 Год назад
The best tutorial on how to start with reinforcement learning that I have ever seen!
@bogdanoleinikov8002
@bogdanoleinikov8002 3 года назад
Thanks for explaining the code, I saw this example online already but with the step by step explanation of this scenario it was much better for learning while running the code alongside the video :)
@NicholasRenotte
@NicholasRenotte 3 года назад
Heya @Bogdan, thanks so much! I'm building up to more sophisticated examples of RL. I'll be doing a lot more with different environments in the coming months!
@MK-ol9gv
@MK-ol9gv 3 года назад
I usually don't write comments on RU-vid videos but wow! I've watched some of your videos and they are extremely helpful. The number of views on this video and subscribes on your channel are so underrated thx for the great content and hope u keep making good videos like this one!
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much for your kind words @M K! Truly appreciate it!
@raihankhanphotography6041
@raihankhanphotography6041 3 года назад
I am so glad I stumbled across your channel. Best tutorial ever! THANK YOU!!!
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks sooo much @Raihan!
@mohammedbasheer581
@mohammedbasheer581 3 года назад
Thank you Nic! Very helpful of you to make such informative videos for all! Wish you lots of success and joy!
@NicholasRenotte
@NicholasRenotte 3 года назад
Thank you so much @Mohammed!!
@jumiduss
@jumiduss 2 года назад
Commenting for the algorithm. Started looking into deep learning recently and eventually got here, great intro and explanations. Looking forward to the other videos
@NicholasRenotte
@NicholasRenotte 2 года назад
Thanks so much!! Whatcha working on?
@oleksiy2090
@oleksiy2090 3 года назад
I do not know what to say. I think closes words what can describe my feelings now are "wow, that was amazing and very very simple that even I understood what is going on there". Going to play with code and try to solve more problems. I wish I found your channel earlier. 👍🏻
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much @Alex, you've found it now 😊! I've got way more reinforcement learning and game AI coming in the coming weeks!
@BRUNO12059
@BRUNO12059 3 года назад
I am from Brazil and your video was very useful for me !!! I hope you to continue to make more videos like that. Great video !!
@NicholasRenotte
@NicholasRenotte 3 года назад
Glad you liked it @Bruno! Definitely, got a special one on Reinforcement Learning coming up!
@Patiencelad
@Patiencelad 3 года назад
Great video. Thanks for explaining everything with the step by step. Excellent Job!
@NicholasRenotte
@NicholasRenotte 3 года назад
Anytime! A heap more rl videos coming, it's going to be a big focus this year!
@RajaSekharaReddyKaluri
@RajaSekharaReddyKaluri 2 года назад
Thank you! This would be my first motivation to explore RL!
@tomgolf2624
@tomgolf2624 3 года назад
Thank you Nicholas.. Your video is very informative, nice pace and entertaining. I am now hooked with RL.
@NicholasRenotte
@NicholasRenotte 3 года назад
Thank you so much @Tom 🙏
@coded6799
@coded6799 3 года назад
For your content, 6.5k subs are too little. I have been scouring the internet for reinforcement learning courses ever since AlphaGo beat the world champion, and today I found your video. And I'm glad I did.
@NicholasRenotte
@NicholasRenotte 3 года назад
Yooo, thanks so much! I've got a bunch more RL stuff coming soon!
@coded6799
@coded6799 3 года назад
@@NicholasRenotte Cool!
@freydunthanos3155
@freydunthanos3155 3 года назад
Seriously, I'm recommending this channel to my data science class
@NicholasRenotte
@NicholasRenotte 3 года назад
@@freydunthanos3155 yesss, thanks so much!
@rmt3589
@rmt3589 3 года назад
A Go fan. Didn't expect to see another person of culture here.
@supankanlavanathan463
@supankanlavanathan463 10 месяцев назад
Video Summary (Made with HARPA AI):- 00:30 🧠 Core concept: "Area 51" summarizes Action, Reward, Environment, and Agent in reinforcement learning. 01:00 🐍 Python setup: Use OpenAI Gym, TensorFlow, Keras to create and train reinforcement learning models. 04:52 🏞 Gym environment setup: Import dependencies, set up the environment, and extract states and actions. 08:27 🧠 Build deep learning model: Construct a model with TensorFlow and Keras. 13:48 🤖 Train the model: Compile and train with KerasRL, monitor progress. 15:06 🎯 Test the model: Evaluate performance in the Gym environment. 17:30 💾 Save and reload weights: Save and reload model weights. 19:49 🔃 Reuse the model: Rebuild, load weights for further testing or deployment.
@paulburnett1963
@paulburnett1963 Год назад
Sweet.. love the explanation.. That was a lot to take in but what a clean explanation... Thanks for the video. paul.
@siddharthmanumusic
@siddharthmanumusic 2 месяца назад
Thank you!!! You rock! Such a well made video! Short and fully informative.
@alexeysmirnov1678
@alexeysmirnov1678 2 года назад
Superclear! Keep doing your stuff, man!
@BrunoVasco
@BrunoVasco 3 года назад
Thanks man! Nice pace and objectiveness.
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much @Bruno!
@islam6916
@islam6916 3 года назад
Thank you so much ❤ searched a lot for that kind of video and finally found a good one 👏
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks sooo much! There's some more reinforcement learning stuff coming this week, hopefully a video on Atari and (assuming my GPU doesn't catch fire) one on CARLA!
@islam6916
@islam6916 3 года назад
@@NicholasRenotte looking forward to seeing that
@NicholasRenotte
@NicholasRenotte 3 года назад
@@islam6916 awesome stuff!!
@omarsinno2774
@omarsinno2774 3 года назад
Really nice and simple explanation. Cheers!
@NicholasRenotte
@NicholasRenotte 3 года назад
YESS! Thanks @Omar, glad you enjoyed it!
@choptran
@choptran 3 года назад
Thank you for such simple and easy to follow video. 🙏
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much @Chop, glad you enjoyed it!
@edzme
@edzme 3 года назад
You're a great teacher thanks for making these!!
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much @Ed, glad you're enjoying them!
@sagnikroy6405
@sagnikroy6405 3 месяца назад
I watch your videos and feel like you taught us a very important topic like no one did. I do believe this is how no one shouldn't. Better to follow written documentations!!!
@MaximeAntoine97
@MaximeAntoine97 3 года назад
Awesome video! I just started my master in AI and seeing your videos helps a lot to remember a couple “key” things before the start of the semester! I also just started a YT channel, if you’re down we could maybe see how we could create something together, might be fun! Have a good day 👋🏼
@NicholasRenotte
@NicholasRenotte 3 года назад
Hey thanks co much @Maxime, glad you enjoyed the video!
@gusinthecloud
@gusinthecloud 3 года назад
great job, ypu saved me a lot of time. Support from Argentina!!
@kashyapbrahmandam3586
@kashyapbrahmandam3586 5 месяцев назад
Bro's got a taste for classic music. Beethoven and Dvorak in the beginning. Nice!!
@whataday3910
@whataday3910 3 года назад
Hey! Thanks for the video. I would love to see how I can solve a problem with my own environment. Or how to build a specific environment and an agent with specific actions. I am at the moment not familiar with OpenAI but I think it would be interesting to see something more custom. :)
@NicholasRenotte
@NicholasRenotte 3 года назад
Heya @WhataDay, check this out: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-bD6V3rcr_54.html
@tzhern
@tzhern 3 года назад
short and clear! thanks a lot!
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much @Tom!
@Andy-rq6rq
@Andy-rq6rq 3 года назад
great tutorial! keep making more
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much @Andy, definitely plenty more coming!
@sdtcuce
@sdtcuce 3 года назад
Wow! such a wonderful lessons with practical example. I loved it. I want to learn more about self control action mechanism for multivariate industrial control using RL. Kindly put some light on it
@NicholasRenotte
@NicholasRenotte 3 года назад
Nice, got more RL stuff coming in the weeks coming @Suvankar!
@_FLOROID_
@_FLOROID_ Год назад
As far as I can tell this tutorial sadly is already outdated since some of the API has changed now and some functions may require different arguements. And updated version of this tutorial would be great!
@peter-holzer-dev
@peter-holzer-dev Год назад
Amazing video, thanks! 🥳
@muditrustagi5775
@muditrustagi5775 3 года назад
great job man love from India !
@abramswee
@abramswee 2 года назад
great video! thanks for sharing.
@richard_franks
@richard_franks Год назад
tl;dr if you're watching this in 2022, make sure you pip install gym==0.17.1. I'm sure this is due to the age of this video/updated code being released, but I had the following errors in case anyone else comes across this. First was - ValueError: too many values to unpack (expected 4) - for the line n_state, reward, done, info = env.step(action). For some reason adding a 5th parameter so it looked like this - n_state, reward, done, info, test = env.step(action) - made it pass. Next was ValueError: Error when checking input: expected flatten_input to have shape (1, 4) but got array with shape (1, 2) on line dqn.fit(env, nb_steps=50000, visualize=False, verbose=1). I was able to fix this by downgrading to python 3.8, downgrading protobuf to 3.9.2, and explicitly installing the versions of all traces found in the pip install trace of the jupyter notebook. When I changed the gym version to the one found in the video, it allowed env.step(action) to actually take 4 parameters, instead of the 5th I had to add in to make it pass, and the code ran. After all that I went back to python 3.10, explicitly installed gym 0.17.0, then installed keras, keras-rl2, and tensorflow, and it worked again. Thanks for the video, the issues obviously aren't your fault, just wanted to pass this info off. I learned a ton about pip, library versions, and all kinds of other stuff in this process.
@CrossyChainsaw
@CrossyChainsaw Год назад
This worked for me aswell i downgraded protobuff which downgraded tensorflow aswell. After i upgraded tensorflow to the correct version and everything worked. I think the origin of the problem is not having the correct version of TensorFlow in the first place
@dineshkrishnasamy1628
@dineshkrishnasamy1628 Год назад
Nice content. We're waiting for ML trader series... thank you
@thiennguyenthanh5004
@thiennguyenthanh5004 3 года назад
Thank you so much for this video!
@NicholasRenotte
@NicholasRenotte 3 года назад
Anytime!
@xinanwang9379
@xinanwang9379 2 года назад
Hi Nick, Thanks for your tutorial, it really helped me kick off the field of RL. There is an issue of the keras-rl2 package you used, specifically the NAFAgent, which fails all the time even using the example given in the official repo. Could you please spare some time and take a look at it? Many thanks and wish your channel gets better and better! Best, Tony
@neelkanthbhavnagarwala6001
@neelkanthbhavnagarwala6001 Год назад
When I try to run "dqn.fit(env,nb_steps...)" command I am getting ValueError : Error when checking input : expected flatten_2_input to have shape (1,4) but got array with (1,2) can you please help me out??
@varunsharma7706
@varunsharma7706 3 года назад
It brings tears to my eyes😂😂 Awesome
@NicholasRenotte
@NicholasRenotte 3 года назад
Yesss! Thanks for checking it out @Varun!
@pranavprasad5661
@pranavprasad5661 3 года назад
@Nicholas Renotte This is such a well-explained video! Thanks for making it, I was looking for something exactly like this. I wanted to know whether you can make a video on custom environments using different types of observation_spaces and action_spaces (Discrete, Box, Dict, MultiDiscrete). I am trying this for a problem and I'm struggling a bit to understand how to use Dict and MultiDiscrete, most examples use Box and Discrete.
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks @Pranav, definitely will do! Got it on the list!
@housseynenadour2233
@housseynenadour2233 3 года назад
Thank you brother, really helpful
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much @Housseyne!
@McRookworst
@McRookworst 3 года назад
Great video! Got it up and running in no time. One question tough: What exactly does the value of 4 out of env.observation_space.shape[0] represent? Isn't the state supposed to be a pixel vector? Or is this some kind of abstraction openAI makes?
@NicholasRenotte
@NicholasRenotte 3 года назад
Heya @McRookworst, for CartPole we don't use a pixel vector (moreso used in the Atari envs). In CartPole the four values represented in from the observation space are: [position of cart, velocity of cart, angle of pole, rotation rate of pole].
@khalidbinhida
@khalidbinhida 2 года назад
Excellent sir!
@user-vc5kp1tl8r
@user-vc5kp1tl8r 2 года назад
Hello, please let us know if you can use deep reinforcement learning in classification problems.
@alishafii9141
@alishafii9141 22 дня назад
I like you, your video and your teach. keep go on
@MrDaFuxae
@MrDaFuxae Год назад
Hi Nocholas, you did a great job there, thanks for sharing your knowledge! I would like to mention, that in my case I had a problem running the code, because I got a value error in the line "n_state, reward, done, info = env.step(action)". Adding a fifth value "observation" on the left side (so that it looks like "n_state, reward, done, info, observation = env.step(action)" got the code up and running :-) Nevertheless your videos are really helpful and please keep going! You're doing an amazing job!
@FrancescoPalazzo26
@FrancescoPalazzo26 Год назад
dude I can't import the agents and policies, basically keras doesn't have rl.policy or even rl.agents, what should I do?
@Nobske
@Nobske Год назад
# new version with terminated and truncated episodes = 10 for episode in range(1, episodes+1): state = env.reset() #initial for each episode terminated = False score = 0 while not terminated: env.render() # render the CartPole action = random.choice([0,1]) # 0,1 left or right observation, reward, terminated, truncated ,info = env.step(action) score+=reward #based on our step we get a reward till it's done print('Episode:{} Score:{}'.format(episode, score)) Docs observation (object) - this will be an element of the environment’s observation_space. This may, for instance, be a numpy array containing the positions and velocities of certain objects. reward (float) - The amount of reward returned as a result of taking the action. terminated (bool) - whether a terminal state (as defined under the MDP of the task) is reached. In this case further step() calls could return undefined results. truncated (bool) - whether a truncation condition outside the scope of the MDP is satisfied. Typically a timelimit, but could also be used to indicate agent physically going out of bounds. Can be used to end the episode prematurely before a terminal state is reached. info (dictionary) - info contains auxiliary diagnostic information (helpful for debugging, learning, and logging). This might, for instance, contain: metrics that describe the agent’s performance state, variables that are hidden from observations, or individual reward terms that are combined to produce the total reward. It also can contain information that distinguishes truncation and termination, however this is deprecated in favour of returning two booleans, and will be removed in a future version.
@MrDaFuxae
@MrDaFuxae Год назад
@@FrancescoPalazzo26 I had the same problem. In my case I could solve it by importing the modules from a different path, which is 'tensorflow.python'. so the import commands look Like 'from tensor flow.python.keras.models import sequential'. Hope this solves your problem!
@ashkanforootan
@ashkanforootan Год назад
episodes = 10 for episode in range(1, episodes+1): state = env.reset() terminated = False score = 0 while not terminated: env.render() action = random.choice([0,1]) n_state, reward, terminated, truncated, info = env.step(action) score+=reward print('Episode:{} Score:{}'.format(episode, score)) run these for new versions
@GeraLdario
@GeraLdario Год назад
If you get "ValueError: Error when checking input: expected flatten_input to have shape (1, 4) but got array with shape (1, 2)", Install the package 'rl-agents==0.1.1'. It works for me.
@amoghlakkanagavi10
@amoghlakkanagavi10 Год назад
yoooo thanks mate
@NingAaron
@NingAaron Год назад
Your video is amazing! You make learning RL fun! However, I have some questions, maybe some rookie-type questions, about the best strategy for reinforcement learning, can I just extract this part, such as a vehicle turning right at an intersection, and then turning left is its best path, Can I extract only this one path among many paths? Or is it possible to convert the results of RL into text? Does this RL training log include the actions selected for these trainings? Please take the time to take a look, thank you very much!
@salmankhalildurrani
@salmankhalildurrani Год назад
can you please guide me solve the problem I am getting while working on this example TyperError: _set_agent() missing 1 required positional argument: 'agent'
@Officialnorio
@Officialnorio 3 года назад
Hey there! I am having the same issue with *'Sequential' object has no attribute '_compile_time_distribution_strategy'* but in my case *del model* doesn't help at all. If i want to delete it before *model = build_model(states, actions) I receive the error that I want to refer to a var before declaring it (which makes total sense to me xD). Any ideas how to fix this? :) btw. this video is amazing! Keep the good work up :)
@NicholasRenotte
@NicholasRenotte 3 года назад
Heya @Norio! Try deleting it then running the cell that creates the model again. I show it here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-hCeJeq8U0lo.html
@Officialnorio
@Officialnorio 3 года назад
@@NicholasRenotte didn't work for me. But thanks for your help :/ I now use Tensorforce and don't have any problems :D
@NicholasRenotte
@NicholasRenotte 3 года назад
@@Officialnorio awesome work! What did you think of Tensorforce, I checked it out earlier on but switched to stable baselines a little later on!
@Officialnorio
@Officialnorio 3 года назад
@@NicholasRenotte Sometimes my code threw some weird output but changing the agent-type fixed it. Tensorforce is pretty easy to use and does its job (so far) pretty well. I am using Tensorforce for my bachelor thesis about MTSP solutions :D
@NicholasRenotte
@NicholasRenotte 3 года назад
@@Officialnorio awesome, will need to give it a second chance!
@RaviKumar-ub2ng
@RaviKumar-ub2ng 2 года назад
Hi, what an amazing video! You are a great teacher and you make the learning of RL fun! However, I have some question and it might be some rookies type of questions because i am not that experience with python. You said that we can reload the trained model, but how can i do it in VSC? Create a new Python file and import the one we created? And also, when i run the " _ = dqn.test(env, nb_episodes=15, visualize=True)" and want to change episodes(just for testing), it has to go through the process all over again, but in your case it just used the rewards already generated and printed it right away. These questions might be so easy that maybe someone in the comments can provide an answer. Thanks :)
@NicholasRenotte
@NicholasRenotte 2 года назад
Should be able to reload the weights by running this when you open up again: dqn.load_weights('dqn_weights.h5f') Then to chaneg the number of episodes just change the number set to nb_episodes e.g. For 30 episodes run this: _ = dqn.test(env, nb_episodes=30, visualize=True) For 40 episodes run ghit: _ = dqn.test(env, nb_episodes=40, visualize=True)
@lahaale5840
@lahaale5840 3 года назад
Nice introduction. It seems the DQN method is value-based even you are using BoltzmanQPolicy. BoltzmanQPolicy is like epsilon-greedy, a method to balance exploitation and exploration. Methods like DPG, PPO, A2C, and DDP can be considered as policy-based methods.
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks for tuning in @Laha, good to note!
@tommclean9208
@tommclean9208 3 года назад
If anyone had the same issue as me, using keras-rl saying that model has no attribute __len__, I just modified the model code to: def build_model(states, actions): model = Sequential() model.add(Flatten(input_shape=(1, states))) model.add(Dense(23, activation='relu')) model.add(Dense(23, activation='relu')) model.add(Dense(actions, activation='linear')) model.__len__=actions return model and it worked (notice the additional line model.__len__ = actions Probably not the best practice, but worked without having to downgrade tensorflow
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much for helping out the fam @Tom!
@raencarve4
@raencarve4 3 года назад
Awensome job. Thanks
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much @Rafael!
@junjieshi3900
@junjieshi3900 2 года назад
Geat video! As a starting learner, I have one stupid question here: how can we build a model that can hanld 2-dimensional state, e.g., recording several histirucal data, or even 3-dimensional state data?
@ahmedwaly9073
@ahmedwaly9073 3 года назад
Wooow this is an awesome tutorial
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much @Ahmed!! 🙏
@Guskiller1
@Guskiller1 3 года назад
Wow, this was very interesting. Great video. I've been interested in trying to use Deep-RL on android games. Do you know how one could go about this? I was thinking of using screenshots as inputs to the DQN. i'd have to create a custom environment, right? Is this something you are familiar with? Thanks again for the video.
@NicholasRenotte
@NicholasRenotte 3 года назад
Yo @Gustavo Lorentz! Ya, you'd need a custom environment. You could also try out some of the pre-built games from OpenAI though as a kick start, LMK if you want me to make a video on doing it with games! Also, looks like there's a ton of third party envs you could use as a baseline though:github.com/openai/gym/blob/master/docs/environments.md#third-party-environments
@Guskiller1
@Guskiller1 3 года назад
@@NicholasRenotte that sounds like a good video, I'd watch it! I'll try building my own custom environment. Thanks for answering :)
@NicholasRenotte
@NicholasRenotte 3 года назад
@@Guskiller1 anytime, I've got it on the list for some future videos now!
@sarnathk1946
@sarnathk1946 Год назад
Thanks , awesome 🙏🙏
@BilalKhan-sx9eu
@BilalKhan-sx9eu 3 года назад
Best crash course ever :D
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks sooo much @Bilal, check this out as well :) ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-Mut_u40Sqz4.html
@InteliDey
@InteliDey 2 года назад
Hi Nicholas, why did you use "linear" as the activation function in your last layer instead of "softmax"? How would it differ if I choose "softmax" as activation function instead of linear for this case? Will it be possible to mention this, please? Or may be make a video on it? (When to choose linear and softmax activation function for what type of target cases)
@xnyu254
@xnyu254 Год назад
softmax is great for classification, but the experiment shown in the video is more of a regression problem. In this case, it makes more sense to use linear. Doesn't mean you can't use softmax, but your dqn will most likely don't work as you would expect it.
@70ME3E
@70ME3E Месяц назад
@@xnyu254 here you have two states as the output (either go left or go right). It _is_ a classification problem, and not a regression one at all.
@Rose-ro7wz
@Rose-ro7wz 3 года назад
Thank you for the video, would you please make a video about DDPG?
@krvignesh6323
@krvignesh6323 2 года назад
Great tutorial Nic.. I was trying to implement this and encountered an error when I run the line "dqn.compile(Adam(lr=1e-3),metrics=['mae'] Error: 'Sequential' object has no attribute '_compile_time_distribution_strategy'. Can someone help me resolving this?
@josefelgueiras8404
@josefelgueiras8404 2 года назад
Great tutorial. Is there a way to graphically visualize the convergence of the agent's scores throughout training? Or should I just use a longer method like alternatively training the agent for, say, 1000 steps and then use agent.test() to get some scores for validation. My goal here would basically be to have a robust method for training an agent while observing its progress throughout the training process.
@NicholasRenotte
@NicholasRenotte 2 года назад
Take a look at the full rl course on the channel, progress it output via Tensorboard.
@imedcherif8134
@imedcherif8134 3 года назад
Thank you for nice videos
@NicholasRenotte
@NicholasRenotte 3 года назад
Anytime @Imed, glad you enjoyed it!
@Mokaigo
@Mokaigo Год назад
nice try David Goggins ;) Thx Alot !
@jeferson1556
@jeferson1556 Год назад
Fr😂😂
@igorperessinotto5774
@igorperessinotto5774 3 года назад
Great video! Quick question: how can I ask the model for the actions he took during the tests? Is there a way of getting a list or an array of all the left/right choices he makes?
@NicholasRenotte
@NicholasRenotte 3 года назад
I don't think it's available through Keras-RL but if you work with the environment directly you can get it based on the generated action. Want a video on it @Igor?
@igorperessinotto5774
@igorperessinotto5774 3 года назад
@@NicholasRenotte I was able to improvise by making him print the action in the env.render(), so I use visualize = True when testing and it returns the action taken in each step. I guess it kinda works. Thanks!
@NicholasRenotte
@NicholasRenotte 3 года назад
@@igorperessinotto5774 awesome, glad you got a workaround!
@skippergiggletush8739
@skippergiggletush8739 2 года назад
The video could have been better, by talking a bit more about the input. But overall, it's a great video. Thank you for your time!
@manishalifestyle7863
@manishalifestyle7863 2 года назад
Sir can you please help me in doing MountainCar-v0 and frozenLake as well because these not have same properties as cartpole
@abdikarimibrahim7078
@abdikarimibrahim7078 3 года назад
Thank you for the amazing content. I would like to know how to define multiple agents? As an example, if we have an environment with more than one agent taking action, how we can define the other agents and return their value?
@NicholasRenotte
@NicholasRenotte 3 года назад
Heya @Abrikarim, working on something in this space now. Will share it once it's ready :)
@abdikarimibrahim7078
@abdikarimibrahim7078 3 года назад
@@NicholasRenotte Thank you. Can't wait for it, because am doing my PhD on multi-agent deep reinforcement learning, so am excited for this.
@NicholasRenotte
@NicholasRenotte 3 года назад
@@abdikarimibrahim7078 woah, awesome space to be working in!
@abdikarimibrahim7078
@abdikarimibrahim7078 3 года назад
@@NicholasRenotte yeah, thanks alot
@jubeyerrahman8310
@jubeyerrahman8310 2 года назад
Hi, I was wondering if I want to retrieve all the states and actions in the testing phase what is the way of doing it. For example, you have tested it for 5 episodes so how can I retrieve all the states and actions corresponding to those 5 episodes?
@oneredpanda9933
@oneredpanda9933 Год назад
I keep running into errors because I don't have the right things downloaded. Ive been trying to to fix it for about an hour now and I can't figure it out! If anyone has done this more recent than 2020, and would be willing to help me I would greatly appreciate it. Thanks so much!
@Umidyor
@Umidyor Год назад
Hi, what version of python and tensorflow did you use to use these tensorflow and keras libraries?
@mrwallstreet3438
@mrwallstreet3438 3 года назад
Hi Nicholas thanks again for your videos , i have learn and start coding , with your help , since 3 to 4 weeks now ...., and i am loving it ... thanks ....can you do a videos with capsule net .... greetings God bless you Bro
@NicholasRenotte
@NicholasRenotte 3 года назад
Woah, thanks so much! Awesome to hear about your journey, any particular use case you were looking at with a capsule net?
@mrwallstreet3438
@mrwallstreet3438 3 года назад
@@NicholasRenotte You are welcome Nicholas , all the credit is to you , because you explain us ,what you are doing and why you are doing it , so thanks again :-)) Regarding the capsule Net , can we use this example ( lucenaresearch.com/2019/07/15/capsule-networks-deep-learning-for-stock-forecasting/ ) for time series classification just for BUY and SELL pictures from TRADING CHART with the OS and CV2 importation folder. Looking forward for your reply .... Greetings
@NicholasRenotte
@NicholasRenotte 3 года назад
@@mrwallstreet3438 definitely, might need to do some research into it. But I'll take a look!
@mrwallstreet3438
@mrwallstreet3438 3 года назад
@@NicholasRenotte , thanks very much , looking forward to that , since then , i will keep learning with your videos , thanks again , bro !!!
@ASDFAHED1985
@ASDFAHED1985 3 года назад
Thanks, it is great video
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks so much @Mustafa!
@javierlemus9
@javierlemus9 2 года назад
Hello, would you be able to make a video on this but using the mountain car scenario? I am trying to follow this using the mountain car but it does not work :(
@premithmendis8004
@premithmendis8004 3 года назад
Just awesome
@NicholasRenotte
@NicholasRenotte 3 года назад
Thank you so much @Premith!
@srirams9482
@srirams9482 2 года назад
Hi @Nicholas Renotte, I am new to this ...The code works fine however i don't see the graphics of the CartPole as you see in this video. How do i get that as an output ?
@wilamshields
@wilamshields 6 месяцев назад
Thank you for replying to my previous comment on how out of date this code is, can not be used
@fatemehkiaie7612
@fatemehkiaie7612 3 года назад
Hi. Great Video. I am wondering to know if it is possible to create a custom environment?
@NicholasRenotte
@NicholasRenotte 3 года назад
Sure is! Check this out @Fatemeh: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-bD6V3rcr_54.html
@AldorCrap
@AldorCrap Год назад
Awesome video, I have question, How would I define a model with a dynamic action_space? like the actions possible to make are gonna dependent on the current state, I defined the Env to do this by simply redefine the action_space on the step() function. But how do I proceed when declaring the model? (and the following agent?)
@JonCianci12
@JonCianci12 10 месяцев назад
I don't think that is possible and also I don't think that will achieve your desired outcome. You can define the action space as just about anything from discrete options to box shapes (x and y) or even combinations of the two from my limited understanding. Could you give an example of your desired action space in a given moment?
@abdelmalekdjamaa7691
@abdelmalekdjamaa7691 3 года назад
Hi 👋 Can you make a Q learning agent with just Keras and Tensorflow ? Creating the agent seems more interesting ⚡
@NicholasRenotte
@NicholasRenotte 3 года назад
Definitely, I've got the code 80% of the way there! Should be out in the coming weeks!
@rezagolipour9821
@rezagolipour9821 2 года назад
Hi, thank you for the video. My question is : is there any specific reason behind you have installed Tensorflow 2.3.0? Can version 2.9.0 work without error?
@jakes-dev1337
@jakes-dev1337 7 месяцев назад
Did ya try it? Try things.
@Tprakh-iw6qt
@Tprakh-iw6qt 6 месяцев назад
Very helpful but could not understand how to visualize the Cart Pole animation. Please let me know how to visualize it
@MaximePerrain
@MaximePerrain 2 года назад
Hi Nicholas, thanks for all your greats video. i've problem with this line of code : model = build_model(states, actions) only integer scalar arrays can be converted to a scalar index and Error converting shape to a TensorShape: only integer scalar arrays can be converted to a scalar index. do you have an idea of what can be the issue?
@NicholasRenotte
@NicholasRenotte 2 года назад
If you sample your states what does it look like? Are they non-integer values?
@01bit
@01bit 3 года назад
this is perfect!!!
@NicholasRenotte
@NicholasRenotte 3 года назад
Thanks a bunch @01bit!
@haniehamiri6640
@haniehamiri6640 Год назад
I have a question! how can we see every action and states in each episode ? this shows just the final score of each episode but we can not see what's happening during episode?
@wtf9693
@wtf9693 Год назад
brother, can you please explain those parameters in sequentialmemory and dqnagent.. like, what is limit ? and window length ?? and steps_warmup ??
@user-bi2yd2lc6e
@user-bi2yd2lc6e Год назад
Hi Nick .Thanks for your tutorial it really helps me a lot.However , i am getting an error saying :"ValueError: Error when checking input: expected flatten_input to have shape (1, 4) but got array with shape (1, 2)",So ,i am wondering why this error didn't happen in your case
@vietle6099
@vietle6099 Год назад
I'm having the same issue
@evolutionXXVII
@evolutionXXVII Год назад
Did you ever find a solution to this issue? I'm having the same problem.
@GeraLdario
@GeraLdario Год назад
Install the package 'rl-agents==0.1.1'. It works for me.
@sebastianrada4107
@sebastianrada4107 6 месяцев назад
@@GeraLdario It worked!
@yalcinimeryuz5414
@yalcinimeryuz5414 2 года назад
Great video! However, I am getting an error saying "TypeError: only integer scalar arrays can be converted to a scalar index" on the line "model.add(Flatten(input_shape=(1, states)))". How do I solve this?
@thiagobastani6663
@thiagobastani6663 Год назад
The variable states is probably not an integer scalar array. are you testing the same eviroment?
@salmankhalildurrani
@salmankhalildurrani Год назад
can you please guide me solve the problem I am getting while working on this example TyperError: _set_agent() missing 1 required positional argument: 'agent'
@erfanbayat3974
@erfanbayat3974 Год назад
loved it
@AnkitSharma-lh6rf
@AnkitSharma-lh6rf 2 года назад
Hey Nick! How do i give custom policy here like if i want to use my version of epsilon greedy policy how to do that?
@Bobstrer
@Bobstrer 3 года назад
Hi Nicholas, Thank you so much for the great content! I'm running into an error "AttributeError: 'Sequential' object has no attribute '_compile_time_distribution_strategy'" I couldn't really find anything online to help me solve it, do you have any idea where this is from? thank you!
@NicholasRenotte
@NicholasRenotte 3 года назад
Heya @Olivier, try running del model, then rerunning the cell that creates your model.
@adrianchervinchuk5632
@adrianchervinchuk5632 3 года назад
@@NicholasRenotte it worked for me, but why it acts in such a strange way?
@NicholasRenotte
@NicholasRenotte 3 года назад
@@adrianchervinchuk5632 I think there is conflict between tensorflow and keras. Seems to happy pretty frequently.
@ka1zoku-o
@ka1zoku-o 11 месяцев назад
Could anyone please explain or provide some resource on how we will handle a situation in which the action space is also continuous??
@randomizer272
@randomizer272 3 года назад
Hello, Thanks for the great tutorial step by step video. Quick question. When I run dqn.fit(env, nb_steps = 50000, visualize = False, verbose = 1), I get this error: "'Sequential' object has no attribute '_compile_time_distribution_strategy'". How do I overcome this? and why did this happen? Thanks again
@randomizer272
@randomizer272 3 года назад
I checked your other video. Deleting the model and reloading the kernel works. This comment is for anyone with same issues
@NicholasRenotte
@NicholasRenotte 3 года назад
Awesome work @Sriram, yep that's the solution the majority of the time!
@ts717
@ts717 3 года назад
@@randomizer272 thank you for your answer, i have the same problem. But my knowledge is still quite limited so i don't know how i delete my model and reload the kernel. Would be nice if you could explain it a little bit more. Thanks in advance!
@randomizer272
@randomizer272 3 года назад
@@ts717 You can just do a new line del model and create the model again. It worked for me fine. I will attach the video in which he explained about this error. ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-hCeJeq8U0lo.html
@rodolpheredoute809
@rodolpheredoute809 3 года назад
in the section "def build_model" you have to change the line : model = Sequential() into : model = tensorflow.keras.models.Sequential() i checked and it seems that's because python can misinterpret it with keras, and not tensorflow's keras (but i have no clue why) this worked for me
@alimashoud6294
@alimashoud6294 11 месяцев назад
Hy! Nice video, How would we do it in PyTorch? Please make a video on deep Reinforcement Learning with PyTorch as well. Cheers!
@richchizzl5020
@richchizzl5020 3 года назад
Great video! Can you explain the target model update + the 10_000 displayed by Keras in the verbosity? It seems like, the target model still updates every 10.000 steps, even though the target model update was set to a soft rate of 0.001. What am I missing? :D
@NicholasRenotte
@NicholasRenotte 3 года назад
Heya @Richchizzl, this is due to a DQN being an off-policy reinforcement learning algorithm. When you train, there are actually two models being trained in tandem, one is consistently being trained based on the latest values (think of this one as a fast learner) the other is being used to generate the next set of states (think of this one as a slow learner). Every 10,000 steps the model weights from the fast learner are copied over the the slow learner, this helps ensure you get more reliable training.
@richchizzl5020
@richchizzl5020 3 года назад
Thank's a lot for your reply! Do you know, if it's possible to change the mark of 10,000 steps within the keras framework? I'm trying to implement the connectx kaggle challenge and it seems like that a slowly increasing reward is completely shaken after the update of the slow learner...
@NicholasRenotte
@NicholasRenotte 3 года назад
@@richchizzl5020 hmmm, did you try changing that parameter? TBH, I'm now using stable baselines over kerasl-rl as it actually seems, well, a lot more stable. You can set the target model update frequency for a DQN pretty easily using the target_network_update_freq parameter: stable-baselines.readthedocs.io/en/master/modules/dqn.html I did a bit of a crash course on setting up experiments with it here: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-nRHjymV2PX8.html could swap out the algorithm used there for a DQN and set the paramater there.
@muhammadattaurrahman1365
@muhammadattaurrahman1365 Год назад
Model output "Tensor("dense_2/BiasAdd:0", shape=(?, 2), dtype=float32)" has invalid shape. DQN expects a model that has one dimension for each action, in this case 2. How to fix this issue sir?
@abulfahadsohail466
@abulfahadsohail466 2 года назад
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none) ERROR: No matching distribution found for tensorflow this error is showing while instaling
@adrian46647
@adrian46647 6 месяцев назад
had issues with rendering on m2 chip. Those pips helped !pip install tensorflow==2.13.0 !pip install gym==0.25.2 !pip install numpy==1.24.4 !pip install keras==2.10.0 !pip install keras-rl2==1.0.5 !pip uninstall protobuf -y & pip install protobuf==3.20.0 !pip install "gym[classic-control]" !pip install tflearn !pip install ipywidgets !pip install matplotlib pyglet !pip install pygame !pip install numpy --upgrade
@frankgiardina1360
@frankgiardina1360 3 года назад
Thanks Nicholas i use colab and will try TF 2.3.1
@NicholasRenotte
@NicholasRenotte 3 года назад
Awesome @Frank, let me know how you go!
@hardikkamboj3528
@hardikkamboj3528 3 года назад
Hey Frank, I am also using Colab but facing a lot of difficulties in rendering gym. can you please help me with that @Frank
@NicholasRenotte
@NicholasRenotte 3 года назад
@@hardikkamboj3528 hmmm, I normally avoid colab for that reason. Rendering anything outside of the notebook is problematic. You can try training on Colab then rendering on your local machine.
@hardikkamboj3528
@hardikkamboj3528 3 года назад
@@NicholasRenotte thanks a lot mate. I have started reinforcement learning, following your videos. Awesome work mate, really appreciate it
@hardikkamboj3528
@hardikkamboj3528 3 года назад
@@NicholasRenotte I will try it
Далее
An introduction to Reinforcement Learning
16:27
Просмотров 649 тыс.
🤡Украли У ВСЕХ🤪
00:37
Просмотров 156 тыс.
AI Learns to Walk (deep reinforcement learning)
8:40
Has Generative AI Already Peaked? - Computerphile
12:48
I Built a Neural Network from Scratch
9:15
Просмотров 215 тыс.
КРУТОЙ ТЕЛЕФОН
0:16
Просмотров 6 млн