我正在尝试让BERT从这里获得的代码中进行情感分析:https://github.com/strongio/keras-bert
但是当我尝试建立模型时,我得到了一个错误,
'Module' object has no attribute 'variables'当我试图访问self.bert.variables时,这种情况特别发生在BertLayer类的构建函数中。
我尝试使用dir(self.bert)来获取对象的所有属性,但它确实没有一个名为variables的属性。以下是我获得的属性:
['\__call__', '\__class__', '\__delattr__', '\__dict__', '\__dir__', '\__doc__', '\__eq__', '\__format__', '\__ge__', '\__getattribute__', '\__gt__', '\__hash__', '\__init__', '\__init_subclass__', '\__le__', '\__lt__', '\__module__', '\__ne__', '\__new__', '\__reduce__', '\__reduce_ex__', '\__repr__', '\__setattr__', '\__sizeof__', '\__str__', '\__subclasshook__', '\__weakref__', '_graph', '_impl', '_name', '_spec', '_tags', '_trainable', 'export', 'get_input_info_dict', 'get_output_info_dict', 'get_signature_names', 'variable_map']我正在使用tf版本: 1.13.0和Python: 3.5
发布于 2019-06-28 02:13:50
安装最新版本的tensorflow和tensorflow集线器解决了此问题。
https://stackoverflow.com/questions/56794341
复制相似问题