cifar-10-100n icon indicating copy to clipboard operation
cifar-10-100n copied to clipboard

How to load side information in Tensorflow?

Open gortizji opened this issue 1 year ago • 0 comments

Hi,

I would like to load the side information and associate it with the correct sample in Tensorflow. What order do the side_info_cifar10N.csv and side_info_cifar100N.csv follow, the one of the PyTorch or the Tensorflow files?

And if they don't come in the Tensorflow order, should I load them like this?

import numpy as np
import pandas as pd

noise_file = np.load('./data/CIFAR-10_human_ordered.npy', allow_pickle=True)
random_label1 = noise_file.item().get('random_label1')

train_ds, test_ds = tfds.load('cifar10', split=['train','test'], as_supervised=True, batch_size = -1)
train_images, train_labels = tfds.as_numpy(train_ds) 

side_info_df = pd.read_csv('side_info_cifar10N.csv')
worker1_id = df['Worker1-id'].to_numpy()

# Reorder side information with correct order
image_order = np.load('image_order_c10.npy')
worker1_id_ordered = worker1_id[image_order // 10]

# Now, the indexing of all arrays matches correctly
first_example = (train_images[0], train_labels[0], worker1_id_ordered[0])

Thank you very much!

gortizji avatar Aug 12 '22 07:08 gortizji