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
[Question] Multi-output model #92
Comments
Yes, kashgari support multi-label classifacation. input_text = [
['This','news',are',very','well','organized'],
['What','extremely','usefull','tv','show'],
['The','tv','presenter','were','very','well','dress']
]
labels = [
['class1', 'class3'],
['class1', 'class2'],
['class1', 'class2', 'class3'],
]
model.fit(input_text, labels, multi_label=True) |
Dear @BrikerMan, thank you for your answer. I am little confused about how you transform the labels. Actually, they dataset with tokenized text input looks like this:
So, i can't figure out how those 'class1','class2' and 'class3' are mapped. |
First, according to what you discribed, you actually want to train two
classifiers coordinately. This is possible because Kash is based on keras
which support multi-output form of deep models. All you need is to define
the model structure you want by heritaging it from the base classification
class of kash.
But there may be a bug existed in the `fit` method of dealing with multiple
output and need to be fixed. This potentia flaw was induced when I
implement the multiple input feature, when I just considered the simplest
scenario, without supporting multi-output.
So here are the alternatives:
1. we are working on refactoring the project and the base model class part
would be redesigned to be more flexible and you may keep an eye on the
process.
2. You may consider using multi-label to get over it or you may modify
those parts of code in current version and make a PR then.
It's up to you now and feel free to let us know. 😀
…On Mon, 20 May 2019 at 19:59, Qian16 ***@***.***> wrote:
Dear @BrikerMan <https://github.com/BrikerMan>, thank you for your
answer. I am little confused about how you transform the labels.
Actually, they dataset with tokenized text input looks like this:
input_text | label1 | label2
1. ['This','news',are',very','well','organized'] | 1 | 1
2. ['What','extremely','usefull','tv','show'] | 0 | 1
3. ['The','tv','presenter','were','very','well','dress'] | 1 | 0
So, i figure out how those 'class1','class2' and 'class3' are mapped.
Thank you.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#92?email_source=notifications&email_token=AAGRFKTEQ3LNOA7HX7T3YVTPWKHD3A5CNFSM4HN7UGJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVYS4SA#issuecomment-493956680>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAGRFKRNOXBWXOUVJ6GWERDPWKHD3ANCNFSM4HN7UGJA>
.
|
Just keep the label that should be output as 1.
|
@alexwwang @BrikerMan Thank you. It will be nice to have Kash that supports all features. Big up guys. |
@Qian16 I got it wrong, Kashgari support multi-label classification. Not support the multi-output classification. |
@BrikerMan By modifying method |
@alexwwang Thank you. Can you show me the test you did(or tel me the exact line to change)? To define a model and assemble it to Kash i did. Thank you. |
I am working on it. I will submit the demo later today. |
@alexwwang Wow! Thank you for saving my life!!! |
@BrikerMan @Qian16 The main change need to be done is the processing of label or y data. Just like what have been done with x data in multi-input scenario, the y part also need an automatic de-nest from input list and re-nest when assemble to batch later. It's not too hard, I think. |
It's an honor of @BrikerMan. He'll implement the last mile. :) |
@alexwwang @Qian16 I have added an example of a multi-output model. Check it out. Remember u need to run the |
@BrikerMan @alexwwang Thank you for great job. It working correctly. |
@BrikerMan Did you try to use BERTEmbedding ? |
Not yet, but it should work fine. Remember to pull the latest code. |
@BrikerMan to run BERT, we need to change in keras fit() function Thanks. |
Fixed, Added new test case at b27dea0 . |
The accuracy achieved by multi-output model is not poor! The performance of individual models is very good compared to multi-output. May be we need to check it again. Thx |
Hello Dear @BrikerMan. Thanks for creating this good library. However, I want to perform multi-outputs classification(This is different to multi-label).
My input is sentence and the outputs are two full-connected networks where each one has its own labels (One input-->Two branch networks).
I want to know if Kashgari supports multi-outputs classification.
input_text=[['This','news',are',very','well','organized'],
['What','extremely','usefull','tv','show'],
['The','tv','presenter','were','very','well','dress']]
label_list1=[1,0,1]
label_list2=[1,1,0]
xdata=input_text
ydata=[label_list1,label_list2] #In Keras, for multi-output we make a list of both labels.
model.fit(xdata,ydata,epochs=1)
Thank you.
The text was updated successfully, but these errors were encountered: