This file contains hidden or 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
| ''' | |
| -------------------------------------------------- | |
| 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) |
This file contains hidden or 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
| ''' | |
| ----------------------------------------------------- | |
| 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): |
This file contains hidden or 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
| import gzip | |
| import os | |
| import struct | |
| import numpy as np | |
| try: | |
| from urllib.request import urlretrieve | |
| except ImportError: | |
| from urllib import urlretrieve |
This file contains hidden or 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
| import gym | |
| import numpy as np | |
| import random | |
| import math | |
| from time import sleep | |
| ## Initialize the "Cart-Pole" environment | |
| env = gym.make('CartPole-v0') |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| 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 |
NewerOlder