Skip to content

Commit

Permalink
Have Tokenizers extend tf.Module
Browse files Browse the repository at this point in the history
This fixes #224 where tokenizers were unable to be saved from within custom Keras layers.

PiperOrigin-RevId: 315784812
  • Loading branch information
broken authored and tf-text-github-robot committed Jun 16, 2020
1 parent b72c60d commit 97c922a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions tensorflow_text/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,9 @@ py_test(
py_library(
name = "tokenization",
srcs = ["python/ops/tokenization.py"],
deps = [
# python/module tensorflow dep,
],
)

py_tf_text_library(
Expand Down
5 changes: 3 additions & 2 deletions tensorflow_text/python/ops/tokenization.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@

import abc

from tensorflow.python.module import module

# TODO(broken): Have this extend Module when it becomes public
class Tokenizer(object):

class Tokenizer(module.Module):
"""Base class for tokenizer implementations."""

__metaclass__ = abc.ABCMeta
Expand Down

0 comments on commit 97c922a

Please sign in to comment.