官方代码微调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 分钟前
猫头虎AI分享|一款Coze、Dify类开源AI应用超级智能体快速构建工具:FastbuildAI
人工智能·开源·prompt·github·aigc·ai编程·ai-native
重启的码农20 分钟前
ggml 介绍 (6) 后端 (ggml_backend)
c++·人工智能·神经网络
重启的码农20 分钟前
ggml介绍 (7)后端缓冲区 (ggml_backend_buffer)
c++·人工智能·神经网络
数据智能老司机21 分钟前
面向企业的图学习扩展——图简介
人工智能·机器学习·ai编程
盼小辉丶21 分钟前
PyTorch生成式人工智能——使用MusicGen生成音乐
pytorch·python·深度学习·生成模型
mit6.8241 小时前
[AI React Web] 包与依赖管理 | `axios`库 | `framer-motion`库
前端·人工智能·react.js
小阿鑫1 小时前
不要太信任Cursor,这位网友被删库了。。。
人工智能·aigc·cursor·部署mcp
说私域2 小时前
基于定制开发开源 AI 智能名片 S2B2C 商城小程序的热点与人工下发策略研究
人工智能·小程序
Tiger Z2 小时前
《动手学深度学习v2》学习笔记 | 1. 引言
pytorch·深度学习·ai编程
GoGeekBaird3 小时前
GoHumanLoopHub开源上线,开启Agent人际协作新方式
人工智能·后端·github