bojone / bert4keras

keras implement of transformers for humans
https://kexue.fm/archives/6915
Apache License 2.0
5.37k stars 929 forks source link

在对bert4keras加载的模型进行人工特征输入时出现问题, #518

Closed WMeng1 closed 1 year ago

WMeng1 commented 1 year ago

提问时请尽可能提供如下信息:

基本信息

核心代码

model = build_transformer_model(config_path, checkpoint_path, model='albert') category = Input(shape=(1,), name='feature_input') categoryEmbedding = Embedding(1, 312)(category) categoryEmbedding = Flatten()(categoryEmbedding)

特征拼接

input = model.input input.append(category)

output = concatenate([model.output, categoryEmbedding], axis=1) output = GlobalPointer(len(categories), 64)(output)

model = Model(input, output)


### 输出信息
```shell
ValueError: A `Concatenate` layer requires inputs with matching shapes except for the concat axis. Got inputs shapes: [(None, None, 312), (None, 312)]

在maxlen维度处要怎么处理才能正确拼接人工构造的特征呢,辛苦您了

自我尝试

不管什么问题,请先尝试自行解决,“万般努力”之下仍然无法解决再来提问。此处请贴上你的努力过程。