def load_dataset(data_file=('%s/%s' % (DATA_DIR, DATA_FILE))): dataset = utils_backdoor.load_dataset(data_file, keys=['X_test', 'Y_test']) X_test = np.array(dataset['X_test'], dtype='float32') Y_test = np.array(dataset['Y_test'], dtype='float32') print('X_test shape %s' % str(X_test.shape)) print('Y_test shape %s' % str(Y_test.shape)) return X_test, Y_test
def load_dataset(data_file=('%s/%s' % (DATA_DIR, DATA_FILE))): dataset = utils_backdoor.load_dataset(data_file, keys=['X_test', 'Y_test']) X_test = np.array(dataset['X_test'], dtype='float32') Y_test = np.array(dataset['Y_test'], dtype='float32') if CHANNELS_FIRST: # X_test = np.moveaxis(X_test, -1, 1) X_test = np.rollaxis(X_test, 3, 1) print('X_test shape %s' % str(X_test.shape)) print('Y_test shape %s' % str(Y_test.shape)) return X_test, Y_test
def load_dataset(data_file=('%s/%s' % (DATA_DIR, DATA_FILE))): if not os.path.exists(data_file): print( "The data file does not exist. Please download the file and put in data/ directory from https://drive.google.com/file/d/1kcveaJC3Ra-XDuaNqHzYeomMvU8d1npj/view?usp=sharing" ) exit(1) dataset = utils_backdoor.load_dataset( data_file, keys=['X_train', 'Y_train', 'X_test', 'Y_test']) X_train = dataset['X_train'] Y_train = dataset['Y_train'] X_test = dataset['X_test'] Y_test = dataset['Y_test'] return X_train, Y_train, X_test, Y_test
def load_dataset(data_file=('%s/%s' % (DATA_DIR, DATA_FILE))): if not os.path.exists(data_file): print( "The data file does not exist. Please download the file and put in data/ directory from https://drive.google.com/file/d/1kcveaJC3Ra-XDuaNqHzYeomMvU8d1npj/view?usp=sharing" ) exit(1) dataset = utils_backdoor.load_dataset( data_file, keys=['X_train', 'Y_train', 'X_test', 'Y_test']) X_train = np.transpose(np.array(dataset['X_train'], dtype='float32'), (0, 3, 1, 2)) Y_train = np.array(dataset['Y_train'], dtype='int64') Y_train = np.asarray([np.where(r == 1)[0][0] for r in Y_train]) X_test = np.transpose(np.array(dataset['X_test'], dtype='float32'), (0, 3, 1, 2)) Y_test = np.array(dataset['Y_test'], dtype='int64') Y_test = np.asarray([np.where(r == 1)[0][0] for r in Y_test]) #tensor_x, tensor_y = torch.Tensor(X), torch.Tensor(Y) #dataset = torch.utils.data.TensorDataset(tensor_x, tensor_y) #generator = torch.utils.data.DataLoader(dataset, batch_size=BATCH_SIZE, shuffle=False) return X_train, Y_train, X_test, Y_test