8a0565f97357dd32a3b4fc357f61ba5392f75144,code/HardNet.py,TripletPhotoTour,generate_triplets,#,194

Before Change


        for x in tqdm(range(num_triplets)):
            if len(already_idxs) >= args.batch_size:
                already_idxs = set()
            c1 = np.random.randint(0, n_classes - 1)
            while c1 in already_idxs:
                c1 = np.random.randint(0, n_classes - 1)
            already_idxs.add(c1)
            c2 = np.random.randint(0, n_classes - 1)
            while c1 == c2:
                c2 = np.random.randint(0, n_classes - 1)
            if len(indices[c1]) == 2:  // hack to speed up process
                n1, n2 = 0, 1
            else:
                n1 = np.random.randint(0, len(indices[c1]) - 1)
                n2 = np.random.randint(0, len(indices[c1]) - 1)
                while n1 == n2:
                    n2 = np.random.randint(0, len(indices[c1]) - 1)
            n3 = np.random.randint(0, len(indices[c2]) - 1)
            triplets.append([indices[c1][n1], indices[c1][n2], indices[c2][n3]])
        return torch.LongTensor(np.array(triplets))

After Change


            if len(indices[c1]) == 2:  // hack to speed up process
                n1, n2 = 0, 1
            else:
                n1 = np.random.randint(0, len(indices[c1]))
                n2 = np.random.randint(0, len(indices[c1]))
                while n1 == n2:
                    n2 = np.random.randint(0, len(indices[c1]))
            n3 = np.random.randint(0, len(indices[c2]))
            triplets.append([indices[c1][n1], indices[c1][n2], indices[c2][n3]])
        return torch.LongTensor(np.array(triplets))
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 4

Non-data size: 9

Instances


Project Name: DagnyT/hardnet
Commit Name: 8a0565f97357dd32a3b4fc357f61ba5392f75144
Time: 2017-10-28
Author: anastasiya.mishchuk@gmail.com
File Name: code/HardNet.py
Class Name: TripletPhotoTour
Method Name: generate_triplets


Project Name: DagnyT/hardnet
Commit Name: 8a0565f97357dd32a3b4fc357f61ba5392f75144
Time: 2017-10-28
Author: anastasiya.mishchuk@gmail.com
File Name: code/HardNet.py
Class Name: TripletPhotoTour
Method Name: generate_triplets


Project Name: DagnyT/hardnet
Commit Name: c446e3daad523d25b19d48b1163d54af48fa271b
Time: 2017-10-28
Author: anastasiya.mishchuk@gmail.com
File Name: code/HardNetMultipleDatasets.py
Class Name: TotalDatasetsLoader
Method Name: generate_triplets