keras-crf icon indicating copy to clipboard operation
keras-crf copied to clipboard

how to use sample weight with CRF as sample weight is a 2D array?

Open ShamilaNasreen opened this issue 4 years ago • 0 comments

I am building a model for sequence tagging using BiLSTM and CRF. I am using the Keras-CRF provided in this project. I successfully run the code and below is the summary of my model. While the Keras_model support sample weight as 1D but we have to assign different weights at each time step as I want to give higher weights to less frequent tag class. so my weight_sample shape is (1114,100). It gives error as to compute the loss the function is: if sample_weight is not None: crf_loss = crf_loss * sample_weight and an error occued of 'required broadcast shape'. image

Can you please suggest how to use 2D sample weight within this code.

ShamilaNasreen avatar Jan 18 '22 14:01 ShamilaNasreen