获取embedding时ernir_encoder.py保存文件时有问题
Created by: Lijun1003
170行-175行
with open(os.path.join(args.output_dir, "cls_emb.npy"),
"w") as cls_emb_file:
np.save(cls_emb_file, total_cls_emb)
with open(os.path.join(args.output_dir, "top_layer_emb.npy"),
"w") as top_layer_emb_file:
np.save(top_layer_emb_file, total_top_layer_emb)
错误原因:np.save后只能跟文件名,并不能使用已打开的文件。
应改为 np.save(os.path.join(args.output_dir, "cls_emb.npy"), total_cls_emb) np.save(os.path.join(args.output_dir, "top_layer_emb.npy"), total_top_layer_emb)