import nn
import helper
import dataio
import numpy as np
import pdb
import matplotlib.pyplot as plt

training_data = dataio.training_from_doc()
validation_data = dataio.validation_from_doc()
learning_rates = [.1, .01, .2, .5]

a = nn.FCN(rand_seed=1, dropout=True)

#pdb.set_trace()
a.fit(training_data, validation_data)

np.save('weightsq5f', a.weights)

#pdb.set_trace()

vce = a.v_ce_array
tce = a.t_ce_array

plt.plot(a.epoch_nums, vce, 'r--')
plt.plot(a.epoch_nums, tce, 'b--')
plt.savefig('q5f.png')
plt.show()
Example #2
0
import nn
import helper
import dataio
import numpy as np
import pdb
import matplotlib.pyplot as plt

training_data = dataio.training_from_doc()

validation_data = dataio.validation_from_doc()
test_data = dataio.test_from_doc()
learning_rates = [.1,.01,.2,.5]

a = nn.FCN(architecture=[784,100,10], eta = 0.5, batch_size = 1, n_epochs=18, rand_seed = 4, momentum = 0.0)
a.fit(training_data,test_data)

helper.plot_ce('q6f_ce',a)
helper.plot_ac('q6f_ac',a)


np.save('fbest_weights',a.weights)
import nn
import helper
import dataio
import numpy as np
import pdb
import matplotlib.pyplot as plt

training_data = dataio.training_from_doc()

validation_data = dataio.validation_from_doc()
learning_rates = [.1, .01, .2, .5]

a = nn.FCN(architecture=[784, 100, 100, 10],
           eta=0.5,
           batch_size=32,
           n_epochs=250,
           rand_seed=41,
           momentum=.5)
a.fit(training_data, validation_data)

helper.plot_ce('h6g_ce', a)
helper.plot_ac('h6g_ac', a)

np.save('hbest_weights', a.weights)
import nn
import helper
import dataio
import numpy as np
import pdb
import matplotlib.pyplot as plt

training_data = dataio.training_from_doc()
validation_data = dataio.validation_from_doc()
learning_rates = [.1, .01, .2, .5]

a = nn.FCN(rand_seed=1)

#pdb.set_trace()
a.fit(training_data, validation_data, rbm)

plt.plot(a.epoch_nums, vce, 'r--', tce, 'b--')
plt.savefig('q6a.png')
plt.show()

plt.plot(a.epoch_nums, va, 'r--', ta, 'b--')
plt.savefig('q6b.png')
plt.show()
import nn
import helper
import dataio
import numpy as np
import pdb
import matplotlib.pyplot as plt

training_data = dataio.training_from_doc()

validation_data = dataio.validation_from_doc()
learning_rates = [.1, .01, .2, .5]

a = nn.FCN(rand_seed=5,
           eta=.01,
           momentum=0.5,
           architecture=[784, 100, 10],
           n_epochs=200)
b = nn.FCN(rand_seed=5,
           eta=.01,
           momentum=0.5,
           architecture=[784, 20, 10],
           n_epochs=200)
c = nn.FCN(rand_seed=5,
           eta=.01,
           momentum=0.5,
           architecture=[784, 200, 10],
           n_epochs=200)
d = nn.FCN(rand_seed=5,
           eta=.01,
           momentum=0.5,
           architecture=[784, 500, 10],
import dataio
import numpy as np
import pdb
import matplotlib.pyplot as plt

training_data = dataio.training_from_doc()
validation_data = dataio.validation_from_doc()
learning_rates = [.1, .01, .2, .5]
autoencoder = np.load('weightsq5e.npy')[1]
denoise = np.load('weightsq5f.npy')[1]
denoise.tolist()
rbm = np.load('a2weights.npy')
rbm.tolist()
autoencoder.tolist()

c = nn.FCN(rand_seed=1, pretrain=denoise)

a = nn.FCN(rand_seed=1, pretrain=autoencoder)
b = nn.FCN(rand_seed=1, pretrain=rbm)

#pdb.set_trace()
a.fit(training_data, validation_data)
b.fit(training_data, validation_data)
c.fit(training_data, validation_data)
'''
plt.plot(a.epoch_nums,vce, 'r--', tce, 'b--')
plt.savefig('a2q5pre.png')
plt.show()
'''
plt.plot(a.epoch_nums, b.v_ac_array, 'b--')
plt.plot(a.epoch_nums, a.v_ac_array, 'r--')
Example #7
0
import nn
import helper
import dataio
import numpy as np
import pdb
import matplotlib.pyplot as plt

training_data = dataio.training_from_doc()

validation_data = dataio.test_from_doc()
learning_rates = [.1,.01,.2,.5]

a = nn.FCN(architecture=[784,10,20,10], eta = 0.03, batch_size = 1, n_epochs=500, rand_seed = 40, momentum = 0.9)
a.fit(training_data,validation_data)

helper.plot_ce('q6g_ce',a)
helper.plot_ac('q6g_ac',a)


np.save('gbest_weights',a.weights)
Example #8
0
import nn
import helper
import dataio
import numpy as np
import pdb
import matplotlib.pyplot as plt

training_data = dataio.training_from_doc()

validation_data = dataio.validation_from_doc()
learning_rates = [.1, .01, .2, .5]

a = nn.FCN(rand_seed=1, eta=0.1)
b = nn.FCN(rand_seed=2, eta=.01)
c = nn.FCN(rand_seed=3, eta=.2)
d = nn.FCN(rand_seed=4, eta=.5)
e = nn.FCN(rand_seed=5, eta=.1, momentum=0.5)
f = nn.FCN(rand_seed=5, eta=.1, momentum=0.9)

best_results = 0
best_network = 5
for net, file in zip([a, b, c, d, e, f],
                     ['eta01', 'eta001', 'eta02', 'eta05', 'm5', 'm9']):
    net.fit(training_data, validation_data)
    helper.plot_ce(file + 'ce', net)
    helper.plot_ac(file + 'ac', net)
    if net.v_ac_array[-1] > best_results:
        best_network = net

np.save('best_weights', best_network.weights)