tripletnet.py
def accuracy(pos_samples, neg_samples):
    """ pos_samples: Distance between positive pair
        neg_samples: Distance between negative pair
    """
    is_cuda = pos_samples.is_cuda
    margin = 0
    pred = (pos_samples - neg_samples - margin).cpu().data
    acc = (pred > 0).sum()*1.0/pos_samples.size()[0]
    acc = torch.from_numpy(np.array([acc], np.float32))
    if is_cuda:
        acc = acc.cuda()
    
    return Variable(acc)
 pos_samples: Distance between positive pair
        neg_samples: Distance between negative pair
    
Distance between positive pair
neg_samples: Distance between negative pair
Distance between positive pair neg_samples : Distance between negative pair
def accuracy(pos_samples, neg_samples):
    is_cuda = pos_samples.is_cuda
    margin = 0
    pred = (pos_samples - neg_samples - margin).cpu().data
    acc = (pred > 0).sum()*1.0/pos_samples.size()[0]
    acc = torch.from_numpy(np.array([acc], np.float32))
    if is_cuda:
        acc = acc.cuda()
    return Variable(acc)
def accuracy ( pos_samples , neg_samples ) : is_cuda = pos_samples . is_cuda margin = 0 pred = ( pos_samples - neg_samples - margin ) . cpu ( ) . data acc = ( pred > 0 ) . sum ( ) * 1.0 / pos_samples . size ( ) [ 0 ] acc = torch . from_numpy ( np . array ( [ acc ] , np . float32 ) ) if is_cuda : acc = acc . cuda ( ) return Variable ( acc )
pos_samples: Distance between positive pair
neg_samples: Distance between negative pair
pos_samples : Distance between positive pair neg_samples : Distance between negative pair
""" pos_samples: Distance between positive pair
        neg_samples: Distance between negative pair
    """
pos_samples
neg_samples