fastnlp / fastNLP

fastNLP: A Modularized and Extensible NLP Framework. Currently still in incubation.
https://gitee.com/fastnlp/fastNLP
Apache License 2.0
3.05k stars 451 forks source link

"fastnlp" batch size 设置偶尔不生效 #406

Closed 312shan closed 2 years ago

312shan commented 2 years ago

torch-1.2.0 fastNLP-0.7.0 系统ubuntu18.04

"fastnlp" batch size 设置偶尔不生效, 做序列标注,用的是内置模型和示例代码,batch_size=32 偶尔生效偶尔为 2。

trainer = Trainer(data_bundle.get_dataset('train'), model, loss=loss, optimizer=optimizer, dev_data=data_bundle.get_dataset('dev'), metrics=metric, device=device, n_epochs=N_EPOCHS, batch_size=BATCH_SIZE) trainer.train()

batch_size 调试的时候都为2。怎么设置都不管用。

yhcc commented 2 years ago

在Trainer初始化的时候,有个check_code参数设置为-1,就不会有batch_size为2。为了防止代码跑完一个epoch之后,测试报错,fastnlp默认会使用比较小的batch跑一遍模型和evaluate,来最低限度确保代码是可以正常运行的。可以通过check_code控制该行为。