Intro – Training a neural network to play a game with TensorFlow and Open AI




[ad_1]

This tutorial mini series is focused on training a neural network to play the Open AI environment called CartPole.

The idea of CartPole is that there is a pole standing up on top of a cart. The goal is to balance this pole by wiggling/moving the cart from side to side to keep the pole balanced upright.

Sample code: https://pythonprogramming.net/openai-cartpole-neural-network-example-machine-learning-tutorial/
https://twitter.com/sentdex
https://www.facebook.com/pythonprogramming.net/
https://plus.google.com/+sentdex

Source


[ad_2]

Comment List

  • sentdex
    November 25, 2020

    Cool stuff mang! Even though these are simple games, I can see how this information you’ve can be useful for much more complicated applications.

  • sentdex
    November 25, 2020

    I just wanna ask, how do you dk this with android games?

  • sentdex
    November 25, 2020

    AttributeError: module 'tensorflow.python.framework.ops' has no attribute 'register_tensor_conversion_function'

    Can someone help me with this? Idk what's wrong and neither google nor stackoverflow is helping

  • sentdex
    November 25, 2020

    Please acquire dark theme! Great video besides that.

  • sentdex
    November 25, 2020

    We will reach a million subs soon! Congratulations!!

  • sentdex
    November 25, 2020

    Thank you so much for this video, it was really helpful to see you make use of gym so that I can play with it on my own.

  • sentdex
    November 25, 2020

    You're literally amazing 🤩🔥🤩🔥

  • sentdex
    November 25, 2020

    It took me 2 DAYS just to get this to work. But it was worth it.

  • sentdex
    November 25, 2020

    Can you make it so that OpenAi can attach to a game that is not one of the samples?

  • sentdex
    November 25, 2020

    I have an error importing tflearn please help .
    ModuleNotFoundError: No module named 'tensorflow.contrib'

  • sentdex
    November 25, 2020

    it did not work in ubuntu 18.04

  • sentdex
    November 25, 2020

    What if I want the AI to play the classic SWBF2?

  • sentdex
    November 25, 2020

    hey man love the videos. but i love you star background more, could you please link me that image

  • sentdex
    November 25, 2020

    Ok, I hope i can help some of you out as I've been struggling for quite a few hours on this. From how he was able to do it back then it seems some things have changed. The only way that I've gotten the code so far to build is via the following:

    pip install tensorflow==1.15
    pip install tflearn
    pip install gym
    #make sure a newer version of TensorFlow isn't installed as a dependency
    if you have pillow at all delete it from everywhere and reinstall it

    then in the header of the code:

    import gym

    import random

    import numpy as np

    from PIL.Image import core as _imaging
    #this is what fixed a long lasting problem of the module not being able to be found
    import tflearn

    from tflearn.layers.core import input_data, dropout, fully_connected

    from tflearn.layers.estimator import regression

    from statistics import median, mean

    from collections import Counter

    Also incidentally do not save the file name as gym because for some god forsaken reason that conflicts with the gym import.

  • sentdex
    November 25, 2020

    forever sad. i did exactly what you did and it wont run

  • sentdex
    November 25, 2020

    Thank you for this amazing video, I have a question which would be better as far as Python for machine learning or C++ for machine learning.

  • sentdex
    November 25, 2020

    I get these errors, got everything installed(yes, tensorflow included), any ideas on whats goin on? 🙁
    Traceback (most recent call last):

    File "<frozen importlib._bootstrap>", line 983, in _find_and_load

    File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked

    File "<frozen importlib._bootstrap>", line 677, in _load_unlocked

    File "<frozen importlib._bootstrap_external>", line 728, in exec_module

    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed

    File "C:UserspabloAppDataRoamingPythonPython37site-packagestflearn__init__.py", line 4, in <module>

    from . import config

    File "C:UserspabloAppDataRoamingPythonPython37site-packagestflearnconfig.py", line 3, in <module>

    import tensorflow as tf

    File "C:UserspabloAppDataRoamingPythonPython37site-packagestensorflow__init__.py", line 98, in <module>

    from tensorflow_core import *

    File "C:UserspabloAppDataRoamingPythonPython37site-packagestensorflow_core__init__.py", line 27, in <module>

    from tensorflow.python.tools import module_util as _module_util

    File "C:UserspabloAppDataRoamingPythonPython37site-packagestensorflow_init__.py", line 50, in __getattr_

    module = self._load()

    File "C:UserspabloAppDataRoamingPythonPython37site-packagestensorflow__init__.py", line 44, in _load

    module = _importlib.import_module(self.__name__)

    File "C:UserspabloAppDataLocalProgramsPythonPython37libimportlib__init__.py", line 127, in import_module

    return _bootstrap._gcd_import(name[level:], package, level)

    ModuleNotFoundError: No module named 'tensorflow_core.python'

    Process finished with exit code 1

  • sentdex
    November 25, 2020

    having error: UnregisteredEnv: No registered env with id: cartpole-v0,,,, can anybody help? or has had this error

  • sentdex
    November 25, 2020

    This guy has a video on everything 😂

  • sentdex
    November 25, 2020

    No module named 'tensorflow.contrib'……..yes i have installed tensorflow and tflearn and all updated

  • sentdex
    November 25, 2020

    uuuuuhhh ok , Traceback (most recent call last):

    File "E:/smaple code/some_random_games_first.py", line 4, in <module>

    import tflearn

    File "C:UsersJordaAppDataLocalProgramsPythonPython37libsite-packagestflearn__init__.py", line 4, in <module>

    from . import config

    File "C:UsersJordaAppDataLocalProgramsPythonPython37libsite-packagestflearnconfig.py", line 5, in <module>

    from .variables import variable

    File "C:UsersJordaAppDataLocalProgramsPythonPython37libsite-packagestflearnvariables.py", line 7, in <module>

    from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope

    ModuleNotFoundError: No module named 'tensorflow.contrib'

    what is this???? fix??

  • sentdex
    November 25, 2020

    The links you mentioned at 5:00 are missing

  • sentdex
    November 25, 2020

    dumb question but how do i start the game or program

  • sentdex
    November 25, 2020

    The code opens black screen and closes it down soon after with a lot of text like :
    WARNING:tensorflow:From C:Users1AppDataLocalProgramsPythonPython37libsite-packagestflearnconfig.py:131: The name tf.assign is deprecated. Please use tf.compat.v1.assign instead.

  • sentdex
    November 25, 2020

    this is trivial to code without fancy machine learning

  • sentdex
    November 25, 2020

    To anyone wondering, the atari game environments now work fine on windows. Just type "pip install gym[atari]" in the command window after you have gym installed. Enjoy 🙂

  • sentdex
    November 25, 2020

    dang getting this on mac Python[9435:5764564] ApplePersistenceIgnoreState: Existing state will not be touched. New state will be written to (null)

  • sentdex
    November 25, 2020

    ImportError: DLL load failed: The specified module could not be found.

  • sentdex
    November 25, 2020

    pip install gym
    you're ready to rumble!

    i need to go outside

  • sentdex
    November 25, 2020

    any tutorials on neat Python?

  • sentdex
    November 25, 2020

    Be me , just trying to scroll down on sentdex's in-video web browser

  • sentdex
    November 25, 2020

    Can you create a Video to give an idea which course to take first or what are prerequisite of a course in your playlist there are bunch of courses in your playlist for machine learning,deep learning
    and thanks for creating all these playlists

  • sentdex
    November 25, 2020

    To Which Playlist This Video Belong

  • sentdex
    November 25, 2020

    Sublime text

  • sentdex
    November 25, 2020

    Best teacher on Youtube.

Write a comment