当前位置:网站首页>Use transformers to convert TF model to pytorch model
Use transformers to convert TF model to pytorch model
2022-06-11 18:23:00 【Yalin melon seeds】
scene
Use tensorflow take TF The model is transformed into PyTorch Model
step
Get the following three files :
- src/transformers/models/bert/convert_bert_original_tf2_checkpoint_to_pytorch.py: This is the tensorflow2.x Bert The model is transformed into PyTorch Available models .
- src/transformers/models/bert/modeling_bert.py:Bert Model usage examples .
- BERT-Base, Multilingual Cased (New, recommended): be based on Bert Multi - language pre - training model .
It is assumed here that PyTorch 了 .
Start to transform TF2 Model bit PyTorch Model :
# Installation dependency
pip3 install tensorflow transformers
export BERT_BASE_DIR=~/Downloads/nlp_bert/multi_cased_L-12_H-768_A-12
transformers-cli convert --model_type bert \
--tf_checkpoint $BERT_BASE_DIR/bert_model.ckpt \
--config $BERT_BASE_DIR/bert_config.json \
--pytorch_dump_output $BERT_BASE_DIR/pytorch_model.bin
there pytorch_model.bin Namely TF2 Has been trained to transform the model PyTorch Model .
Reference resources :
边栏推荐
猜你喜欢

ctf入门

Async leads to unexpected function results and changes the intention of the original code; await is only valid in async functions and the top level bodies of modules
![[C语言]压缩字符串并添加标记字符](/img/b7/f7918f3ee0c409faffc70addd5ee65.png)
[C语言]压缩字符串并添加标记字符

Jsfinder, wafw00f installation, nmap configuration (msvcr120.dll file is missing)

软件测试技术复习
![[C语言]对一个数组的元素排序后平移元素](/img/5b/3e74fc40787d94f6d0ab93332140ba.png)
[C语言]对一个数组的元素排序后平移元素
![[Golang]力扣Leetcode - 292. Nim 游戏(数学)](/img/82/54c3f6be9d08687b42cba0487380f0.png)
[Golang]力扣Leetcode - 292. Nim 游戏(数学)
MySQL/Redis 常见面试题汇总

v-for循环遍历
![[golang] leetcode - 349 Intersection of two arrays (hash table)](/img/92/03de54c9f08eae5bc920b04d2b8493.png)
[golang] leetcode - 349 Intersection of two arrays (hash table)
随机推荐
NR LDPC 打孔-punctured
安全领域常规术语
* Jetpack 笔记 使用DataBinding
Hwang
Common operations of Visio
关于keil中,while循环条件不成立却无法跳出的问题
[Golang]力扣Leetcode - 349. 两个数组的交集(哈希表)
Winter vacation daily question 2022 [week1 not finished]
神经网络与深度学习-2- 机器学习简单示例-PyTorch
Mysql8 installation, Navicat installation, sqli labs setup
单选按钮 文字背景同时改变
Codeworks round 479 (Div. 3) [done]
Feign shares login information for request
Network Security Threat Intelligence System
下载代码,并编译环境的问题
软件测试技术复习
LeetCode_ Prefix tree_ Medium_ 208. implement trie (prefix tree)
DataNode的启动流程
炫酷的可视化工具:processing 初识
MMA-Self-defining function