from utils.Data import Data from factories.NetworkFactory import NetworkFactory from utils.Tags import NetworkTags from utils.WinnerHolder import WinnerHolder data = Data("resources/IrisDataTrain.xls", 125, shufle_data=True) data.label_iris_dat() normalized_data = data.normalize_data() layers = [data.def_input_neurons(), 4, 4, 4, 4] som = NetworkFactory.create(NetworkTags.SOM, layers) # som.print() som.train(data.get_raw_data(), data.label_iris_dat(), 2000) # som.print() # print("=============================================") # print(WinnerHolder.get_winner()) # print("distance") # print(som.layers_list[1].neuron_vector[0])
from utils.Data import Data from factories.NetworkFactory import NetworkFactory from utils.Tags import NetworkTags from utils.Functions import ActivaionFunction from utils.NetworkHelper import NetworkHelper data = Data("resources/IrisDataTrain.xls", 125, shufle_data=True) data.label_iris_dat() normalized_data = data.normalize_data() layers = [data.def_input_neurons(), 3, data.def_input_neurons()] encoder = NetworkFactory.create(NetworkTags.AutoEncoder, layers) encoder.train(normalized_data, normalized_data, repetitions=500, activation_function=ActivaionFunction.HYPERBOLIC_TANGENT) encoder.remove_unneeded_layers() layers = [data.def_input_neurons(), 15, 7, data.def_output_neurons()] mlp = NetworkFactory.create(NetworkTags.MLPWithEachLayerConnection, layers) merged = NetworkHelper.merge_autoencoder_to_mlp(encoder, mlp) finnal = NetworkHelper.add_neurons_to_first_hidden_layer(merged, 6) finnal.update_id() finnal.train(data.normalize_data(), data.label_iris_dat(), repetitions=500, activation_function=ActivaionFunction.HYPERBOLIC_TANGENT) predict_data = Data("resources/IrisData.xls", 150, shufle_data=False) returned_value = finnal.predict( predict_data.normalize_data(),
from utils.Data import Data from factories.NetworkFactory import NetworkFactory from utils.Tags import NetworkTags from utils.Functions import ActivaionFunction import time time_start = time.time() data = Data("resources/IrisDataTrain.xls", 125, shufle_data=True) data.label_iris_dat() normalized_data = data.normalize_data() print(normalized_data[0]) layers = [data.def_input_neurons(), 15, 10, data.def_output_neurons()] mlp = NetworkFactory.create(NetworkTags.MLPWithContiguousConnection, layers) mlp.train(data.normalize_data(), data.label_iris_dat(), repetitions=500, activation_function=ActivaionFunction.SIGMOID) predict_data = Data("resources/IrisData.xls", 150, shufle_data=False) returned_value = mlp.predict(predict_data.normalize_data(), predict_data.label_iris_dat(), activation_function=ActivaionFunction.SIGMOID) labels = predict_data.label_iris_dat() counter = 0 for i in range(len(returned_value)): print("label: {0}".format(labels[i])) print("output: {0}".format(returned_value[i]))