BERT:how to change the output feature?

When I use the bert to extract features,the output features are always 768 dimension.How can I change them into 300 dimension?

댓글 수: 9

Rik
Rik 2022년 9월 19일
That is a form of down-sampling. How do you propose to perform this downsampling?
Also, this question doesn't have anything to do with Matlab yet. You could indeed perform this downsampling in Matlab, but the concept itself is a deep learning question, not a Matlab question.
David Willingham
David Willingham 2022년 9월 19일
이동: Rik 2022년 9월 20일
Can you explain why you would like to change the output to 300?
XT
XT 2022년 9월 20일
이동: Rik 2022년 9월 20일
I want to use the bert to extract features of protein sequence.But when I put the features into the model, I found the model performance is not well. I know that the model performance is affected by many factors, but I want to know whether the features extracted by bert are too long. (Every input sequence is not more than 50 words) So I want to change the output to fewer dimension.
XT
XT 2022년 9월 20일
I wonder whether can I put a fullyconnected layer to change the output of the bert. If the model is a CNN , I think the fullyconnected layer can work. The bert cant' be seen in the Deep Network Designer, so I don't konw how to change it.
Rik
Rik 2022년 9월 20일
A fully connected layer is equivalent to doing a matrix multiplication. In your case you want a matrix of 768x300.
But there is a more fundamental problem. You say you want to analyze protein sequences. BERT is intended for normal text. Why do you think this will work in the first place?
XT
XT 2022년 9월 20일
I just want a try and use the bert to extract features is easy. Usually, many articals use CNN,LSTM or other varieties to extract protein sequences data, the precision of sota model is just 0.69. When I use features extracted by bert, the precision can up to 0.74, but the recall becomes lower.
Rik
Rik 2022년 9월 20일
Well, if it works it works, that's up to you. I already gave you what you need to know: a fully connected layer is equivalent to doing a matrix multiplication. You can even do the training fully inside Matlab with the mldivide, \ function.
David Willingham
David Willingham 2022년 9월 20일
Hi Rik,
I spoke with development on this, they state:
==
Reducing the features of BERT might not help and wouldn’t recommend doing that in that situation.
It seems that they are trying to extract features of protein sequence from BERT, which is something BERT is not trained for.
==
I note that you have tried Bert already. Are you able to provide some example code? This may help us provide more guidence on this.
XT
XT 2022년 9월 21일
편집: XT 2022년 9월 21일
I have uploaded the code and data. I dont't know whether the loss function is correct

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Modeling and Prediction에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

XT
2022년 9월 19일

편집:

XT
2022년 9월 21일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by