The credit for the code used in this chapter goes to Giacomo Spigler's GitHub repository (https://github.com/spiglerg/DQN_DDQN_Dueling_and_DDPG_Tensorflow). Throughout this chapter, the code is explained at each and every line. For a complete structured code, check the above GitHub repository.
First, we import all the necessary libraries:
import numpy as np
import tensorflow as tf
import gym
from gym.spaces import Box
from scipy.misc import imresize
import random
import cv2
import time
import logging
import os
import sys
We define the EnvWrapper class and define some of the environment wrapper functions:
class EnvWrapper:
We define the __init__ method and initialize variables:
def __init__(self, env_name, debug=False):
Initialize the gym environment:
self.env = gym.make(env_name)
Get the action_space:
self.action_space = self.env.action_space...