How to measure accuracy while fine-tuning bert-base model?

Hello everybody,

While I am fine-tunning ‘dbmdz/bert-base-turkish-uncased model’, I can see the loss value during training the model as below:

outputs = model(b_input_ids, attention_mask=b_input_mask, labels=b_labels)
loss = outputs[0]  #  get loss

but I could not measure accuracy value during training the model.
any suggestion, please?

1 Like

I’m not sure if it’s possible to print metrics with that object, but with model.fit it automatically displays the metrics as in TensorFlow.
Check out the course page

However, I don’t know if it’s possible to include the attention layers here as you do in your example.

model.fit(
    x=training['train']['input_ids'],
    y=training['labels_train'], 
    validation_data=(
        validation['valid']['input_ids'],
        validation['labels_test'],
    )
    ,batch_size = batch_size
    ,epochs = epochs
)