Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cords/utils/data/datasets/SL/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,30 +466,30 @@ def create_imbalance(x_trn, y_trn, x_val, y_val, x_tst, y_tst, num_cls, ratio, s
subset_idxs = rng.choice(np.where(y_trn == i)[0], size=min_samples, replace=False)
else:
subset_idxs = np.where(y_trn == i)[0]
x_trn_new = np.row_stack((x_trn_new, x_trn[subset_idxs]))
y_trn_new = np.row_stack((y_trn_new, y_trn[subset_idxs].reshape(-1, 1)))
x_trn_new = np.vstack((x_trn_new, x_trn[subset_idxs]))
y_trn_new = np.vstack((y_trn_new, y_trn[subset_idxs].reshape(-1, 1)))
max_samples = int(np.max(val_samples_per_class))
for i in range(num_cls):
y_class = np.where(y_val == i)[0]
if i == 0:
subset_ids = rng.choice(y_class, size=max_samples - y_class.shape[0], replace=True)
x_val_new = np.row_stack((x_val, x_val[subset_ids]))
y_val_new = np.row_stack((y_val.reshape(-1, 1), y_val[subset_ids].reshape(-1, 1)))
x_val_new = np.vstack((x_val, x_val[subset_ids]))
y_val_new = np.vstack((y_val.reshape(-1, 1), y_val[subset_ids].reshape(-1, 1)))
else:
subset_ids = rng.choice(y_class, size=max_samples - y_class.shape[0], replace=True)
x_val_new = np.row_stack((x_val, x_val_new, x_val[subset_ids]))
y_val_new = np.row_stack((y_val.reshape(-1, 1), y_val_new, y_val[subset_ids].reshape(-1, 1)))
x_val_new = np.vstack((x_val, x_val_new, x_val[subset_ids]))
y_val_new = np.vstack((y_val.reshape(-1, 1), y_val_new, y_val[subset_ids].reshape(-1, 1)))
max_samples = int(np.max(tst_samples_per_class))
for i in range(num_cls):
y_class = np.where(y_tst == i)[0]
if i == 0:
subset_ids = rng.choice(y_class, size=max_samples - y_class.shape[0], replace=True)
x_tst_new = np.row_stack((x_tst, x_tst[subset_ids]))
y_tst_new = np.row_stack((y_tst.reshape(-1, 1), y_tst[subset_ids].reshape(-1, 1)))
x_tst_new = np.vstack((x_tst, x_tst[subset_ids]))
y_tst_new = np.vstack((y_tst.reshape(-1, 1), y_tst[subset_ids].reshape(-1, 1)))
else:
subset_ids = rng.choice(y_class, size=max_samples - y_class.shape[0], replace=True)
x_tst_new = np.row_stack((x_tst, x_tst_new, x_tst[subset_ids]))
y_tst_new = np.row_stack((y_tst.reshape(-1, 1), y_tst_new, y_tst[subset_ids].reshape(-1, 1)))
x_tst_new = np.vstack((x_tst, x_tst_new, x_tst[subset_ids]))
y_tst_new = np.vstack((y_tst.reshape(-1, 1), y_tst_new, y_tst[subset_ids].reshape(-1, 1)))

return x_trn_new, y_trn_new.reshape(-1), x_val_new, y_val_new.reshape(-1), x_tst_new, y_tst_new.reshape(-1)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ def __repr__(self):
"""
def numpy_batch_gcn(images, multiplier=55, eps=1e-10):
# global contrast normalization
images = images.astype(np.float)
images = images.astype(float)
images -= images.mean(axis=(1,2,3), keepdims=True)
per_image_norm = np.sqrt(np.square(images).sum((1,2,3), keepdims=True))
per_image_norm[per_image_norm < eps] = 1
Expand Down