From 7d7fe4997f83d6d858849a659302b9fdc32c3337 Mon Sep 17 00:00:00 2001 From: Funtowicz Morgan Date: Tue, 12 May 2020 19:02:46 +0000 Subject: [PATCH] Allow BatchEncoding to be initialized empty. (#4316) * Allow BatchEncoding to be initialized empty. This is required by recent changes introduced in TF 2.2. * Attempt to unpin Tensorflow to 2.2 with the previous commit. --- setup.py | 4 ++-- src/transformers/tokenization_utils.py | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/setup.py b/setup.py index f0f9af8bf5..ac4722c450 100644 --- a/setup.py +++ b/setup.py @@ -67,8 +67,8 @@ extras = {} extras["mecab"] = ["mecab-python3"] extras["sklearn"] = ["scikit-learn"] -extras["tf"] = ["tensorflow <= 2.1"] -extras["tf-cpu"] = ["tensorflow-cpu <= 2.1"] +extras["tf"] = ["tensorflow"] +extras["tf-cpu"] = ["tensorflow-cpu"] extras["torch"] = ["torch"] extras["serving"] = ["pydantic", "uvicorn", "fastapi", "starlette"] diff --git a/src/transformers/tokenization_utils.py b/src/transformers/tokenization_utils.py index a2d258afad..e929d0273c 100644 --- a/src/transformers/tokenization_utils.py +++ b/src/transformers/tokenization_utils.py @@ -173,7 +173,11 @@ class BatchEncoding(UserDict): """ - def __init__(self, data: Dict[str, Any], encoding: Optional[Union[EncodingFast, Sequence[EncodingFast]]] = None): + def __init__( + self, + data: Optional[Dict[str, Any]] = None, + encoding: Optional[Union[EncodingFast, Sequence[EncodingFast]]] = None, + ): super().__init__(data) if isinstance(encoding, EncodingFast):