Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

TypeError: get_encoders() got an unexpected keyword argument 'use_adapter' #116

Closed
MNCTTY opened this issue Aug 2, 2019 · 11 comments
Closed
Assignees
Labels
invalid This doesn't seem right

Comments

@MNCTTY
Copy link

MNCTTY commented Aug 2, 2019

import os
from keras_bert import load_trained_model_from_checkpoint

layer_num = 12
checkpoint_path = 'rubert_cased_L-12_H-768_A-12_v1'

config_path = os.path.join(checkpoint_path, 'bert_config.json')
model_path = os.path.join(checkpoint_path, 'bert_model.ckpt')
model = load_trained_model_from_checkpoint(
    config_path,
    model_path,
    training=False,
    use_adapter=True,
    trainable=['Encoder-{}-MultiHeadSelfAttention-Adapter'.format(i + 1) for i in range(layer_num)] +
    ['Encoder-{}-FeedForward-Adapter'.format(i + 1) for i in range(layer_num)] +
    ['Encoder-{}-MultiHeadSelfAttention-Norm'.format(i + 1) for i in range(layer_num)] +
    ['Encoder-{}-FeedForward-Norm'.format(i + 1) for i in range(layer_num)],
)

I try to run this code from tutorial
and this error arises:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-23-a18dfbad0880> in <module>
     15     ['Encoder-{}-FeedForward-Adapter'.format(i + 1) for i in range(layer_num)] +
     16     ['Encoder-{}-MultiHeadSelfAttention-Norm'.format(i + 1) for i in range(layer_num)] +
---> 17     ['Encoder-{}-FeedForward-Norm'.format(i + 1) for i in range(layer_num)],
     18 )

TypeError: load_trained_model_from_checkpoint() got an unexpected keyword argument 'use_adapter'

By the way, i tried to upgrade keras-transformers - it didnt help

@MNCTTY MNCTTY added the bug Something isn't working label Aug 2, 2019
@CyberZHG
Copy link
Owner

CyberZHG commented Aug 3, 2019

pip install --upgrade keras-bert

@CyberZHG CyberZHG added invalid This doesn't seem right and removed bug Something isn't working labels Aug 3, 2019
@MNCTTY MNCTTY closed this as completed Aug 3, 2019
@googlx
Copy link

googlx commented Jul 20, 2020

这是keras-transformer版本问题,换成0.31.0就ok了

@MoreInterest
Copy link

这是keras-transformer版本问题,换成0.31.0就ok了

ok

@1535966643
Copy link

这是keras-transformer版本问题,换成0.31.0就ok了

大哥牛逼

@CyberZHG
Copy link
Owner

This is an out-dated issue. See #190 and #191 if you still want to use the adapter.

@CyberZHG
Copy link
Owner

这是keras-transformer版本问题,换成0.31.0就ok了

Please read the last two lines carefully:

TypeError: load_trained_model_from_checkpoint() got an unexpected keyword argument 'use_adapter'
By the way, i tried to upgrade keras-transformers - it didnt help

@1535966643
Copy link

这是keras-transformer版本问题,换成0.31.0就ok了

Please read the last two lines carefully:

TypeError: load_trained_model_from_checkpoint() got an unexpected keyword argument 'use_adapter'
By the way, i tried to upgrade keras-transformers - it didnt help
你好,可以使用的Bert模型都有哪些?albert,robert可以用吗

@CoinCheung
Copy link

What is the solution to this problem ?? I am using 0.69.0 which still has the problem, do I need to down grade to 0.31.0?

@llpin1992
Copy link

pip install keras-bert==0.81.1 slove the problem

@Gavin4th
Copy link

大哥牛逼

@apugachev
Copy link

Try pip install keras-transformer==0.33.0

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

9 participants