官方代码微调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}"
        }
    ]
}
相关推荐
我是小哪吒2.010 分钟前
书籍推荐-《对抗机器学习:攻击面、防御机制与人工智能中的学习理论》
人工智能·深度学习·学习·机器学习·ai·语言模型·大模型
慕婉030714 分钟前
深度学习前置知识全面解析:从机器学习到深度学习的进阶之路
人工智能·深度学习·机器学习
荔枝吻1 小时前
【AI总结】Git vs GitHub vs GitLab:深度解析三者联系与核心区别
人工智能·git·github
Jamie201901061 小时前
高档宠物食品对宠物的健康益处有哪些?
大数据·人工智能
云卓SKYDROID2 小时前
无人机载重模块技术要点分析
人工智能·无人机·科普·高科技·云卓科技
云卓SKYDROID2 小时前
无人机RTK技术要点与难点分析
人工智能·无人机·科普·高科技·云卓科技
麻雀无能为力2 小时前
CAU数据挖掘 支持向量机
人工智能·支持向量机·数据挖掘·中国农业大学计算机
智能汽车人3 小时前
Robot---能打羽毛球的机器人
人工智能·机器人·强化学习
埃菲尔铁塔_CV算法3 小时前
基于 TOF 图像高频信息恢复 RGB 图像的原理、应用与实现
人工智能·深度学习·数码相机·算法·目标检测·计算机视觉
ζั͡山 ั͡有扶苏 ั͡✾3 小时前
AI辅助编程工具对比分析:Cursor、Copilot及其他主流选择
人工智能·copilot·cursor