当我尝试在python 3.6.7
和中导入 sentence_transformers 时出现以下错误tensorflow==2.3.0
。有人可以帮我吗?似乎这是变压器包中的错误。
import sentence_transformers
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/__init__.py", line 3, in <module>
from .datasets import SentencesDataset, SentenceLabelDataset, ParallelSentencesDataset
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/__init__.py", line 1, in <module>
from .sampler import *
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/sampler/__init__.py", line 1, in <module>
from .LabelSampler import *
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/sampler/LabelSampler.py", line 6, in <module>
from ...datasets import SentenceLabelDataset
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/datasets/SentenceLabelDataset.py", line 8, in <module>
from .. import SentenceTransformer
File "/usr/local/lib/python3.6/site-packages/sentence_transformers/SentenceTransformer.py", line 11, in <module>
import transformers
File "/usr/local/lib/python3.6/site-packages/transformers/__init__.py", line 124, in <module>
from .pipelines import (
File "/usr/local/lib/python3.6/site-packages/transformers/pipelines.py", line 47, in <module>
from .modeling_tf_auto import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_auto.py", line 45, in <module>
from .modeling_tf_albert import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_albert.py", line 43, in <module>
from .modeling_tf_utils import (
File "/usr/local/lib/python3.6/site-packages/transformers/modeling_tf_utils.py", line 943, in <module>
def get_initializer(initializer_range: float = 0.02) -> tf.initializers.TruncatedNormal:
File "/usr/local/lib64/python3.6/site-packages/tensorflow/python/util/module_wrapper.py", line 194, in __getattr__
attr = getattr(self._tfmw_wrapped_module, name)
AttributeError: module 'tensorflow._api.v1.initializers' has no attribute 'TruncatedNormal'