官方代码微调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}"
        }
    ]
}
相关推荐
笨笨饿几秒前
74_SysTick滴答定时器中断
c语言·开发语言·人工智能·单片机·嵌入式硬件·算法·学习方法
2501_921960852 分钟前
协同本体论 V4.2+:离散关系拓扑涌现连续时空几何的数值验证
数据结构·人工智能·重构
IT_陈寒7 分钟前
Redis缓存击穿把我坑惨了,原来这样解决才靠谱
前端·人工智能·后端
学习论之费曼学习法17 分钟前
Agent记忆系统:让AI拥有长期记忆能力
数据库·人工智能·oracle
Bnews24 分钟前
机器人轨迹定位设备推荐:高精度动作捕捉系统的科研价值与应用选择
人工智能·机器人
wuxinyan12328 分钟前
工业级大模型学习之路012:RAG 零基础入门教程(第七篇):高级检索架构(解决分块不合理问题)
人工智能·学习·rag
Lee川1 小时前
RAG 知识库问答:从概念到代码的完整实现
前端·人工智能·后端
侃谈科技圈1 小时前
2026年幻视AI数字工牌与全域零售AI解决方案官方介绍
人工智能·零售
chushiyunen1 小时前
ai人工智能方案-3d
人工智能
易知微EasyV数据可视化1 小时前
数序重构・智启新生|袋鼠云发布Data+AI智能飞轮战略,2026春季发布会圆满落幕
大数据·人工智能·经验分享·数字孪生·空间智能