MCPcopy Create free account
hub / github.com/pytorch/examples / group_examples

Method group_examples

siamese_network/main.py:97–113  ·  view source on GitHub ↗

To ease the accessibility of data based on the class, we will use `group_examples` to group examples based on class. Every key in `grouped_examples` corresponds to a class in MNIST dataset. For every key in `grouped_examples`, every va

(self)

Source from the content-addressed store, hash-verified

95 self.group_examples()
96
97 def group_examples(self):
98 """
99 To ease the accessibility of data based on the class, we will use `group_examples` to group
100 examples based on class.
101
102 Every key in `grouped_examples` corresponds to a class in MNIST dataset. For every key in
103 `grouped_examples`, every value will conform to all of the indices for the MNIST
104 dataset examples that correspond to that key.
105 """
106
107 # get the targets from MNIST dataset
108 np_arr = np.array(self.dataset.targets.clone(), dtype=None, copy=None)
109
110 # group examples based on class
111 self.grouped_examples = {}
112 for i in range(0,10):
113 self.grouped_examples[i] = np.where((np_arr==i))[0]
114
115 def __len__(self):
116 return self.data.shape[0]

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected