使用TensorFlow and Horovod 实现BERT多GPU训练

一、run_classifier.py文件

#chang 1:引入horovod
import horovod.tensorflow as hvd
...
def get_train_examples(self, data_dir):
    """See base class."""
    file_path = os.path.join(data_dir, "train_bert.txt")
    #chang 2 修改训练数据创建方式
    return self._create_examples_train(file_path, "train")
	#...
def get_labels(self):
    """See base class."""
    return ["0", "1"]
#chang 3 新增训练数据创建代码
def _create_examples_train(self, file_path, set_type):
    """Creates examples for the training and dev sets."""
    examples = []
    for (i, line) in enumerate(codecs.open(
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值