data_loader

This commit is contained in:
NiiiCo 2021-06-05 16:14:27 +02:00
commit cd144b1f8b
6 changed files with 13 additions and 9 deletions

7
RUN.py
View File

@ -6,11 +6,12 @@ training_data, validation_data, test_data = mnist_loader.load_data_wrapper()
import network
import dataset_loader
net = network.Network([262144, 30, 10]) #Testé : 94,56%
net = network.Network([262144,50, 20, 30, 10]) #Testé : 94,56%
net.SGD(dataset_loader.loadTrainingSet("training"), 30, 10, 3.0, test_data=dataset_loader.loadTestSet("test"))
# net = network.Network([784, 100, 10]) #Marche mieux apparemment
# net.SGD(training_data, 30, 10, 3.0, test_data=test_data)
#net = network.Network([784, 100, 10]) #Marche mieux apparemment
#net.SGD(dataset_loader.loadTrainingSet("setcomplete"), 30, 10, 3.0, test_data=dataset_loader.loadTestSet("setcomplete"))
# net = network.Network([784, 100, 10]) #Marche pas bien apparemment
# net.SGD(training_data, 30, 10, 0.001, test_data=test_data)

Binary file not shown.

View File

@ -29,7 +29,7 @@ def loadSet(path):
for name in filelist:
if i >= 100:
if i >= 500:
break
@ -40,7 +40,7 @@ def loadSet(path):
pix = im.load()
temparray = []
result.append(name.split("/")[-1][0])
result.append(int(name.split("/")[-1][0]))
for x in range(im.size[0]):
@ -49,8 +49,7 @@ def loadSet(path):
temparray.append(pix[x, y] / 255)
pixels.append(temparray)
print(temparray)
print(str("%.2f" % round(i / (len(filelist) if len(filelist) < 100 else 100) * 100, 2)) + "% Done, ram usage: " + str("%.2f" % round(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / (1024*1024), 2)) + "Go", end = '\r')
print(str("%.2f" % round(i / (len(filelist) if len(filelist) < 500 else 500) * 100, 2)) + "% Done, ram usage: " + str("%.2f" % round(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / (1024*1024), 2)) + "Go", end = '\r')
i += 1
print("max ram usage: " + str(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / (1024*1024)) + "Go")
@ -64,7 +63,7 @@ def loadTrainingSet(path):
set = loadSet(path)
training_inputs = [np.reshape(x, (262144, 1)) for x in set[0]]
training_inputs = [np.reshape(x, (784, 1)) for x in set[0]]
training_results = [vectorized_result(int(y)) for y in set[1]]
training_data = zip(training_inputs, training_results)
@ -76,7 +75,7 @@ def loadTestSet(path):
set = loadSet(path)
test_inputs = [np.reshape(x, (262144, 1)) for x in set[0]]
test_inputs = [np.reshape(x, (784, 1)) for x in set[0]]
test_data = zip(test_inputs, set[1])
return test_data

View File

@ -66,6 +66,8 @@ def load_data_wrapper():
validation_data = zip(validation_inputs, va_d[1])
test_inputs = [np.reshape(x, (784, 1)) for x in te_d[0]]
test_data = zip(test_inputs, te_d[1])
print(te_d[0])
print("1:", te_d[1])
return (training_data, validation_data, test_data)
def vectorized_result(j):

View File

@ -132,6 +132,8 @@ class Network(object):
neuron in the final layer has the highest activation."""
test_results = [(np.argmax(self.feedforward(x)), y)
for (x, y) in test_data]
print(test_data[0], test_data[1])
return sum(int(x == y) for (x, y) in test_results)
def cost_derivative(self, output_activations, y):