New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] AttributeError: 'tuple' object has no attribute 'layer' #152
Comments
Are you working on a multi-label classification task? I might there is a small issue in the documents. |
Long story short, if you import keras_bert from setting the environment variable, it will cause this issue. You can fix it by importing import os
os.environ['TF_KERAS'] = '1' |
thanks for response, to answer your question, I am working on multi-class classification not multi-label classification, |
I am working on to make it easier to access the keras_bert tokenizer. Will release 5.0.1 today. Check out this commit 22ad76f |
thanks for your help, problem has been solved. I noticed a note in your tutorial for BERT embeddings, you tokenized sentences with BERT tokenizer but did not pass them into your neural net model, you just feed the raw text as input data. but then |
Fixed the typo and released the 0.5.1 version, it is much easier to use BERT tokenizer. Check it out, document |
dear BrikerMan |
You have updated to 0.5.1 version?
mahdisnapp <notifications@github.com>于2019年7月15日 周一19:42写道:
… dear BrikerMan
now we have other main error, after update, we got this error
tokenizer = bert_embed.tokenizer
'BERTEmbedding' object has no attribute 'tokenizer'
—
You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub
<#152?email_source=notifications&email_token=ACHPKS2CETBDQJK3U76RDV3P7RPDDA5CNFSM4IDUIGQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ5N6PI#issuecomment-511369021>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACHPKS4VTGMUGTIGUSO2K4DP7RPDDANCNFSM4IDUIGQQ>
.
|
yes I updated my kashgari just while you informed me. |
I just tried and it works. Please make sure you have imported the latest version if you started a kernel like jupyter before updating, it will require a kernel restart to import latest version. You can confirm by
Here is my demo: colab link |
errors have been solved, thank you again. |
dear BrikerMan, Keras: operands could not be broadcast together with shapes |
I need a little bit more details with this bug. Please provide the model config and data samples. |
I used BiLSTM model from kashgari.tasks.classification, my input data (x_train and x_validate) are tokenized texts and outpus (y_train, y_validate) are labels, |
Maybe you could provide the code, how you build the model, and sample data. Or just give me a colab notebook which could reproduce the issue. |
It seems the issue with data, please run this code.
|
there were no problem with shape of training and validation sets, I provide link to my colab |
I might know the issue, try to convert data to list rather than np.array.
|
yes your solution worked, may I ask what is the reason the model did not support numpy array as an input? |
I need to add all your corpus together to build token dict and label dict. So here is one important line Kashgari/kashgari/tasks/base_model.py Line 117 in 63f0991
But when you add two numpy array, they must be able to broadcast I have tried mainly on my build in corpus and haven't tested on numpy array input. So, this is a bug and will fix in the next version by converting |
@mahdisnapp Maybe you guys could help me write some blog about how you use Kashgari~ That means a lot. I hope more people know about this project. |
Dear BrikerMan |
Let's start with fixing bugs and documents, also feel free to add new features and create pull request. here is the contributing guide. |
This may be a bug induced by tf.keras. In tf.keras, they haven’t done type
check or explicit conversion from other types to list in some method
implementations.
…On Tue, Jul 16, 2019 at 20:27 Eliyar Eziz ***@***.***> wrote:
Dear BrikerMan
your work is very impressive and I want to help you to improve kashgari
performance and add new features to it. at the moment I could help with
bugs or add other models. if you need help just let me know. and if you
want I could mail you for further talks
Let's start with fixing bugs and documents, also feel free to add new
features and create pull request. here is the contributing guide
<https://kashgari.bmio.net/about/contributing/>.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#152?email_source=notifications&email_token=AAGRFKU7OOBCXLQSPSX2LQ3P7W5BRA5CNFSM4IDUIGQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2AVZ5I#issuecomment-511794421>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGRFKQ742WCHTWS3TGSIVTP7W5BRANCNFSM4IDUIGQQ>
.
|
first of all thanks for your impressive work and effort. I faced a problem when using your package in google colab. while I want to use bert embedding with this command:
bert_embedding = BERTEmbedding(bert_model_path,
task=kashgari.CLASSIFICATION,
sequence_length=128)
I got this error:
AttributeError: 'tuple' object has no attribute 'layer'
thanks in advance for your help.
The text was updated successfully, but these errors were encountered: