簡體   English   中英

嘗試訪問bert.variables時出現BERT模塊錯誤

[英]Getting an Error for BERT module when trying to access bert.variables

我正試圖讓BERT從從這里獲得的代碼中進行情感分析: https : //github.com/strongio/keras-bert

但是當我嘗試建立模型時,出現錯誤消息,

'Module' object has no attribute 'variables'

當我嘗試訪問self.bert.variables時,這特別發生在BertLayer類的build函數中。

我嘗試使用dir(self.bert)來獲取對象的所有屬性,但實際上並沒有稱為變量的屬性。 這些是我獲得的屬性:

['\__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

安裝最新版本的tensorflow和tensorflow hub可以解決此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM