Skip to content

Instantly share code, notes, and snippets.

View MattChanTK's full-sized avatar

Matthew Chan MattChanTK

View GitHub Profile
'''
--------------------------------------------------
Retrieve and process the training and testing data
--------------------------------------------------
'''
# Ensure we always get the same amount of randomness
np.random.seed(0)
# Define the data dimensions
image_shape = (1, 28, 28)
'''
-----------------------------------------------------
Functions to load or download MNIST images and unpack
into training and testing sets.
-----------------------------------------------------
'''
# loading data from local path if possible. Otherwise download from online sources
def load_or_download_mnist_files(filename, num_samples, local_data_dir):
if (local_data_dir):
import gzip
import os
import struct
import numpy as np
try:
from urllib.request import urlretrieve
except ImportError:
from urllib import urlretrieve
import gym
import numpy as np
import random
import math
from time import sleep
## Initialize the "Cart-Pole" environment
env = gym.make('CartPole-v0')
import gym
import numpy as np
import random
import math
from time import sleep
## Initialize the "Cart-Pole" environment
env = gym.make('CartPole-v0')
## Defining the environment related constants
import gym
import numpy as np
import random
import math
from time import sleep
## Initialize the "Cart-Pole" environment
env = gym.make('CartPole-v0')
## Defining the environment related constants