strongio / keras-bert

A simple technique to integrate BERT from tf hub to keras
258 stars 108 forks source link

Error accessing variables attribute of bert module #12

Closed varunvprabhu closed 5 years ago

varunvprabhu commented 5 years ago

When I try to build the model, I get an error saying - 'Module' object has no attribute 'variables'

This occurs specifically in the build function of the BertLayer class when I try to access self.bert.variables.

I tried a dir(self.bert) to get all the attributes of the object and it indeed did not have an attribute called variables. These are the attributes I obtained:

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

I'm using tf version 1.13.0 with Python3.5 on Win10.

varunvprabhu commented 5 years ago

Installing the very latest version of tensorflow and tensorflow hub fixed this issue.