Пример #1
0
        struct.use_dropout = True
        struct.dropout_value = 0.1 * (
            j + 1)  # Pour avoir des dropouts à 0.1, puis 0.2, puis 0.3
        struct.dropout_indexes = [
            x + 1 for x in range(struct.nb_hidden_layers)
        ]
        model = [create_custom_mlp(struct)]
        desc = [getMlpStructAsString(struct)]

        print(desc[0])
        test_models('mlp_best_models_with_l2_and_dropout',
                    model,
                    desc,
                    train_data,
                    train_labels,
                    val_data,
                    val_labels,
                    epochs_p=epochs,
                    batch_size_p=8192)
        clear_session()  #clear tf GPU memory

    for j in range(3):
        struct.use_l1l2_regularisation_hidden_layers = True
        struct.regulization_indexes = [
            x + 1 for x in range(struct.nb_hidden_layers)
        ]
        struct.l2_value = 0.002
        struct.l1_value = 0.0

        struct.use_dropout = True
from cifar10.models.ModelTester import test_models
from tensorflow.keras.datasets import cifar10
from cifar10.models.UNet import *

from tensorflow.keras.backend import clear_session

if __name__ == "__main__":
    (train_data, train_labels), (val_data, val_labels) = cifar10.load_data()

    epochs = [40]

    for i in range(3):
        struct = generateRandoUNetStruc(min_nb_layers=7, max_nb_layers=7)
        struct.use_MaxPooling2D = True
        struct.MaxPooling2D_position = [1, 2, 3]
        model = [create_unet(struct)]
        desc = [getUNetStructAsString(struct)]
        print(desc[0])
        test_models('model_3',
                    model,
                    desc,
                    train_data,
                    train_labels,
                    val_data,
                    val_labels,
                    epochs_p=epochs,
                    batch_size_p=256,
                    save_image=True,
                    save_model=True)
        clear_session()
    #                                         [0.025], [True], [True], [0.012], [0.025], [[6]],
    #                                         ['sparse_categorical_crossentropy'], ['Adam'], [['accuracy']])
    #
    # test_models('cnn_8_8_OOOO_32_128', modelcnn, desccnn, train_images, train_labels, test_images, test_labels,
    #             epochs_p=epochs,
    #             batch_size_p=256, save_image=True)
    # clear_session()
    #testes 28/01/2020 08h22
    epochs=[200]
    (modelcnn, desccnn) = generateCNNModels([8], [[(128, 4),(128, 4),(64, 4),(64, 4),(64, 4),(32, 4),(32, 4),(32, 4)]],
                                            ['relu'], ['softmax'], ['same'], [True], [[1, 4]], [4], [True], [[0, 4, 6]],
                                            [0.025], [True], [True], [0.012], [0.025], [[2,7]],
                                            ['sparse_categorical_crossentropy'], ['Adam'], [['accuracy']])

    test_models('cnn_8_8_OOOO_32_128', modelcnn, desccnn, train_images, train_labels, test_images, test_labels,
                epochs_p=epochs,
                batch_size_p=256, save_image=True)
    clear_session()

    (modelcnn, desccnn) = generateCNNModels([8], [
        [(128, 4), (128, 4), (64, 4), (64, 4), (64, 4), (32, 4), (32, 4), (32, 4)]],
                                            ['relu'], ['softmax'], ['same'], [True], [[1, 4]], [4], [True], [[0, 4, 6]],
                                            [0.028], [True], [True], [0.012], [0.025], [[2,3,7]],
                                            ['sparse_categorical_crossentropy'], ['Adam'], [['accuracy']])

    test_models('cnn_8_8_OOOO_32_128', modelcnn, desccnn, train_images, train_labels, test_images, test_labels,
                epochs_p=epochs,
                batch_size_p=256, save_image=True)
    clear_session()

    (modelcnn, desccnn) = generateCNNModels([8], [
     clear_session()
     struct = generateRandoCNNStruc(use_maxpool=False,
                                    use_dropout=False,
                                    use_l1l2_conv=True,
                                    use_l1l2_output=False,
                                    min_nb_layers=3,
                                    max_nb_layers=8,
                                    min_filter_size=32,
                                    max_filter_size=64)
     model = [create_CNN_model(struct)]
     desc = [getcnnStructAsString(struct)]
     test_models('cnn_3_8_NNON_32_64',
                 model,
                 desc,
                 train_images,
                 train_labels,
                 test_images,
                 test_labels,
                 epochs_p=epochs,
                 batch_size_p=256,
                 save_image=True)
     del model
     del desc
 # ######################## CNN 3-8 O O O O 32 64 #########################
 for i in range(3):
     clear_session()
     struct = generateRandoCNNStruc(use_maxpool=True,
                                    use_dropout=True,
                                    use_l1l2_conv=True,
                                    use_l1l2_output=True,
                                    min_nb_layers=3,
                                    max_nb_layers=8,
from tensorflow.keras.datasets import *

from cifar10.models.LIN import create_lin_model, getLinStructAsString
from cifar10.models.ModelTester import test_models
from cifar10.models.structurer.LinearStructurer import LinearStructurer

if __name__ == "__main__":
    (train_data, train_labels), (val_data, val_labels) = cifar10.load_data()
    classes = [
        'plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship',
        'truck'
    ]
    epochs = [100]

    struct = LinearStructurer()
    desc = [getLinStructAsString(struct)]
    linear_model = [create_lin_model(struct)]
    test_models('lin',
                linear_model,
                desc,
                train_data,
                train_labels,
                val_data,
                val_labels,
                epochs_p=epochs,
                batch_size_p=1024,
                save_model=True)
        'airplane', 'automobile', 'bird', 'cat', 'deer', 'dog', 'frog',
        'horse', 'ship', 'truck'
    ]

    #script du 06/02/2020:
    for e in (30, 35):
        (modelcnn, desccnn) = generateCNNModels(
            [3], [[(128, 3), (64, 3), (32, 3)]], ['relu'], ['softmax'],
            ['same'], [True], [[2]], [3], [True], [[0]], [0.25], [True],
            [True], [0.030], [0.090], [[1, 3]],
            ['sparse_categorical_crossentropy'], ['Adam'], [['accuracy']])
        test_models('cnn_1_3_OOOO_32_128',
                    modelcnn,
                    desccnn,
                    train_images,
                    train_labels,
                    test_images,
                    test_labels,
                    epochs_p=[e],
                    batch_size_p=256,
                    save_image=True)
        clear_session()

    # ##Scirpt du 26 01 2020 11h40:
    # # ######################## CNN 1-3 N N N N 32 64 #########################
    # for i in range(3):
    #     clear_session()
    #     struct = generateRandoCNNStruc(use_maxpool=False, use_dropout=False, use_l1l2_conv=False, use_l1l2_output=False,
    #                                    min_nb_layers=1, max_nb_layers=3, min_filter_size=32, max_filter_size=64)
    #     model = [create_CNN_model(struct)]
    #     desc = [getcnnStructAsString(struct)]
    #     test_models('cnn_1_3_NNNN_32_64', model, desc, train_images, train_labels, test_images, test_labels,
Пример #7
0
from __future__ import absolute_import, division, print_function, unicode_literals
from tensorflow.keras import layers
from tensorflow.keras.backend import clear_session
import tensorflow as tf

from cifar10.models.CNN import *
from cifar10.models.ModelTester import test_models

if __name__ == "__main__":
    #déclaration des param:
    epochs=[30]
    #importation des données:
    (train_images, train_labels), (test_images, test_labels) = tf.keras.datasets.cifar10.load_data()
    #définition des noms des classes:
    class_names = ['airplane', 'automobile', 'bird', 'cat', 'deer',
                   'dog', 'frog', 'horse', 'ship', 'truck']

    epochs=[50]
    for i in range(3):
        clear_session()
        cnn_str=generateRandoCNNStruc(use_maxpool=False,use_l1l2_conv=False,use_l1l2_output=True,use_dropout=False,min_nb_layers=3,max_nb_layers=4,min_filter_size=32,max_filter_size=128)
        cnn_model=[create_CNN_model(cnn_str)]
        cnn_desc=[getcnnStructAsString(cnn_str)]
        test_models('cnn_3_4_N_N_O_N_32_128', cnn_model, cnn_desc, train_images, train_labels, test_images, test_labels,
                    epochs_p=epochs,
                    batch_size_p=1024, save_image=True)
        del cnn_model
        del cnn_desc
Пример #8
0
    #     test_models('cnn_5_5_ONON_32128', modelcnn, desccnn, train_images, train_labels, test_images, test_labels,
    #                 epochs_p=[e],
    #                 batch_size_p=256, save_image=True)
    #     clear_session()

    #tested on 8/2/2020 à 12h08
    #5;(64, 3) (128, 3) (64, 3) (32, 3) (32, 3);selu;softmax;same;True;3;2 4;False;0;0;True;False;0.005;0.06;1 3
    e=[45]
    for i in (0.15,0.25,0.35,0.45):
        (modelcnn, desccnn) = generateCNNModels([5], [
                    [(64, 3), (128, 3),(64, 3), (32, 3) ,(32, 3)]],
                                                        ['selu'], ['softmax'], ['same'], [True], [[2,4]], [3], [False], [[0]],
                                                        [0], [True], [True], [i], [0.099], [[1,3]],
                                                        ['sparse_categorical_crossentropy'], ['Adam'], [['accuracy']])
        test_models('cnn_5_5_OOON_32128', modelcnn, desccnn, train_images, train_labels, test_images, test_labels,
                            epochs_p=[e],
                            batch_size_p=256, save_image=True)
        clear_session()

    for e in (30,35,40,45,50):
        (modelcnn, desccnn) = generateCNNModels([6], [
            [(64, 3), (128, 3), (128, 3) ,(64, 3), (32, 3) ,(32, 3)]],
                                                ['relu'], ['softmax'], ['same'], [True], [[4,5]], [3], [True], [[0]],
                                                [0.35], [True], [True], [0.05], [0.095], [[1,4]],
                                                ['sparse_categorical_crossentropy'], ['Adam'], [['accuracy']])
        test_models('cnn_6_6_OOOO_32128', modelcnn, desccnn, train_images, train_labels, test_images, test_labels,
                    epochs_p=[e],
                    batch_size_p=256, save_image=True)
        clear_session()

    for e in (25,30,35,40,45,50):