官方代码微调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}"
        }
    ]
}
相关推荐
IT古董21 分钟前
【深度学习】常见模型-Transformer模型
人工智能·深度学习·transformer
沐雪架构师1 小时前
AI大模型开发原理篇-2:语言模型雏形之词袋模型
人工智能·语言模型·自然语言处理
摸鱼仙人~2 小时前
Attention Free Transformer (AFT)-2020论文笔记
论文阅读·深度学习·transformer
python算法(魔法师版)2 小时前
深度学习深度解析:从基础到前沿
人工智能·深度学习
kakaZhui2 小时前
【llm对话系统】大模型源码分析之 LLaMA 位置编码 RoPE
人工智能·深度学习·chatgpt·aigc·llama
struggle20253 小时前
一个开源 GenBI AI 本地代理(确保本地数据安全),使数据驱动型团队能够与其数据进行互动,生成文本到 SQL、图表、电子表格、报告和 BI
人工智能·深度学习·目标检测·语言模型·自然语言处理·数据挖掘·集成学习
佛州小李哥3 小时前
通过亚马逊云科技Bedrock打造自定义AI智能体Agent(上)
人工智能·科技·ai·语言模型·云计算·aws·亚马逊云科技
云空4 小时前
《DeepSeek 网页/API 性能异常(DeepSeek Web/API Degraded Performance):网络安全日志》
运维·人工智能·web安全·网络安全·开源·网络攻击模型·安全威胁分析
AIGC大时代5 小时前
对比DeepSeek、ChatGPT和Kimi的学术写作关键词提取能力
论文阅读·人工智能·chatgpt·数据分析·prompt
山晨啊86 小时前
2025年美赛B题-结合Logistic阻滞增长模型和SIR传染病模型研究旅游可持续性-成品论文
人工智能·机器学习