Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieu637 committed Apr 11, 2012
1 parent db81cdb commit 76c8991
Show file tree
Hide file tree
Showing 13 changed files with 423 additions and 196 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
**/*~
**/*.swp
**/*.kate-swp
**/.directory
48 changes: 24 additions & 24 deletions src/articles/blindslight.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from data import DataFile
from random import shuffle
from multilayerp import MultilayerPerceptron
from multilayerp import MultilayerPerceptronXT
from perceptron import Perceptron, PerceptronN0to1, PerceptronR0to1
from utils import index_max
import matplotlib.pyplot as plt
Expand All @@ -21,7 +21,7 @@
samples = DataFile("../data/blindslight.txt", rules=r)


first_order = MultilayerPerceptron(100, 60, 100, 0, 0.9, 0., 2, False, True)
first_order = MultilayerPerceptronXT(100, 60, 100, 0, 0.9, 0., 2, False, True)
first_order.init_weights_randomly(-0.6, 0.6)


Expand Down Expand Up @@ -58,28 +58,28 @@

i = index_max(first_order.stateOutputNeurons)
j = index_max(samples.outputs[ex])
if ((first_order.stateOutputNeurons[i] > 0.5 and samples.outputs[ex][j] > 0.5 and i == j) \
or(first_order.stateOutputNeurons[i] <= 0.5 and samples.outputs[ex][j] <= 0.5)) :

res = [high_order[i].calc_output(compara)
for i in range(2)]

if(index_max(res) == 0):
rms_ss += 1

high_order[0].train(compara, 1.)
high_order[1].train(compara, 0.)
else:
the += 1

res = [high_order[i].calc_output(compara)
for i in range(2)]

if(index_max(res) == 1):
rms_ss += 1

high_order[0].train(compara, 0.)
high_order[1].train(compara, 1.)
# if ((first_order.stateOutputNeurons[i] > 0.5 and samples.outputs[ex][j] > 0.5 and i == j) \
# or(first_order.stateOutputNeurons[i] <= 0.5 and samples.outputs[ex][j] <= 0.5)) :
#
# res = [high_order[i].calc_output(compara)
# for i in range(2)]
#
# if(index_max(res) == 0):
# rms_ss += 1
#
# high_order[0].train(compara, 1.)
# high_order[1].train(compara, 0.)
# else:
# the += 1
#
# res = [high_order[i].calc_output(compara)
# for i in range(2)]
#
# if(index_max(res) == 1):
# rms_ss += 1
#
# high_order[0].train(compara, 0.)
# high_order[1].train(compara, 1.)

first_order.train(samples.inputs[ex], samples.outputs[ex])

Expand Down
Binary file removed src/articles/digit_reco/discretize_cloud.png
Binary file not shown.
Binary file removed src/articles/digit_reco/discretize_cloud_out.png
Binary file not shown.
11 changes: 6 additions & 5 deletions src/articles/digit_reco/handwritten_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
nbr_network = 5
momentum = 0.9
lrate = 0.1
nbEpoch = 201
nbTry = 50
nbEpoch = 1000
nbTry = 10
display_interval = range(nbEpoch)[::6]
display_interval2 = [0, 25, 50, 100, 200, 500, 999]


#create all networks
Expand Down Expand Up @@ -118,13 +119,13 @@
rms_plot['high_order_5'][i] /= max_err[2]

#displays rms
plt.plot(display_interval, [rms_plot['first_order'][i] for i in display_interval],
plt.plot(display_interval2, [rms_plot['first_order'][i] for i in display_interval2],
label="first-order network")

plt.plot(display_interval, [rms_plot['high_order_10'][i] for i in display_interval],
plt.plot(display_interval2, [rms_plot['high_order_10'][i] for i in display_interval2],
label="high-order network (128 hidden units)")

plt.plot(display_interval, [rms_plot['high_order_5'][i] for i in display_interval],
plt.plot(display_interval2, [rms_plot['high_order_5'][i] for i in display_interval2],
label="high-order network (64 hidden units)")

plt.title('Error proportion (RMS) of first-order and high-order networks')
Expand Down
Loading

0 comments on commit 76c8991

Please sign in to comment.