xmxoxo / BERT-train2deploy

BERT模型从训练到部署
517 stars 165 forks source link

ModuleNotFoundError: No module named 'optimization' #5

Open sunweiconfidence opened 5 years ago

sunweiconfidence commented 5 years ago

使用以下命令训练模型,目录参数请根据各自的情况修改:

cd /mnt/sda1/transdat/bert-demo/bert/ export BERT_BASE_DIR=/mnt/sda1/transdat/bert-demo/bert/chinese_L-12_H-768_A-12 export GLUE_DIR=/mnt/sda1/transdat/bert-demo/bert/data export TRAINED_CLASSIFIER=/mnt/sda1/transdat/bert-demo/bert/output export EXP_NAME=mobile_0

sudo python run_mobile.py \ --task_name=setiment \ --do_train=true \ --do_eval=true \ --data_dir=$GLUE_DIR/$EXP_NAME \ --vocab_file=$BERT_BASE_DIR/vocab.txt \ --bert_config_file=$BERT_BASE_DIR/bert_config.json \ --init_checkpoint=$BERT_BASE_DIR/bert_model.ckpt \ --max_seq_length=128 \ --train_batch_size=32 \ --learning_rate=2e-5 \ --num_train_epochs=5.0 \ --output_dir=$TRAINED_CLASSIFIER/$EXP_NAME

根据这个,我本地win10的运行命令如下: python run_mobile.py --task_name=setiment --do_train=true --do_eval=true --data_dir=C:/Workspace/mnt/sda1/transdat/bert-demo/bert/data/mobile_0 --vocab_file=C:/Workspace/mnt/sda1/transdat/bert-demo/bert/chinese_L-12_H-768_A-12/vocab.txt --bert_config_file=C:/Workspace/mnt/sda1/transdat/bert-demo/bert/chinese_L-12_H-768_A-12/bert_config.json --init_checkpoint=C:/Workspace/mnt/sda1/transdat/bert-demo/bert/chinese_L-12_H-768_A-12/bert_model.ckpt --max_seq_length=80 --train_batch_size=16 --learning_rate=2e-5 --num_train_epochs=5.0 --output_dir=C:/Workspace/mnt/sda1/transdat/bert-demo/bert/output/mobile_0

运行目录如下: rundirectory

报错: mnt/sda1/transdat/bert-demo/bert/data/mobile_0 --vocab_file=C:/Workspace/mnt/sda1/transdat/bert-demo/bert/chinese_L-12_H-768_A-12/vocab.txt --bert_config_file=C:/Workspace/mnt/sda1/transdat/bert-demo/bert/chinese_L-12_H-768_A-12/bert_config.json --init_checkpoint=C:/Workspace/mnt/sda1/transdat/bert-demo/bert/chinese_L-12_H-768_A-12/bert_model.ckpt --max_seq_length=80 --train_batch_size=16 --learning_rate=2e-5 --num_train_epochs=5.0 --output_dir=C:/Workspace/mnt/sda1/transdat/bert-demo/bert/output/mobile_0 Traceback (most recent call last): File "run_mobile.py", line 25, in import optimization ModuleNotFoundError: No module named 'optimization'

请问需要安装什么模块吗?谢谢

xmxoxo commented 5 years ago

需要BERT的原始文件,这些需要的依赖文件已经补传了,请更新一下

sunweiconfidence commented 5 years ago

@xmxoxo, 谢谢,已更新,已调通,不过我训练的结果没有出现 这个训练结果: eval_accuracy = 0.861643 eval_f1 = 0.9536328 eval_loss = 0.56324786 eval_precision = 0.9491279 eval_recall = 0.9581805 global_step = 759 loss = 0.5615213, 但是文件都生成出来了,控制台也没报明显的错误,但是需要的文件都生成出来了,这样可以吗?谢谢。 traindata train data generate data

xmxoxo commented 5 years ago

训练结果得分还不错~~!

------------------ 原始邮件 ------------------ 发件人: "happycoding"notifications@github.com; 发送时间: 2019年6月27日(星期四) 下午5:47 收件人: "xmxoxo/BERT-train2deploy"BERT-train2deploy@noreply.github.com; 抄送: "何熙"xmxoxo@qq.com; "Mention"mention@noreply.github.com; 主题: Re: [xmxoxo/BERT-train2deploy] ModuleNotFoundError: No module named'optimization' (#5)

@xmxoxo, 谢谢,已更新,已调通,不过我训练的结果没有出现 这个训练结果: eval_accuracy = 0.861643 eval_f1 = 0.9536328 eval_loss = 0.56324786 eval_precision = 0.9491279 eval_recall = 0.9581805 global_step = 759 loss = 0.5615213, 但是文件都生成出来了,控制台也没报明显的错误,但是需要的文件都生成出来了,这样可以吗?谢谢。

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

sunweiconfidence commented 5 years ago

@xmxoxo 想做一个文本相似度的搜索,每一个问题,语义搜索完可以返回5个相似的回答语句,不知道如何做训练集,此项目支持吗,如果支持,如何准备训练集,测试集,验证集,谢谢