Giter Site home page Giter Site logo

Comments (2)

QueuQ avatar QueuQ commented on July 30, 2024

as seen in the next code fragment, line 212, optimizer.step() is outside of the for loop, which iterates over the current task.

for batch_id, batch_data in enumerate(data_loader[task_i]):
smiles, bg, labels, masks = batch_data
bg = bg.to(f"cuda:{args['gpu']}")
labels, masks = labels.cuda(), masks.cuda()
logits = predict(args, self.net, bg)
# class balance
n_per_cls = [(labels == j).sum() for j in clss]
loss_w_ = [1. / max(i, 1) for i in n_per_cls]
loss_w_ = torch.tensor(loss_w_).to(device='cuda:{}'.format(args['gpu']))
# labels= labels.long()
for i, c in enumerate(clss):
labels[labels == c] = i
# Mask non-existing labels
loss = loss_criterion(logits[:, clss], labels.long(), weight=loss_w_).float()
self.optimizer.zero_grad()
loss.backward()
# check if gradient violates constraints
if len(self.observed_tasks) > 1:
# copy gradient
store_grad(self.net.parameters, self.grads, self.grad_dims, task_i)
indx = torch.cuda.LongTensor(self.observed_tasks[:-1])
dotp = torch.mm(self.grads[:, task_i].unsqueeze(0),
self.grads.index_select(1, indx))
if (dotp < 0).sum() != 0:
project2cone2(self.grads[:, task_i].unsqueeze(1),
self.grads.index_select(1, indx), self.margin)
# copy gradients back
overwrite_grad(self.net.parameters, self.grads[:, task_i],
self.grad_dims)
self.optimizer.step()

while in the same file, in line 296 and line 127, this step is inside the for loop.

Thanks for pointing out this issue. It should be a mistake, and we have corrected it and updated it. We tested the result of GEM with the updated code (on Aromaticity-CL, the only class-IL dataset), and got AP 5.2±1.1 AF -57.6±3.4. The AP decreases a little, and the AF increases. The previous code would skip some batches of data in each epoch, but since shuffle is used for the data loader, all data should get chance to be trained after multiple epochs. Now the corrected code would ensure that all batches are used in each epoch.

from cglb.

WeiWeic6222848 avatar WeiWeic6222848 commented on July 30, 2024

Thank you for the update

from cglb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.