Traceback (most recent call last):
File "test_estimator_bert.py", line 49, in <module>
model = build_model()
File "test_estimator_bert.py", line 36, in build_model
title_bert = tf.layers.dense(bert_encoder, units=1)
File "/data/anaconda3/envs/py3/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 324, in new_func
return func(*args, **kwargs)
File "/data/anaconda3/envs/py3/lib/python3.6/site-packages/tensorflow/python/layers/core.py", line 188, in dense
return layer.apply(inputs)
File "/data/anaconda3/envs/py3/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1479, in apply
return self.__call__(inputs, *args, **kwargs)
File "/data/anaconda3/envs/py3/lib/python3.6/site-packages/tensorflow/python/layers/base.py", line 537, in __call__
outputs = super(Layer, self).__call__(inputs, *args, **kwargs)
File "/data/anaconda3/envs/py3/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 561, in __call__
base_layer_utils.create_keras_history(inputs)
File "/data/anaconda3/envs/py3/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer_utils.py", line 200, in create_keras_history
_, created_layers = _create_keras_history_helper(tensors, set(), [])
File "/data/anaconda3/envs/py3/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer_utils.py", line 253, in _create_keras_history_helper
layer_inputs, op.outputs)
File "/data/anaconda3/envs/py3/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1795, in _add_inbound_node
input_tensors)
File "/data/anaconda3/envs/py3/lib/python3.6/site-packages/tensorflow/python/util/nest.py", line 515, in map_structure
structure[0], [func(*x) for x in entries],
File "/data/anaconda3/envs/py3/lib/python3.6/site-packages/tensorflow/python/util/nest.py", line 515, in <listcomp>
structure[0], [func(*x) for x in entries],
File "/data/anaconda3/envs/py3/lib/python3.6/site-packages/tensorflow/python/keras/engine/base_layer.py", line 1794, in <lambda>
inbound_layers = nest.map_structure(lambda t: t._keras_history.layer,
AttributeError: 'tuple' object has no attribute 'layer'
问题
使用tensorflow api时bert4keras报错,错误代码在tf.layers.dense这个api,如果不使用这个api,直接输出bert的向量没有问题。
基本信息
核心代码
输出信息
自我尝试
换了几个tf版本都一样的错误