lukasruff/Deep-SVDD-PyTorch

How can I get `min_max` value list in mnist.py?

rightx2 opened this issue · 1 comments

In your code, there is a constant variable, min_max in mnsit.py:

# Pre-computed min and max values (after applying GCN) from train data per class
min_max = [(-0.8826567065619495, 9.001545489292527),
           (-0.6661464580883915, 20.108062262467364),
           (-0.7820454743183202, 11.665100841080346),
           (-0.7645772083211267, 12.895051191467457),
           (-0.7253923114302238, 12.683235701611533),
           (-0.7698501867861425, 13.103278415430502),
           (-0.778418217980696, 10.457837397569108),
           (-0.7129780970522351, 12.057777597673047),
           (-0.8280402650205075, 10.581538445782988),
           (-0.7369959242164307, 10.697039838804978)]

I've tried to get this number by myself using a global_contrast_normalization function, but I couldn't get it. Here is what I've tried:

train_set = dsets.MNIST(root='data/', train=True, download=True)
test_set = dsets.MNIST(root='data/', train=False, download=True)

train_data = train_set.train_data.float()
train_label = train_set.train_labels.numpy()


# 1. Normalize whole data
data = train_data
label = train_label

digit = 0
given_index = np.where(label==digit)[0] 

data = global_contrast_normalization(data, scale='l1')
print(data[given_index].max())

# 2. Normalize label by label
data = train_data
label = train_label

digit = 0
given_index = np.where(label==digit)[0] 

data = global_contrast_normalization(data[given_index], scale='l1')
print(data.max())

But the values are different with the min_max values.

Did I miss something? Could you let me know how I can get that numbers?

I misunderstood the codes :(