This commit is contained in:
thomwolf 2019-06-19 15:29:28 +02:00
parent 34d706a0e1
commit 14f0e8e557

View File

@ -209,8 +209,8 @@ def run_model():
attn_entropy, head_importance, _, _ = compute_heads_importance(args, model, eval_dataloader)
# Print/save matrices
np.save(os.path.join(args.output_dir, 'attn_entropy.npy'), attn_entropy)
np.save(os.path.join(args.output_dir, 'head_importance.npy'), head_importance)
np.save(os.path.join(args.output_dir, 'attn_entropy.npy'), attn_entropy.detach().cpu().numpy())
np.save(os.path.join(args.output_dir, 'head_importance.npy'), head_importance.detach().cpu().numpy())
logger.info("Attention entropies")
print_2d_tensor(attn_entropy)