You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@almazan
How do you calculate the derivative of the similarity matrix S and matrix D?I calculated it automatically through pytorch, but the parameter update seems to be a bit problematic.
'''
desc_db = Variable(torch.cuda.FloatTensor(desc_db),requires_grad=True)
scores = torch.matmul(desc_db,desc_db.t())
vaild_index = np.arange(batch_sizeindex,batch_size(index+1),1)
Y = np.array(Y_all)[vaild_index][:,vaild_index]
Y = torch.cuda.FloatTensor(np.array(Y))
rank_loss = criterion(scores, Y)
rank_loss.backward()
loss += rank_loss.item()
net.train()
for i,img in enumerate(imgs):
img = Variable(img.cuda(),requires_grad=True)
desc = net(img.unsqueeze(dim=0))
one_grad = desc_db.grad[i].unsqueeze(0)
desc.unsqueeze(0).backward(one_grad)
optimizer.step()
scheduler_mul.step()
optimizer.zero_grad()
lr = scheduler_mul.get_lr()[0]
'''
The text was updated successfully, but these errors were encountered:
@almazan
How do you calculate the derivative of the similarity matrix S and matrix D?I calculated it automatically through pytorch, but the parameter update seems to be a bit problematic.
'''
desc_db = Variable(torch.cuda.FloatTensor(desc_db),requires_grad=True)
scores = torch.matmul(desc_db,desc_db.t())
vaild_index = np.arange(batch_sizeindex,batch_size(index+1),1)
Y = np.array(Y_all)[vaild_index][:,vaild_index]
Y = torch.cuda.FloatTensor(np.array(Y))
rank_loss = criterion(scores, Y)
rank_loss.backward()
loss += rank_loss.item()
net.train()
for i,img in enumerate(imgs):
img = Variable(img.cuda(),requires_grad=True)
desc = net(img.unsqueeze(dim=0))
one_grad = desc_db.grad[i].unsqueeze(0)
desc.unsqueeze(0).backward(one_grad)
optimizer.step()
scheduler_mul.step()
optimizer.zero_grad()
lr = scheduler_mul.get_lr()[0]
'''
The text was updated successfully, but these errors were encountered: