microsoft/AI-For-Beginners
Publicmirrored fromhttps://github.com/microsoft/AI-For-BeginnersAvailable
lessons/6-Other/22-DeepRL/lab/MountainCar.ipynb
98lines · modecode
| 1 | { |
| 2 | "cells": [ |
| 3 | { |
| 4 | "cell_type": "markdown", |
| 5 | "metadata": {}, |
| 6 | "source": [ |
| 7 | "# # Training Mountain Car to Escape\n", |
| 8 | "\n", |
| 9 | "Lab Assignment from [AI for Beginners Curriculum](https://github.com/microsoft/ai-for-beginners).\n", |
| 10 | "\n", |
| 11 | "Your goal is to train the RL agent to control [Mountain Car](https://www.gymlibrary.ml/environments/classic_control/mountain_car/) in OpenAI Environment.\n", |
| 12 | "\n", |
| 13 | "Let's start by creating the environment:" |
| 14 | ] |
| 15 | }, |
| 16 | { |
| 17 | "cell_type": "code", |
| 18 | "execution_count": 1, |
| 19 | "metadata": {}, |
| 20 | "outputs": [], |
| 21 | "source": [ |
| 22 | "import gym\n", |
| 23 | "env = gym.make('MountainCar-v0')" |
| 24 | ] |
| 25 | }, |
| 26 | { |
| 27 | "cell_type": "markdown", |
| 28 | "metadata": {}, |
| 29 | "source": [ |
| 30 | "Let's see how the random experiment looks like:" |
| 31 | ] |
| 32 | }, |
| 33 | { |
| 34 | "cell_type": "code", |
| 35 | "execution_count": 2, |
| 36 | "metadata": {}, |
| 37 | "outputs": [], |
| 38 | "source": [ |
| 39 | "state = env.reset()\n", |
| 40 | "while True:\n", |
| 41 | " env.render()\n", |
| 42 | " action = env.action_space.sample()\n", |
| 43 | " state, reward, done, info = env.step(action)\n", |
| 44 | " if done:\n", |
| 45 | " break" |
| 46 | ] |
| 47 | }, |
| 48 | { |
| 49 | "cell_type": "markdown", |
| 50 | "metadata": {}, |
| 51 | "source": [ |
| 52 | "Now the notebook is all yours - fell free to adopt Policy Gradients and Actor-Critic algorithms from the lesson to this problem! " |
| 53 | ] |
| 54 | }, |
| 55 | { |
| 56 | "cell_type": "code", |
| 57 | "execution_count": null, |
| 58 | "metadata": {}, |
| 59 | "outputs": [], |
| 60 | "source": [ |
| 61 | "## Lost of code here" |
| 62 | ] |
| 63 | }, |
| 64 | { |
| 65 | "cell_type": "code", |
| 66 | "execution_count": 3, |
| 67 | "metadata": {}, |
| 68 | "outputs": [], |
| 69 | "source": [ |
| 70 | "env.close()" |
| 71 | ] |
| 72 | } |
| 73 | ], |
| 74 | "metadata": { |
| 75 | "interpreter": { |
| 76 | "hash": "16af2a8bbb083ea23e5e41c7f5787656b2ce26968575d8763f2c4b17f9cd711f" |
| 77 | }, |
| 78 | "kernelspec": { |
| 79 | "display_name": "Python 3.8.12 ('py38')", |
| 80 | "language": "python", |
| 81 | "name": "python3" |
| 82 | }, |
| 83 | "language_info": { |
| 84 | "codemirror_mode": { |
| 85 | "name": "ipython", |
| 86 | "version": 3 |
| 87 | }, |
| 88 | "file_extension": ".py", |
| 89 | "mimetype": "text/x-python", |
| 90 | "name": "python", |
| 91 | "nbconvert_exporter": "python", |
| 92 | "pygments_lexer": "ipython3", |
| 93 | "version": "3.8.12" |
| 94 | } |
| 95 | }, |
| 96 | "nbformat": 4, |
| 97 | "nbformat_minor": 4 |
| 98 | } |
| 99 | |