Пример #1
0
def classify_XOR():
    #Load Dataset
    P, T, Ptest, Ttest = dts.loadDataset_XOR()

    input_shape = (P.shape[1], )
    output_shape = T.shape[1]  # Number of Dense neurons at output layer

    ### Build Model
    dendral_neurons = 6
    lr = 0.08971484393708822
    activation = 'tanh'

    model = bm.build_HybridModel_MLNN(dendral_neurons, activation, input_shape,
                                      output_shape)

    [hist, train_time] = bm.train_HybridModel_MLNN(model,
                                                   lr,
                                                   P,
                                                   T,
                                                   Ptest,
                                                   Ttest,
                                                   batch_size=512,
                                                   nb_epoch=100,
                                                   v_verbose=False)

    print("\n\t Dataset XOR: ")

    print("\n\t Classificacion: " + str(hist.history['val_acc'][-1]))

    plt_util.my_plot_train_loss(hist)
Пример #2
0
def classify_2C_5L_Spiral():
    #Load Dataset
    P, T, Ptest, Ttest = dts.loadDataset_Espiral_2Class_N_Loops()

    input_shape = (P.shape[1], )
    output_shape = T.shape[1]  # Number of Dense neurons at output layer

    ### Build Model
    dendral_neurons = 250
    lr = 0.2
    activation = 'tanh'

    batch_size = 512

    model = bm.build_HybridModel_MLNN(dendral_neurons, activation, input_shape,
                                      output_shape)

    [hist, train_time] = bm.train_HybridModel_MLNN(model,
                                                   lr,
                                                   P,
                                                   T,
                                                   Ptest,
                                                   Ttest,
                                                   batch_size=batch_size,
                                                   nb_epoch=1000,
                                                   v_verbose=False)

    print("\n\t Dataset 2 class  5 Loops  spiral : ")

    print("\n\t Classificacion: " + str(hist.history['val_acc'][-1]))

    plt_util.my_plot_train_loss(hist)

    plt_util.plot_decision_boundary_2_class(P,
                                            model,
                                            batch_size,
                                            h=0.05,
                                            half_dataset=True,
                                            expand=0.5,
                                            x_lim=45,
                                            y_lim=45)