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

Take two of #1812, simpler classifier head loading #1823

Merged

Conversation

mattdangerw
Copy link
Member

Let's get rid of load_task_extras, which is a bad and confusing name. Instead, we will adopt some behavior that is specific to classifiers, but a lot simpler.

# Random head.
classifier = ImageClassifier.from_preset("resnet50", num_classes=2)
# Pretrained head.
classifier = ImageClassifier.from_preset("resnet50")
# Error, must provide num_classes.
classifier = TextClassifier.from_preset("bert_base_en")

Let's get rid of `load_task_extras`, which is a bad and confusing name.
Instead, we will adopt some behavior that is specific to classifiers,
but a lot simpler.

```python
# Random head.
classifier = ImageClassifier.from_preset("resnet50", num_classes=2)
# Pretrained head.
classifier = ImageClassifier.from_preset("resnet50")
# Error, must provide num_classes.
classifier = TextClassifier.from_preset("bert_base_en")
```
Copy link
Member

@SamanehSaadat SamanehSaadat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Matt!
Just left some nit comments!

keras_nlp/src/models/task.py Outdated Show resolved Hide resolved
keras_nlp/src/models/task_test.py Outdated Show resolved Hide resolved
keras_nlp/src/models/text_classifier.py Outdated Show resolved Hide resolved
@mattdangerw mattdangerw merged commit 29818cb into keras-team:master Sep 12, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kokoro:force-run Runs Tests on GPU
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants