Skip to content

Commit 01fff99

Browse files
jbischofchenmoneygithub
authored andcommitted
Init _backbone, _tokenizer and _preprocessor in Task (keras-team#899)
* Init _backbone in Task * Fix `preprocessor` as well * format * Fix `_tokenizer` * Chain to super() first
1 parent 8fe7ada commit 01fff99

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

keras_nlp/models/preprocessor.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
class Preprocessor(keras.layers.Layer):
2323
"""Base class for model preprocessors."""
2424

25+
def __init__(self, *args, **kwargs):
26+
super().__init__(*args, **kwargs)
27+
self._tokenizer = None
28+
2529
@property
2630
def tokenizer(self):
2731
"""The tokenizer used to tokenize strings."""

keras_nlp/models/task.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
class Task(PipelineModel):
3030
"""Base class for Task models."""
3131

32+
def __init__(self, *args, **kwargs):
33+
super().__init__(*args, **kwargs)
34+
self._backbone = None
35+
self._preprocessor = None
36+
3237
def preprocess_samples(self, x, y=None, sample_weight=None):
3338
return self.preprocessor(x, y=y, sample_weight=sample_weight)
3439

0 commit comments

Comments
 (0)