Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LaMAMLv2 buffer now uses subset instead of indexing #1601

Merged
merged 2 commits into from
Feb 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions avalanche/training/supervised/lamaml_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ def __init__(
buffer_mb_size=buffer_mb_size,
device=device,
)

self.model.apply(init_kaiming_normal)

def _before_training_exp(self, **kwargs):
Expand Down Expand Up @@ -305,16 +304,15 @@ def __len__(self):

def get_buffer_batch(self):
rnd_ind = torch.randperm(len(self))[: self.buffer_mb_size]
buff_x = torch.cat(
[self.storage_policy.buffer[i][0].unsqueeze(0) for i in rnd_ind]
).to(self.device)
buff_y = torch.LongTensor(
[self.storage_policy.buffer[i][1] for i in rnd_ind]
).to(self.device)
buff_t = torch.LongTensor(
[self.storage_policy.buffer[i][2] for i in rnd_ind]
).to(self.device)

buff = self.storage_policy.buffer.subset(rnd_ind)
buff_x, buff_y, buff_t = [], [], []
for bx, by, bt in buff:
buff_x.append(bx)
buff_y.append(by)
buff_t.append(bt)
buff_x = torch.stack(buff_x, dim=0).to(self.device)
buff_y = torch.tensor(buff_y).to(self.device).long()
buff_t = torch.tensor(buff_t).to(self.device).long()
return buff_x, buff_y, buff_t


Expand Down
Loading