Last active
April 5, 2019 20:44
-
-
Save mirrornerror/7a75c1e59f8c9f20966f57b1e5c86edd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"gym-keras-rl.ipynb","version":"0.3.2","provenance":[],"collapsed_sections":[]},"kernelspec":{"name":"python3","display_name":"Python 3"},"accelerator":"GPU"},"cells":[{"metadata":{"id":"GGIkB5ypTFMq","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":161},"outputId":"4971f504-443d-4ad0-e891-21d5f1a08873","executionInfo":{"status":"ok","timestamp":1536514366566,"user_tz":-540,"elapsed":4907,"user":{"displayName":"mirror nerror","photoUrl":"//lh4.googleusercontent.com/-gGETofzEVi8/AAAAAAAAAAI/AAAAAAAADss/kscD3IWnpJ4/s50-c-k-no/photo.jpg","userId":"110024841757699787861"}}},"cell_type":"code","source":["!df -h"],"execution_count":9,"outputs":[{"output_type":"stream","text":["Filesystem Size Used Avail Use% Mounted on\n","overlay 359G 8.2G 332G 3% /\n","tmpfs 6.4G 0 6.4G 0% /dev\n","tmpfs 6.4G 0 6.4G 0% /sys/fs/cgroup\n","tmpfs 6.4G 249M 6.2G 4% /opt/bin\n","/dev/sda1 365G 11G 355G 3% /etc/hosts\n","shm 64M 0 64M 0% /dev/shm\n","tmpfs 6.4G 0 6.4G 0% /sys/firmware\n"],"name":"stdout"}]},{"metadata":{"id":"aT-Os6_6cSPp","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":35},"outputId":"0ef70099-54e9-4eae-efeb-d8170b3f1e2c","executionInfo":{"status":"ok","timestamp":1536550018978,"user_tz":-540,"elapsed":2826,"user":{"displayName":"mirror nerror","photoUrl":"//lh4.googleusercontent.com/-gGETofzEVi8/AAAAAAAAAAI/AAAAAAAADss/kscD3IWnpJ4/s50-c-k-no/photo.jpg","userId":"110024841757699787861"}}},"cell_type":"code","source":["!mkdir project\n","!ls"],"execution_count":11,"outputs":[{"output_type":"stream","text":["project sample_data\n"],"name":"stdout"}]},{"metadata":{"id":"UrPTQwoghMv2","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":35},"outputId":"8c80948c-e5d0-4605-95a7-b0b0b8748419","executionInfo":{"status":"ok","timestamp":1536594908912,"user_tz":-540,"elapsed":4082,"user":{"displayName":"mirror nerror","photoUrl":"//lh4.googleusercontent.com/-gGETofzEVi8/AAAAAAAAAAI/AAAAAAAADss/kscD3IWnpJ4/s50-c-k-no/photo.jpg","userId":"110024841757699787861"}}},"cell_type":"code","source":["!cd sample_data"],"execution_count":1,"outputs":[{"output_type":"stream","text":["\u001b[0m\u001b[01;34msample_data\u001b[0m/\n"],"name":"stdout"}]},{"metadata":{"id":"z5P17iZChSrF","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":35},"outputId":"54510d79-ff3b-40e7-d265-4677efe306ca","executionInfo":{"status":"ok","timestamp":1536550723527,"user_tz":-540,"elapsed":585,"user":{"displayName":"mirror nerror","photoUrl":"//lh4.googleusercontent.com/-gGETofzEVi8/AAAAAAAAAAI/AAAAAAAADss/kscD3IWnpJ4/s50-c-k-no/photo.jpg","userId":"110024841757699787861"}}},"cell_type":"code","source":["import keras\n","keras.__version__"],"execution_count":29,"outputs":[{"output_type":"execute_result","data":{"text/plain":["'2.1.6'"]},"metadata":{"tags":[]},"execution_count":29}]},{"metadata":{"id":"jSH21eMuZY_0","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":287},"outputId":"6616d27c-4b99-499b-f1df-e54332b98868","executionInfo":{"status":"ok","timestamp":1536514607275,"user_tz":-540,"elapsed":1731,"user":{"displayName":"mirror nerror","photoUrl":"//lh4.googleusercontent.com/-gGETofzEVi8/AAAAAAAAAAI/AAAAAAAADss/kscD3IWnpJ4/s50-c-k-no/photo.jpg","userId":"110024841757699787861"}}},"cell_type":"code","source":["from tensorflow.python.client import device_lib\n","device_lib.list_local_devices()"],"execution_count":13,"outputs":[{"output_type":"execute_result","data":{"text/plain":["[name: \"/device:CPU:0\"\n"," device_type: \"CPU\"\n"," memory_limit: 268435456\n"," locality {\n"," }\n"," incarnation: 16719986220226534363, name: \"/device:GPU:0\"\n"," device_type: \"GPU\"\n"," memory_limit: 11281989632\n"," locality {\n"," bus_id: 1\n"," links {\n"," }\n"," }\n"," incarnation: 11146876127476096945\n"," physical_device_desc: \"device: 0, name: Tesla K80, pci bus id: 0000:00:04.0, compute capability: 3.7\"]"]},"metadata":{"tags":[]},"execution_count":13}]},{"metadata":{"id":"euItnxKYca3Q","colab_type":"code","colab":{"resources":{"http://localhost:8080/nbextensions/google.colab/files.js":{"data":"Ly8gQ29weXJpZ2h0IDIwMTcgR29vZ2xlIExMQwovLwovLyBMaWNlbnNlZCB1bmRlciB0aGUgQXBhY2hlIExpY2Vuc2UsIFZlcnNpb24gMi4wICh0aGUgIkxpY2Vuc2UiKTsKLy8geW91IG1heSBub3QgdXNlIHRoaXMgZmlsZSBleGNlcHQgaW4gY29tcGxpYW5jZSB3aXRoIHRoZSBMaWNlbnNlLgovLyBZb3UgbWF5IG9idGFpbiBhIGNvcHkgb2YgdGhlIExpY2Vuc2UgYXQKLy8KLy8gICAgICBodHRwOi8vd3d3LmFwYWNoZS5vcmcvbGljZW5zZXMvTElDRU5TRS0yLjAKLy8KLy8gVW5sZXNzIHJlcXVpcmVkIGJ5IGFwcGxpY2FibGUgbGF3IG9yIGFncmVlZCB0byBpbiB3cml0aW5nLCBzb2Z0d2FyZQovLyBkaXN0cmlidXRlZCB1bmRlciB0aGUgTGljZW5zZSBpcyBkaXN0cmlidXRlZCBvbiBhbiAiQVMgSVMiIEJBU0lTLAovLyBXSVRIT1VUIFdBUlJBTlRJRVMgT1IgQ09ORElUSU9OUyBPRiBBTlkgS0lORCwgZWl0aGVyIGV4cHJlc3Mgb3IgaW1wbGllZC4KLy8gU2VlIHRoZSBMaWNlbnNlIGZvciB0aGUg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mlsZXMsCiAgX3VwbG9hZEZpbGVzQ29udGludWUsCn07Cn0pKHNlbGYpOwo=","ok":true,"headers":[["content-type","application/javascript"]],"status":200,"status_text":""}},"base_uri":"https://localhost:8080/","height":74},"outputId":"a7690dd7-d0c4-4378-d567-c3e04668e891","executionInfo":{"status":"ok","timestamp":1536532177761,"user_tz":-540,"elapsed":172566,"user":{"displayName":"mirror nerror","photoUrl":"//lh4.googleusercontent.com/-gGETofzEVi8/AAAAAAAAAAI/AAAAAAAADss/kscD3IWnpJ4/s50-c-k-no/photo.jpg","userId":"110024841757699787861"}}},"cell_type":"code","source":["from google.colab import files\n","uploaded = files.upload()"],"execution_count":9,"outputs":[{"output_type":"display_data","data":{"text/html":["\n"," <input type=\"file\" id=\"files-51915982-403d-4088-9b97-7c8d7c41f4d3\" name=\"files[]\" multiple disabled />\n"," <output id=\"result-51915982-403d-4088-9b97-7c8d7c41f4d3\">\n"," Upload widget is only available when the cell has been executed in the\n"," current browser session. Please rerun this cell to enable.\n"," </output>\n"," <script src=\"/nbextensions/google.colab/files.js\"></script> "],"text/plain":["<IPython.core.display.HTML object>"]},"metadata":{"tags":[]}},{"output_type":"stream","text":["Saving dqn_BreakoutDeterministic-v4_weights_1750000.h5f to dqn_BreakoutDeterministic-v4_weights_1750000.h5f\n"],"name":"stdout"}]},{"metadata":{"id":"1H73-hB7eJGM","colab_type":"code","colab":{}},"cell_type":"code","source":["!pip install gym keras-rl pyglet==1.2.4\n","!apt-get install -y cmake zlib1g-dev libjpeg-dev xvfb ffmpeg xorg-dev python-opengl libboost-all-dev libsdl2-dev swig\n","!pip install 'gym[all]'"],"execution_count":0,"outputs":[]},{"metadata":{"id":"hRy1xdunfxry","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":486},"outputId":"dec05cac-cc93-4ad0-915a-daf06e444adb","executionInfo":{"status":"ok","timestamp":1536533985819,"user_tz":-540,"elapsed":4,"user":{"displayName":"mirror nerror","photoUrl":"//lh4.googleusercontent.com/-gGETofzEVi8/AAAAAAAAAAI/AAAAAAAADss/kscD3IWnpJ4/s50-c-k-no/photo.jpg","userId":"110024841757699787861"}}},"cell_type":"code","source":["import gym\n","from IPython import display\n","import matplotlib.pyplot as plt\n","%matplotlib inline\n","\n","env = gym.make('Breakout-v0')\n","env.reset()\n","\n","plt.figure(figsize=(6,8))\n","img = plt.imshow(env.render(mode='rgb_array'))\n","\n","for _ in range(100):\n"," img.set_data(env.render(mode='rgb_array'))\n"," display.display(plt.gcf())\n"," display.clear_output(wait=True)\n"," action = env.action_space.sample()\n"," env.step(action)\n","env.close()"],"execution_count":26,"outputs":[{"output_type":"display_data","data":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAXEAAAHVCAYAAAAHCstcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAGR9JREFUeJzt3X+w5XV93/HnCSSVLiOI2wSkJsQm\n+3aSZdoJoWCRskSCSGmYEYx/rLeKODoBHDm3JtVYEWimdqTcmwQYW0aCetVRhDEs6iAVmsBA+CGT\nxDVx3orT2I6LhYW6ASTLLpz+cb4XD8v9cfbc77nnvJfnY2aHc77f7/l+X3su93U/9/P9nu92er0e\nkqSafmrSASRJo7PEJakwS1ySCrPEJakwS1ySCrPEJamwg9veYUTMAycCPeB9mflA28eQJPW1OhKP\niFOAX87M1wHnA3/c5v4lSS/U9nTKG4A/BcjMbwOviIiXt3wMSdKiXq/X2p9NmzZdu2nTprMHnt+1\nadOmTcttD/S2b9/eoz/1MtV/KuQ040srZ4WMVXJWyLhcj7Y+J76Pzkort2/fzubNmxcLfepVyGnG\n9lTIWSEj1Mg5zRk7neWrtO0S3wEcOfD8VcDDy2187LHH0uv1Vgw4LSrkNGN7KuSskBFq5KyQcTlt\nz4nfBpwLEBG/BuzIzCdaPoYkqdFq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fts2oqckbEvwP+IjP/1zKbTEPODv0R\n2JvpT1lczwtzTUNGIuJtwP/OzF8CfgP4zD6bTEXOJSyXayryNgW+ANyRmbcvscmkc87zwkHQUiad\ncVWTLPEdvHDk/SqaealJa050fAh4U2buAp5sTiACHM2LfyWbhH8DnB0R9wLvAj7M9OX8v8A9zSjo\ne8ATwBNTlhH6vy5/DSAz/xo4BNg4sH5acsLSX+N9v5emJe/1wHcz87Lm+dTkjIijgdcCn22+h46K\niD9nijIOa5Ilfhv9k0hExK8BOzLziQnmoclyGHAFcFZmLp4w/DpwTvP4HODWSWQblJlvzczjM/NE\n4BP0r06Ztpy3Ab8RET/VnOQ8lOnLCP0ThCcARMQv0P9h8+2IeH2z/s1MR05Y+v27Dzg+Ig5vrrQ5\nCbhrQvmA56/weCYzPzKweGpyZuYPMvOfZeaJzffQw81J2KnJOKyJ3sUwIv4L8K/pX8pzYTMKmqiI\neDdwKfCdgcVvp1+ULwO+D5yXmXvWP93SIuJS4O/ojyY/zRTljIj30J+Wgv4VCw8wfRkPBf4E+Dn6\nl5V+mP4lhv+d/kDnvsxc7dfuceQ6jv55j2PoX6b3A2Ar8En2ef8i4lzgd+lfEnlVZn52wjl/FvgH\n4O+bzf42My+YVM5lMr55caAWEX+Xmcc0jyf2Xo7CW9FKUmHTdGJTkrSfLHFJKswSl6TCLHFJKswS\nl6TCLHFJKswSl6TCLHFJKuz/Ax192n9Wlo21AAAAAElFTkSuQmCC\n","text/plain":["<matplotlib.figure.Figure at 0x7fd507b155c0>"]},"metadata":{"tags":[]}}]},{"metadata":{"id":"fsmDh_Tmixr2","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":269},"outputId":"04461ce6-6c1a-4183-99c6-69a2f30d48cb","executionInfo":{"status":"ok","timestamp":1536533748589,"user_tz":-540,"elapsed":1367,"user":{"displayName":"mirror nerror","photoUrl":"//lh4.googleusercontent.com/-gGETofzEVi8/AAAAAAAAAAI/AAAAAAAADss/kscD3IWnpJ4/s50-c-k-no/photo.jpg","userId":"110024841757699787861"}}},"cell_type":"code","source":["# import gym\n","# from IPython import display\n","# import matplotlib.pyplot as plt\n","# %matplotlib inline\n","\n","env = gym.make('Breakout-v0')\n","env.reset()\n","\n","plt.imshow(env.render(mode='rgb_array'))"],"execution_count":22,"outputs":[{"output_type":"display_data","data":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAMsAAAD8CAYAAADZhFAmAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAD19JREFUeJzt3X+MHPV5x/H31S0qMgHHuTYGlzZC\niZ4o8VVVHBcT6nAUAm5Ei1q7zR/uiYKrRg1GcFfamkYitluVCDe+KgaRWnFNuJSWH1YSA5FDY5oY\nJQUbK9CDoqfgP1CEjeyzhcFA/QNv/5jZernsj+dm5jyze5+XhNj93uzs8wV97jszu/NcX61WQ0Q6\n+7myCxDpFgqLSJDCIhKksIgEKSwiQQqLSNDPF71DMxsFFgM14GZ33130e4iUodCVxcwuAz7i7pcA\nK4GvFrl/kTIVfRh2BfBtAHd/EXi/mZ1b8HuIlKLow7B5wJ6G5wfTsTeabdzX11cbHx9nYGCg4DLK\n0UtzgZk7n1qt1tdsvPBzlkmavmnd+Pg4CxYsoJe+ctNLcwHNp1HRYdlHspLUXQDsb7XxwMAAtVqN\nvr62meoavTQXmLnzaRWoos9ZHgeWA5jZJ4B97v5mwe8hUoq+opdZM/sy8GngFHCjuz/X8s37+mq9\n9Nurl+YCM3c+rc5ZCg/LVFQxLBs2bJjya0ZGRoDT/zOmuo/66/PU0WwfedVqNUZHR0utYbLJ/12m\n8p55w6JP8EWCpvtqWNebjt/6eVavPPvI60ysHFWmlUUkSCuLhHVazXp95dHKIhKklUXaardalHHe\nVCatLCJBWlk6KOK3Z1X20U3vW0VaWUSCFBaRIH3d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9yoyzqcqJ/jdeIfRSyQB\nuZbkztHNvPeXTzfOabLMzUgqZAxY7e6/DTxLctfvZKH5lBWWyc0tLiA5mewa7v6quz/g7jV33wu8\nRnI4eXa6Sb2RR7c52mQOzZqRdMXc3H2Huz+bPt0GDJBxPmWF5XFgOYCZfQLY5+5vllRLJma2wsxu\nTR/PAz4IbOFnG3l0m55qRmJmW83sovTpIPA8GedT2reOzezLwKdJLt3d6O7PlVJIRmb2PuB+YA5w\nFskh2U+A+5jUyKO0Ijsws4XAV4APASeAV4EVwL3kbEZShhbz2QisBt4GjpLM50CW+egr+iJBVTnB\nF6k8hUUkSGERCVJYRIIUFpEghUUkSGERCVJYRIL+D4kJ167OcBoUAAAAAElFTkSuQmCC\n","text/plain":["<matplotlib.figure.Figure at 0x7fd507ac0080>"]},"metadata":{"tags":[]}}]},{"metadata":{"id":"c0ghaIuqTyvc","colab_type":"code","colab":{}},"cell_type":"code","source":["from PIL import Image\n","import numpy as np\n","import gym\n","\n","from keras.models import Sequential\n","from keras.layers import Dense, Activation, Flatten, Convolution2D, Permute\n","from keras.optimizers import Adam\n","import keras.backend as K\n","\n","from rl.agents.dqn import DQNAgent\n","from rl.policy import LinearAnnealedPolicy, BoltzmannQPolicy, EpsGreedyQPolicy\n","from rl.memory import SequentialMemory\n","from rl.core import Processor\n","from rl.callbacks import FileLogger, ModelIntervalCheckpoint\n","\n","\n","INPUT_SHAPE = (84, 84)\n","WINDOW_LENGTH = 4\n","\n","class AtariProcessor(Processor):\n"," def process_observation(self, observation):\n"," assert observation.ndim == 3\n"," img = Image.fromarray(observation)\n"," img = img.resize(INPUT_SHAPE).convert('L')\n"," processed_observation = np.array(img)\n"," assert processed_observation.shape == INPUT_SHAPE\n"," return processed_observation.astype('uint8')\n","\n"," def process_state_batch(self, batch):\n"," processed_batch = batch.astype('float32') / 255.\n"," return processed_batch\n","\n"," def process_reward(self, reward):\n"," return np.clip(reward, -1., 1.)\n","\n","ENV_NAME = 'BreakoutDeterministic-v4'\n","env = gym.make(ENV_NAME)\n","np.random.seed(123)\n","env.seed(123)\n","nb_actions = env.action_space.n\n","input_shape = (WINDOW_LENGTH,) + INPUT_SHAPE\n","\n","model = Sequential()\n","model.add(Permute((2, 3, 1), input_shape=input_shape))\n","model.add(Convolution2D(32, (8, 8), strides=(4, 4)))\n","model.add(Activation('relu'))\n","model.add(Convolution2D(64, (4, 4), strides=(2, 2)))\n","model.add(Activation('relu'))\n","model.add(Convolution2D(64, (3, 3), strides=(1, 1)))\n","model.add(Activation('relu'))\n","model.add(Flatten())\n","model.add(Dense(512))\n","model.add(Activation('relu'))\n","model.add(Dense(nb_actions))\n","model.add(Activation('linear'))\n","#print(model.summary())\n","\n","memory = SequentialMemory(limit=1000000, window_length=WINDOW_LENGTH)\n","processor = AtariProcessor()\n","\n","policy = LinearAnnealedPolicy(EpsGreedyQPolicy(), attr='eps', value_max=1., value_min=.1, value_test=.05,\n"," nb_steps=1000000)\n","\n","dqn = DQNAgent(model=model, nb_actions=nb_actions, policy=policy, memory=memory,\n"," processor=processor, nb_steps_warmup=50000, gamma=.99, target_model_update=10000,\n"," train_interval=4, delta_clip=1.)\n","\n","dqn.compile(Adam(lr=.00025), metrics=['mae'])"],"execution_count":0,"outputs":[]},{"metadata":{"id":"oOZ1AX3DdZxW","colab_type":"text"},"cell_type":"markdown","source":["# TRAIN"]},{"metadata":{"id":"zOevRHKqUU8a","colab_type":"code","colab":{}},"cell_type":"code","source":["weights_filename = 'dqn_{}_weights.h5f'.format(ENV_NAME)\n","checkpoint_weights_filename = 'dqn_' + ENV_NAME + '_weights_{step}.h5f'\n","log_filename = 'dqn_{}_log.json'.format(ENV_NAME)\n","callbacks = [ModelIntervalCheckpoint(checkpoint_weights_filename, interval=250000)]\n","callbacks += [FileLogger(log_filename, interval=100)]\n","dqn.fit(env, callbacks=callbacks, nb_steps=1750000, log_interval=10000)\n","\n","dqn.save_weights(weights_filename, overwrite=True)\n","dqn.test(env, nb_episodes=1, visualize=False)"],"execution_count":0,"outputs":[]},{"metadata":{"id":"6EeLQhNRdhcr","colab_type":"text"},"cell_type":"markdown","source":["# TEST:1"]},{"metadata":{"id":"26Cc_GzxdoBy","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":521},"outputId":"99a02654-aa41-471b-ddbd-e1e924f89a05","executionInfo":{"status":"ok","timestamp":1536534342474,"user_tz":-540,"elapsed":8,"user":{"displayName":"mirror nerror","photoUrl":"//lh4.googleusercontent.com/-gGETofzEVi8/AAAAAAAAAAI/AAAAAAAADss/kscD3IWnpJ4/s50-c-k-no/photo.jpg","userId":"110024841757699787861"}}},"cell_type":"code","source":["from rl.callbacks import Callback\n","from IPython import display\n","import matplotlib.pyplot as plt\n","%matplotlib inline\n","\n","# Subclass to visualize on Jupyter Notebook, inherits from rl.callbacks.Callback Class\n","class Render(Callback):\n"," def on_step_end(self, step, logs={}):\n"," plt.clf()\n"," plt.imshow(env.render(mode='rgb_array'))\n"," display.display(plt.gcf())\n"," display.clear_output(wait=True)\n","\n","# weights_filename = 'dqn_{}_weights.h5f'.format(ENV_NAME)\n","# weights_filename = 'dqn_{}_weights_1750000.h5f'.format(ENV_NAME) # @check point\n","weights_filename = 'dqn_BreakoutDeterministic-v4_weights_1750000.h5f'\n","dqn.load_weights(weights_filename)\n","\n","callbacks = Render()\n","plt.figure(figsize=(6,8))\n","dqn.test(env, nb_episodes=1, visualize=False, callbacks=[callbacks])\n","\n","env.close()\n","print('END')"],"execution_count":28,"outputs":[{"output_type":"stream","text":["Episode 1: reward: 37.000, steps: 1185\n","END\n"],"name":"stdout"},{"output_type":"display_data","data":{"image/png":"iVBORw0KGgoAAAANSUhEUgAAAXEAAAHVCAYAAAAHCstcAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAGZRJREFUeJzt3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yZuaPM/NfZOaJvZ+hh3oHYScm46DGehXDiPgvwL+meyrPhb1R\n0FhFxHuAjwPf71v8DrpF+RLgR8B5mbl37dMtLiI+Dvw93dHk9UxQzoh4L91pKeiesbCdyct4KPBn\nwK/QPa30o3RPMfzvdAc692XmSn92r0au4+ge9ziG7ml6Pwa2ANex4PWLiHOAP6B7SuQVmfmFMef8\nZeAfgX/orfbdzLxgXDmXyPiW+YFaRPx9Zh7Tuz2213IYXopWkgqbpAObkqT9ZIlLUmGWuCQVZolL\nUmGWuCQVZolLUmGWuCQVZolLUmH/Hwih3vSAUzTRAAAAAElFTkSuQmCC\n","text/plain":["<matplotlib.figure.Figure at 0x7fd5018a0198>"]},"metadata":{"tags":[]}}]},{"metadata":{"id":"HJOS8esKkJ0L","colab_type":"code","colab":{"base_uri":"https://localhost:8080/","height":485,"output_embedded_package_id":"1YZIFkFyPX-SJHYKGK4agi_3MRlpij2Be"},"outputId":"db59e244-c38d-425b-acdd-d72fb173ecfa","executionInfo":{"status":"ok","timestamp":1536534609257,"user_tz":-540,"elapsed":37654,"user":{"displayName":"mirror nerror","photoUrl":"//lh4.googleusercontent.com/-gGETofzEVi8/AAAAAAAAAAI/AAAAAAAADss/kscD3IWnpJ4/s50-c-k-no/photo.jpg","userId":"110024841757699787861"}}},"cell_type":"code","source":["from rl.callbacks import Callback\n","import matplotlib.pyplot as plt\n","import matplotlib.animation as animation\n","from IPython.display import HTML\n","%matplotlib inline\n","\n","ims = [] # list for animation\n","\n","class Render(Callback):\n"," def on_step_end(self, step, logs={}):\n"," im = plt.imshow(env.render(mode='rgb_array'))\n"," ims.append([im])\n","\n","#weights_filename = 'dqn_{}_weights.h5f'.format(ENV_NAME)\n","weights_filename = 'dqn_BreakoutDeterministic-v4_weights_1750000.h5f'\n","dqn.load_weights(weights_filename)\n","\n","callbacks = Render()\n","fig = plt.figure(figsize=(4,5)) # output size\n","plt.axis('off') # no frame\n","dqn.test(env, nb_episodes=1, visualize=False, callbacks=[callbacks])\n","\n","ani = animation.ArtistAnimation(fig=fig, artists=ims, interval=10)\n","# ani.save(\"anim.gif\", writer = \"imagemagick\") # save as gif animation\n","plt.close()\n","\n","# animation on Jupyter Notebook\n","HTML(ani.to_jshtml()) # JavascriptHTML output\n","#HTML(ani.to_html5_video()) # HTML5 Video output"],"execution_count":30},{"metadata":{"id":"xZITVZmBmENZ","colab_type":"code","colab":{}},"cell_type":"code","source":[""],"execution_count":0,"outputs":[]}]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment