Skip to content

Conversation

@MohamedAliBouhaouala
Copy link

Summary

The following PR fixes the logic for accessing class_similarities in the loss config. Previously, the code assumed a fixed structure, which could break when feature_config.loss was a dict or an object. The updated logic handles both cases safely.
While training my model with class_similarities, I encountered this exception:

 TypeError: argument of type 'SoftmaxCrossEntropyLossConfig' is not iterable

Changes

  • Added conditional checks to support both dict and object access styles for feature_config.loss.
  • Ensured compatibility with different configuration formats (e.g., YAML or Python objects).

Additional Note

I also modified .pre-commit-config.yaml based on a previous PR 4039 to ensure that pre-commit hooks pass correctly. This change was required to avoid commit failures due to missing staged updates in the pre-commit config.

@MohamedAliBouhaouala MohamedAliBouhaouala changed the title fix: handle loss config access for both dict and object types for cla… fix: handle loss config access for class_similarities Jul 2, 2025
@MohamedAliBouhaouala MohamedAliBouhaouala changed the base branch from master to pre-commit-ci-update-config July 8, 2025 16:21
@MohamedAliBouhaouala MohamedAliBouhaouala changed the base branch from pre-commit-ci-update-config to master July 8, 2025 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant