Skip to content

Cannot import transformers with TF version 2.1.0 #213

@evandrosks

Description

@evandrosks

Hi @patrickvonplaten,

Thank you for your "How to generate text" blog post a couple of years ago. I'm not sure if there are any recent posts for text generation, but I noticed the TF version is outdated (TF 2.1) which results in the error below.

Upgrading to 2.3 works fine for me.

I also noticed in the README.md it's classified as a PyTorch example and not TF. Is this intentional?

AttributeError                            Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/transformers/file_utils.py in _get_module(self, module_name)
   2464         try:
-> 2465             return importlib.import_module("." + module_name, self.__name__)
   2466         except Exception as e:

13 frames
AttributeError: module 'tensorflow_core.python.keras.api._v2.keras.activations' has no attribute 'swish'

The above exception was the direct cause of the following exception:

RuntimeError                              Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/transformers/file_utils.py in _get_module(self, module_name)
   2467             raise RuntimeError(
   2468                 f"Failed to import {self.__name__}.{module_name} because of the following error (look up to see its traceback):\n{e}"
-> 2469             ) from e
   2470 
   2471     def __reduce__(self):

RuntimeError: Failed to import transformers.models.gpt2.modeling_tf_gpt2 because of the following error (look up to see its traceback):
module 'tensorflow_core.python.keras.api._v2.keras.activations' has no attribute 'swish'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions