strongio / keras-bert

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

Variable split error in BERT LAYER #8

Closed zabithameed closed 5 years ago

zabithameed commented 5 years ago

ValueError Traceback (most recent call last) in () 1 #Training the model ----> 2 model = build_model(max_seq_length) 3 4 # Instantiate variables 5 initialize_vars(sess)

in build_model(max_seq_length) 7 bert_inputs = [in_id, in_mask, in_segment] 8 ----> 9 bert_output = BertLayer(n_fine_tune_layers=3)(bert_inputs)

~\Anaconda\lib\site-packages\tensorflow\python\layers\base.py in call(self, inputs, *args, *kwargs) 372 373 # Actually call layer --> 374 outputs = super(Layer, self).call(inputs, args, **kwargs) 375 376 if not context.executing_eagerly():

~\Anaconda\lib\site-packages\tensorflow\python\keras\engine\base_layer.py in call(self, inputs, *args, **kwargs) 744 # the user has manually overwritten the build method do we need to 745 # build it. --> 746 self.build(input_shapes) 747 # We must set self.built since user defined build functions are not 748 # constrained to set self.built.

in build(self, input_shape) 16 for var in self.bert.variables: 17 if "encoder" in var.name: ---> 18 layer_no = int(var.name.split("/")[3]) 19 layer_no = inti(layerno.split("")[-1]) 20 if layer_no >= 12 - self.n_fine_tune_layers:

ValueError: invalid literal for int() with base 10: 'encoder'

jacobzweig commented 5 years ago

Need you to provide more context to resolve this issue, closing until then.