Loading neuralNetwork.py +4 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ from dataset import additional_input import numpy as np import os import shutil import sys class NeuralNetwork: errors = [] Loading Loading @@ -78,6 +79,9 @@ class NeuralNetwork: self.layer[n].bias -= self.learning_rate*self.layer[n].gradient_bias def getResult(self, input): if len(input) != self.structure[0]: print("Difference in dimension! The input layer has dimension "+str(self.structure[0])+", while the data have dimension "+str(len(input))+".") sys.exit(1) self.activation(input) return self.layer[self.depth-1].neurons Loading train.py +3 −3 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ structure = [data.input_data_dimension,8,8,8,data.output_data_dimension] #Initialization of new neural network network = NeuralNetwork(structure) #Loading of already trained neural network network.loadModel("model/") #Loading of already trained neural network - uncomment if you want to evaluate saved network or train it further #network.loadModel("model/") #Initialization of training controller where the neural network, dataset and the whole configuration is stored training_controller = TrainingController(network, data, plot_progress=True) Loading @@ -47,4 +47,4 @@ print("Accuracy on the test data is "+str(test_data_accuracy)+" %.") #Saving the trained model: weights, training history, final state plot, and the final weights plot #Warning: For now, if the folder already exists, the model will be overwritten! Do not save, if you just want to evaluate with loaded network #training_controller.saveTrainedModel() No newline at end of file training_controller.saveTrainedModel() No newline at end of file Loading
neuralNetwork.py +4 −0 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ from dataset import additional_input import numpy as np import os import shutil import sys class NeuralNetwork: errors = [] Loading Loading @@ -78,6 +79,9 @@ class NeuralNetwork: self.layer[n].bias -= self.learning_rate*self.layer[n].gradient_bias def getResult(self, input): if len(input) != self.structure[0]: print("Difference in dimension! The input layer has dimension "+str(self.structure[0])+", while the data have dimension "+str(len(input))+".") sys.exit(1) self.activation(input) return self.layer[self.depth-1].neurons Loading
train.py +3 −3 Original line number Diff line number Diff line Loading @@ -24,8 +24,8 @@ structure = [data.input_data_dimension,8,8,8,data.output_data_dimension] #Initialization of new neural network network = NeuralNetwork(structure) #Loading of already trained neural network network.loadModel("model/") #Loading of already trained neural network - uncomment if you want to evaluate saved network or train it further #network.loadModel("model/") #Initialization of training controller where the neural network, dataset and the whole configuration is stored training_controller = TrainingController(network, data, plot_progress=True) Loading @@ -47,4 +47,4 @@ print("Accuracy on the test data is "+str(test_data_accuracy)+" %.") #Saving the trained model: weights, training history, final state plot, and the final weights plot #Warning: For now, if the folder already exists, the model will be overwritten! Do not save, if you just want to evaluate with loaded network #training_controller.saveTrainedModel() No newline at end of file training_controller.saveTrainedModel() No newline at end of file