Exemple #1
0
way = -1
shot = None

s_ver = 'V01'
build = 'MyModelV2'

db = 'mnist'
n_cls = INFO[db]['n_cls']
shape = INFO[db]['shape']

rpt = Reporter(file_dir='./my_report.log')

# %% Dataset loading
data = load_data(db)

X_train, X_test, y_train, y_test = get_fewshot(*data, shot, way)

X_train, y_train = shuffle(X_train, y_train)
X_test, y_test = shuffle(X_test, y_test)

X_train = reshape(X_train / 255.0, shape)
X_test = reshape(X_test / 255.0, shape)

# %% Generator section
traingen = MyTriplet(X_train, y_train, n_cls)
validgen = MyTriplet(X_test, y_test, n_cls)

# %% Schema creation
schema = load_schema(s_ver)
getattr(schema, 'build' + build)(shape, n_cls)
Exemple #2
0
from sklearn.utils import shuffle
from sklearn.neighbors import KNeighborsClassifier

if __name__ == "__main__":

    from __test_my_layer import MyLayerV1

    e_len = 128
    batch_size = 128

    db = INFO['fashion']
    shape = db['shape']
    n_cls = db['n_cls']

    X_train, X_test, y_train, y_test = get_fewshot(*load_data('fashion'),
                                                   shot=None)

    X_train, y_train = shuffle(X_train, y_train)
    X_test, y_test = shuffle(X_test, y_test)

    X_train = reshape(X_train / 255.0, shape)
    X_test = reshape(X_test / 255.0, shape)

    # %% CNN My Dual Model
    in_layer = layers.Input(shape=shape)

    conv_01 = layers.Conv2D(32, (3, 3))(in_layer)
    batch_01 = layers.BatchNormalization()(conv_01)
    active_01 = layers.Activation('relu')(batch_01)

    _01_out = MyLayerV1(8, 'sigmoid')(active_01)
Exemple #3
0
    rpt = Report()

    for db, db_opt in DATASETS.items():
        n_cls = INFORM[db]['n_cls']
        shape = INFORM[db]['shape']
        X_train, X_test, y_train, y_test = load_data(db)
        X_train = reshape(X_train / 255.0, shape)
        X_test = reshape(X_test / 255.0, shape)
        X_train, X_valid, y_train, y_valid = train_test_split(X_train,
                                                              y_train,
                                                              test_size=0.25,
                                                              stratify=y_train)
        plot_histogram(y_train, db + '_train')

        for shot in db_opt['shots']:
            _X_train, _y_train = get_fewshot(X_train, y_train, shot=shot)
            data = (_X_train, X_valid, _y_train, y_valid)

            for bld, bld_opt in METHODS.items():
                # With Augmentation
                rpt.write_dataset(db).write_shot(shot).flush()
                Run(rpt, bld, n_cls, shape, db_opt, bld_opt, *data, X_test,
                    y_test, db, shot, True)
                # Without Augmentation
                rpt.write_dataset(db).write_shot(shot).flush()
                Run(rpt, bld, n_cls, shape, db_opt, bld_opt, *data, X_test,
                    y_test, db, shot, False)
    rpt.flush()
    rpt.close()