79234950

Date: 2024-11-28 18:07:08
Score: 1
Natty:
Report link

When using huggingface transformer library, the output returned by the model includes the model loss. Before starting the training, simply perform a forward pass on the dataset and obtain the model loss.

with torch.no_grad():
    outputs = model(**inputs, labels=labels)

loss = outputs.loss
print(f"Loss: {loss.item()}")
Reasons:
  • Has code block (-0.5):
  • Starts with a question (0.5): When
  • Low reputation (1):
Posted by: Ali Moameri