for rn in range(5): # rn == 0 no rotates if rn == 0: # output batch filenames NAME_train = '{}_BATCH_{}_T{}_{}'.format( var, size, domain, sea) NAME_valid = '{}_BATCH_{}_V{}_{}'.format( var, size, domain, sea) # random cropping + batch gen print('----- Training data process -----') FEATURE_train = pu.random_cropping(input_train_3d, keys_3d, input_2d, keys_2d, mask[domain], size, gap, ind_train, rnd_range=2) FEATURE_train = pu.feature_norm(FEATURE_train, method=norm) pu.batch_gen(FEATURE_train, batch_size, BATCH_dir, NAME_train, 0) print('----- Validation data process -----') FEATURE_valid = pu.random_cropping(input_valid_3d, keys_3d, input_2d, keys_2d, mask[domain],
num_train[domain] = 0 num_valid[domain] = 0 # output batch filenames NAME_train = '{}_BATCH_{}_T{}-{}_{}'.format( var, size, source, domain, sea) NAME_valid = '{}_BATCH_{}_V{}-{}_{}'.format( var, size, source, domain, sea) # random cropping + batch gen # print('----- Training data process -----') # FEATURE_train = pu.random_cropping(input_train_3d, keys_3d, input_2d, keys_2d, mask[domain], # size, gap, ind_train, rnd_range=2, clim=False) # FEATURE_train = pu.feature_norm(FEATURE_train, method=norm) # pu.batch_gen(FEATURE_train, batch_size, BATCH_dir, NAME_train, 0); print('----- Validation data process -----') FEATURE_valid = pu.random_cropping(input_valid_3d, keys_3d, input_2d, keys_2d, mask[domain], size, gap, ind_valid, rnd_range=2, clim=False) FEATURE_valid = pu.feature_norm(FEATURE_valid, method=norm) pu.batch_gen(FEATURE_valid, batch_size, BATCH_dir, NAME_valid, 0)
num_train = {}; num_valid = {} # aug ind (numbering augmented batches) for domain in domains: num_train[domain] = 0 num_valid[domain] = 0 # batch augmentation and gen with 90-degree rotations for rn in range(5): # rn == 0 no rotates if rn == 0: # output batch filenames NAME_train = '{}_BATCH_{}_T{}_{}'.format(var, size, domain, sea) NAME_valid = '{}_BATCH_{}_V{}_{}'.format(var, size, domain, sea) # random cropping + batch gen print('----- Training data process -----') FEATURE_train = pu.random_cropping(input_3d, keys_3d, input_2d, keys_2d, mask[domain], size, gap, ind_train, sparse_f=sparse_f) FEATURE_train = pu.feature_norm(FEATURE_train, method=norm) pu.batch_gen(FEATURE_train, batch_size, BATCH_dir, NAME_train, 0); print('----- Validation data process -----') FEATURE_valid = pu.random_cropping(input_3d, keys_3d, input_2d, keys_2d, mask[domain], size, gap, ind_valid, sparse_f=sparse_f) FEATURE_valid = pu.feature_norm(FEATURE_valid, method=norm) pu.batch_gen(FEATURE_valid, batch_size, BATCH_dir, NAME_valid, 0); else: print('Rotation round: {}'.format(rn)) # Feature rotations for key in keys_3d: input_3d[key] = np.rot90(input_3d[key], k=1, axes=(1, 2)) for key in keys_2d: input_2d[key] = np.rot90(input_2d[key], k=1)