Skip to content

Directly use the Task object as an hash instead of its name  #88

@MaxenceLarose

Description

@MaxenceLarose

To improve the code, we can replace the usage of task.name as the key in mappings with simply task. This modification can be a bit complex since task.name is used throughout the codebase. However, it is still achievable with careful consideration and replacement in all relevant places. For example :

losses = {task.name: task.criterion(pred_batch[task.name], y_batch[task.name]) for task in self.criterion.tasks}

We should only use the task instead, like :

losses = {task: task.criterion(pred_batch[task], y_batch[task]) for task in self.criterion.tasks}

By using task directly as the key, we eliminate the need for accessing task.name every time, which simplifies the code and improves its readability.

Keep in mind that after making this change, you need to update all other parts of the code where task.name is used. This may involve modifying any references to task.name in other parts of the codebase, such as variable assignments or function calls, to use task directly.

It's important to thoroughly test the modified code to ensure that it functions correctly and doesn't introduce any new issues.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions