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.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])