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

Doc fixes #1530

Merged
merged 1 commit into from
Mar 28, 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
2 changes: 1 addition & 1 deletion keras_nlp/models/backbone.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def from_config(cls, config):

@classproperty
def presets(cls):
"""List builtin presets for a `Task` subclass."""
"""List built-in presets for a `Task` subclass."""
presets = list_presets(cls)
for subclass in list_subclasses(cls):
presets.update(subclass.presets)
Expand Down
4 changes: 3 additions & 1 deletion keras_nlp/models/preprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class Preprocessor(PreprocessingLayer):
`(x, y, sample_weight)` tuples. Where `x` contains token id sequences with
some

This class can be subclassed to implement
This class can be subclassed similar to any `keras.layers.Layer`, by
defining `build()`, `call()` and `get_config()` methods. All subclasses
should set the `tokenizer` property on construction.
"""

tokenizer_cls = None
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def from_config(cls, config):

@classproperty
def presets(cls):
"""List builtin presets for a `Task` subclass."""
"""List built-in presets for a `Task` subclass."""
presets = list_presets(cls)
# We can also load backbone presets.
if cls.backbone_cls is not None:
Expand Down
2 changes: 1 addition & 1 deletion keras_nlp/tokenizers/tokenizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def call(self, inputs, *args, training=None, **kwargs):

@classproperty
def presets(cls):
"""List builtin presets for a `Task` subclass."""
"""List built-in presets for a `Task` subclass."""
presets = list_presets(cls)
for subclass in list_subclasses(cls):
presets.update(subclass.presets)
Expand Down
7 changes: 6 additions & 1 deletion keras_nlp/utils/preset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,19 @@


def register_presets(presets, classes):
"""Register built-in presets for a set of classes.

Note that this is intended only for models and presets shipped in the
library itself.
"""
for preset in presets:
BUILTIN_PRESETS[preset] = presets[preset]
for cls in classes:
BUILTIN_PRESETS_FOR_CLASS[cls][preset] = presets[preset]


def list_presets(cls):
"""Find all registered builtin presets for a class."""
"""Find all registered built-in presets for a class."""
return dict(BUILTIN_PRESETS_FOR_CLASS[cls])


Expand Down
Loading