The algorithm uses a custom built Q Learning agent in Python 3. https://github.com/ryanpeach/openaigym/tree/FrozenLake-QLearner
- Python 3
- Tensorflow
- Numpy
- Scipy
from time import time, sleep | |
from functools import wraps | |
import socket | |
import unittest | |
class TimeoutError(socket.timeout): | |
pass | |
none_val = lambda x: 0.0 if x is None else float(x) # Returns float(x), or 0 if x is None |
# Ryan Peach 3/1/2016 | |
# References Used for this Implementation | |
# https://en.wikipedia.org/wiki/Hungarian_algorithm | |
# https://github.com/bmc/munkres/blob/master/munkres.py | |
# http://csclab.murraystate.edu/bob.pilgrim/445/munkres.html | |
# --- | |
# No copying and pasting of online code was performed, though some code may turn out to be similar due to the standardized nature of this algorithm. | |
# This is a very different implementation due to the fact that it heavily uses numpy, vastly simplifies many poorly pythonized coding elements | |
# removes the "class" approach for a function based one. Etc. | |
# Improvements that need to be made is to require the matrix class, and to vectorize iterations through the matrix. |
The algorithm uses a custom built Q Learning agent in Python 3. https://github.com/ryanpeach/openaigym/tree/FrozenLake-QLearner
import numpy as np | |
import cv2 | |
import random | |
import scipy.stats | |
# Matplotlib | |
import matplotlib as mpl | |
mpl.use('Agg') | |
import matplotlib.pyplot as plt |
""" Python 3 implementation of Deep Learning book early stop algorithm. | |
@book{Goodfellow-et-al-2016, | |
title={Deep Learning}, | |
author={Ian Goodfellow and Yoshua Bengio and Aaron Courville}, | |
publisher={MIT Press}, | |
note={\url{http://www.deeplearningbook.org}}, | |
year={2016} | |
} | |
""" |
import random as rand | |
from functools import partial | |
def twiddle(run, args, p, dp, tol = 0.2, N = 100, logger = None): | |
""" Uses gradient descent to find the optimal value of p as input for function run. | |
run is a function which takes p as an argument and returns an error (with 0 being optimal) as an output. | |
dp is the initial magnitute for each index of p to begin | |
N is the max number of iterations, after which the best value of p is returned. | |
tol is the max error allowed, under which this function will terminate. """ | |
best_err, best_p, best_dp, n = 1000000, None, None, 0 |
def grid_plot(x_label, y_label, z_label, data, ax=None): | |
""" Useful if you have a dataframe, with a certain number of unique categories or values in x and y, | |
and you want to compare them visually to a third continuous value. """ | |
if ax is None: | |
ax = plt.gca() | |
x_val = np.sort(np.unique(data[x_label])) | |
y_val = np.sort(np.unique(data[y_label])) | |
x_idx = np.arange(len(x_val)) | |
y_idx = np.arange(len(y_val)) |
# coding: utf-8 | |
import subprocess | |
import re | |
def get_windows(): | |
list_of_windows = subprocess.check_output(["wmctrl","-l"]).split(b"\n") | |
meta_list_of_windows = [s.decode("utf-8").split() for s in list_of_windows if s] | |
user_processes = {} | |
for line in meta_list_of_windows: |
from copy import deepcopy | |
import networkx as nx | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
G = nx.DiGraph() | |
class Literal(str): |