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)
from tensorflow.keras import backend as K from tensorflow.keras.utils import to_categorical from tensorflow.keras.callbacks import EarlyStopping from sklearn.neighbors import KNeighborsClassifier if __name__ == "__main__": embed_size = 128 db = INFO['fashion'] shape = db['shape'] n_cls = db['n_cls'] X_train, X_test, y_train, y_test = load_data('fashion') 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) conv_02 = layers.Conv2D(32, (3, 3))(active_01) batch_02 = layers.BatchNormalization()(conv_02) active_02 = layers.Activation('relu')(batch_02)
# %% Initialization 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)