原书出处
Natural Language Processing in Action, Second Edition
>>> def make_array(x): ... if hasattr(x, 'detach'): ... return torch.squeeze(x).detach().numpy() ... return x You use this utility function to measure the accuracy of each iteration on the tensors for your outputs (predictions): >>> def measure_binary_accuracy(y_pred, y): ... y_pred = make_array(y_pred).round() ... y = make_array(y).round() ... num_correct = (y_pred == y).sum() ... return num_correct / len(y) Now, you can rerun your training using this utility function
原书定位详情
来源:a19c7933-4eda-4176-aebd-30fe7e1ad292
正文位置:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/chapter-5.html
EPUB SHA-256:0e9a35e49ca446e322e5524e53f39fb6bee5b2b23d9cda10ef052aca770b0b36