官方代码微调bert

train

bash 复制代码
export BERT_BASE_DIR=../GLUE/BERT_BASE_DIR/uncased_L-12_H-768_A-12
export GLUE_DIR=../GLUE/glue_data

python run_classifier.py \
  --task_name=MRPC \
  --do_train=true \
  --do_eval=true \
  --data_dir=$GLUE_DIR/MRPC \
  --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=3.0 \
  --output_dir=../GLUE/output

debugger

bash 复制代码
export BERT_BASE_DIR=./GLUE/BERT_BASE_DIR/uncased_L-12_H-768_A-12
export GLUE_DIR=./GLUE/glue_data

python run_classifier.py \
  --task_name=MRPC \
  --do_train=true \
  --do_eval=true \
  --data_dir=$GLUE_DIR/MRPC \
  --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=3.0 \
  --output_dir=./GLUE/output

AttributeError: module 'tensorflow_core._api.v2.train' has no attribute

https://juejin.cn/s/attributeerror module 'tensorflow._api.v2.train' has no attribute 'sessionrunhook'

更改优化器的调用方式

https://blog.csdn.net/weixin_41845265/article/details/108572738

AttributeError: module 'tensorflow' has no attribute 'flags'

https://blog.csdn.net/qq_53016081/article/details/119831833

加了keras =tf.keras.optimizers.Optimizer

vscode需要切换编译器python环境(这样就成功了)

debugger的终端也需要重新配置环境变量,其是一个临时的变量

为什么debugger的时候,每次都会

复制代码
(myenv) ➜  bert  cd /Users/wangfeng/Downloads/bert ; /usr/bin/env /opt/miniconda3/envs/myenv/bin/python /Users/wangfeng/.vscode/extensions/ms-python.debugpy-2024.7.11371017/bun
dled/libs/debugpy/adapter/../../debugpy/launcher 62860 -- /Users/wangfeng/Downloads/bert/bert-master/run_classifier.py --task_name=MRPC \   --do_train=true \   --do_eval=true \
   --data_dir=$GLUE_DIR/MRPC \   --vocab_file=$BERT_BASE_DIR/vocab.txt \   --bert_config_file=$BERT_BASE_DIR/bert_config.json \   --init_checkpoint=$BERT_BASE_DIR/bert_model.ck
pt \   --max_seq_length=128 \   --train_batch_size=32 \   --learning_rate=2e-5 \   --num_train_epochs=3.0 \   --output_dir=../GLUE/output 
WARNING:tensorflow:From /Users/wangfeng/Downloads/bert/bert-master/optimization.py:87: The name tf.train.Optimizer is deprecated. Please use tf.compat.v1.train.Optimizer instead.

launch文件

json 复制代码
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        

        {
            "name": "Python Debugger: Current File with Arguments",
            "type": "debugpy",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "args": "${command:pickArgs}"
        }
    ]
}
相关推荐
JarryStudy5 分钟前
HCCL与PyTorch集成 hccl_comm.cpp DDP后端注册全流程
人工智能·pytorch·python·cann
大闲在人17 分钟前
10. 配送中心卡车卸货流程分析:产能利用率与利特尔法则的实践应用
人工智能·供应链管理·智能制造·工业工程
woshikejiaih17 分钟前
**播客听书与有声书区别解析2026指南,适配不同场景的音频
大数据·人工智能·python·音视频
qq74223498420 分钟前
APS系统与OR-Tools完全指南:智能排产与优化算法实战解析
人工智能·算法·工业·aps·排程
兜兜转转了多少年21 分钟前
从脚本到系统:2026 年 AI 代理驱动的 Shell 自动化
运维·人工智能·自动化
LLWZAI25 分钟前
十分钟解决朱雀ai检测,AI率为0%
人工智能
无忧智库25 分钟前
某市“十五五“智慧气象防灾减灾精准预报系统建设方案深度解读 | 从“看天吃饭“到“知天而作“的数字化转型之路(WORD)
大数据·人工智能
方见华Richard25 分钟前
方见华个人履历|中英双语版
人工智能·经验分享·交互·原型模式·空间计算
凤希AI伴侣26 分钟前
凤希AI伴侣:一人成军的工具哲学与全模态内容实践-2026年2月7日
人工智能·凤希ai伴侣
Sagittarius_A*27 分钟前
特征检测:SIFT 与 SURF(尺度不变 / 加速稳健特征)【计算机视觉】
图像处理·人工智能·python·opencv·计算机视觉·surf·sift