Closed zoeChen119 closed 1 year ago
使用的模型是bert-wwm-chinese,albert-chinese-tiny,skep_ernie_1.0_large_ch
您的显存有多大呢,换一张卡试试?
您的显存有多大呢,换一张卡试试?
This issue is stale because it has been open for 60 days with no activity. 当前issue 60天内无活动,被标记为stale。
This issue was closed because it has been inactive for 14 days since being marked as stale. 当前issue 被标记为stale已有14天,即将关闭。
`# 模型训练: import paddle.nn.functional as F import time
save_dir = "checkpoint/bert-wwm" if not os.path.exists(save_dir): os.makedirs(save_dir)
save_train_result = "./results/bert-wwm.tsv" train_r_df = pd.DataFrame(data=None, columns=["global_step","epoch","step","loss","acc","time"])
pre_accu=0 accu=0 global_step = 0 epochs = 10 for epoch in range(1, epochs + 1): for step, batch in enumerate(train_data_loader, start=1): start = time.time() input_ids, segment_ids, labels = batch logits = model(input_ids, segment_ids) loss = criterion(logits, labels) probs = F.softmax(logits, axis=1) correct = metric.compute(probs, labels) metric.update(correct) acc = metric.accumulate() global_step += 1 if global_step % 2 == 0 : print("global step %d, epoch: %d, batch: %d, loss: %.5f, acc: %.5f" % (global_step, epoch, step, loss, acc)) loss.backward() optimizer.step() lr_scheduler.step() optimizer.clear_grad()
统计运行时间
tokenizer.save_pretrained(save_dir) train_r_df.to_csv(save_train_result, sep="\t", index=False, header=True)`