Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
omar-florez committed Oct 30, 2017
1 parent 33ae64f commit be4a159
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 45 deletions.
8 changes: 3 additions & 5 deletions scratch_mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from scratch_mlp import utils
utils.reset_folders()


def load_XOR_data(N=300):
rng = np.random.RandomState(0)
X = rng.randn(N, 2)
Expand Down Expand Up @@ -52,11 +51,12 @@ def run():
output_dim = 2
num_epochs = 1000000
learning_rate= 1e-3
reg_coeff = 1e-4
reg_coeff = 1e-6
losses = []
accuracies=[]

#Initialize weights:
#---------------------------------------------------------------------------------------------------------------
# Initialize weights:
np.random.seed(2017)
w1 = 2.0*np.random.random((input_dim, hidden_dim))-1.0 #w0=(2,hidden_dim)
w2 = 2.0*np.random.random((hidden_dim, output_dim))-1.0 #w1=(hidden_dim,2)
Expand Down Expand Up @@ -122,6 +122,4 @@ def run():
save_filepath = './scratch_mlp/plots/accuracy/image_%d.png' % i
utils.plot_function(accuracies, save_filepath=save_filepath, ylabel='Accuracy', title='Accuracy estimation')

#ipdb.set_trace()

run()
41 changes: 1 addition & 40 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
#http://rasbt.github.io/mlxtend/
from sklearn.linear_model import LogisticRegression
from sklearn.naive_bayes import GaussianNB
from sklearn.ensemble import RandomForestClassifier
from sklearn.svm import SVC

# Loading Plotting Utilities
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import itertools
from mlxtend.plotting import plot_decision_regions

import numpy as np
import os
import imageio
import ipdb
import shutil


Expand Down Expand Up @@ -120,13 +112,11 @@ def make_all_gif(input_folder, save_filepath):
ax.imshow(episode_frames_boundary[i], interpolation='none')
ax.set_axis_off()
ax.set_aspect('equal')
#ax.set_adjustable('box-forced')

ax = axes.flat[2]
ax.imshow(episode_frames_loss[i], interpolation='none')
ax.set_axis_off()
ax.set_aspect('equal')
#ax.set_adjustable('box-forced')

fig.tight_layout()
plt.suptitle('Step = %d' %i, fontsize=18)
Expand All @@ -146,32 +136,3 @@ def reset_folders():
if os.path.exists(f):
shutil.rmtree(f)
os.mkdir(f)


# # take second element for sort
# def takeSecond(elem):
# return elem[1]
#
# # random list
# random = [(2, 2), (3, 4), (4, 1), (1, 3)]
#
# # sort list with key
# sortedList = sorted(random, key=takeSecond)
#
# # print list
# print('Sorted list:', sortedList)
#
# ###
# files.sort(key=lambda x: os.path.getmtime(x))

if __name__ == '__main__':
#save_filepath = './scratch_mlp/plots/gif/boundary.gif'
#make_gif('./scratch_mlp/plots/boundary/', save_filepath)
#save_filepath = './scratch_mlp/plots/gif/loss.gif'
#make_gif('./scratch_mlp/plots/loss/', save_filepath)
#save_filepath = './scratch_mlp/plots/gif/accuracy.gif'
#make_gif('./scratch_mlp/plots/accuracy/', save_filepath)

input_folder = './scratch_mlp/plots/'
save_filepath = './scratch_mlp/plots/gif/all.gif'
make_all_gif(input_folder, save_filepath)

0 comments on commit be4a159

Please sign in to comment.