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

task_labels experience attribute type fix: now it is a list, not a set #1646

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions avalanche/benchmarks/scenarios/task_aware.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ def with_task_labels(obj):

def _add_task_labels(exp):
tls = exp.dataset.targets_task_labels.uniques
# tls is a set, we need to convert to list to call __getitem__
tls = list(tls)
if len(tls) == 1:
# tls is a set. we need to convert to list to call __getitem__
exp.task_label = list(tls)[0]
exp.task_label = tls[0]
exp.task_labels = tls
return exp

Expand Down
3 changes: 2 additions & 1 deletion tests/benchmarks/scenarios/test_task_aware.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

class TestsTaskAware(unittest.TestCase):
def test_taskaware(self):
"""Common use case: add tas labels to class-incremental benchmark."""
"""Common use case: add task labels to class-incremental benchmark."""
n_classes, n_samples_per_class, n_features = 10, 3, 7

for _ in range(10000):
Expand Down Expand Up @@ -58,6 +58,7 @@ def test_taskaware(self):
ci_train = bm_ci.train_stream
for eid, exp in enumerate(bm_ti.train_stream):
assert exp.task_label == eid
assert isinstance(exp.task_labels, list)
assert len(ci_train[eid].dataset) == len(exp.dataset)


Expand Down
Loading