Homework 07: Reinforcement Learning: Implementing a Deep Q-Network#
Make sure to run every single cell in this notebook, or some libraries might be missing. Also, if you are using Colab, make sure to change your Runtime (change runtime type under Runtime) to a GPU, although it will work on a CPU.
%apt-get install x11-utils > /dev/null 2>&1
%pip install pyglet > /dev/null 2>&1
%apt-get install -y xvfb python-opengl > /dev/null 2>&1
%pip install gym pyvirtualdisplay > /dev/null 2>&1
%matplotlib inline
import os
import pdb
import sys
import copy
import json
import argparse
from datetime import datetime
import gym
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import matplotlib.pyplot as plt
from IPython import display as ipythondisplay
Acknowledgments#
Initial version: Mark Neubauer
© Copyright 2025