当前位置:网站首页>Bert use
Bert use
2022-06-12 06:06:00 【Singing under the hedge】
List of articles
Bert
One 、 Code
import torch
from transformers import BertModel,BertTokenizer
import torch.nn as nn
sentence = 'i like eating apples very much'
class Model (nn.Module):
def __init__(self):
super().__init__()
self.embeder = BertModel.from_pretrained('bert-base-cased',output_hidden_states = True)
self.tokenizer = BertTokenizer.from_pretrained('bert-base-cased')
def forward(self,inputs):
tokens = self.tokenizer.tokenize(inputs)
print(tokens)
tokens_id = self.tokenizer.convert_tokens_to_ids(tokens)
print(tokens_id)
token_id_tensor = torch.tensor(tokens_id).unsqueeze(0)
outputs = self.embeder(token_id_tensor)
print(outputs[0])
model = Model()
results = model(sentence)
Two 、 Realization effect

边栏推荐
- Recursive implementation of exponential, permutation and combination enumerations
- Sensor bringup 中的一些问题总结
- 2D human pose estimation for pose estimation - pifpaf:composite fields for human pose estimation
- 项目开发流程简单介绍
- Understand Houdini's (heightfield) remap operation
- [untitled]
- User login [next]
- 分段贝塞尔曲线
- Remap function of C different interval mapping
- Simple spiral ladder generation for Houdini program modeling
猜你喜欢

Understand Houdini's (heightfield) remap operation

Un mois de DDD hépatique.

Project technical structure
![[PowerShell] command line output and adding system environment variables](/img/49/b92175181aa4a3fddfa3adcacf1d72.jpg)
[PowerShell] command line output and adding system environment variables

前台展示LED数字(计算器上数字类型)

Houdini script vex learning

Redis队列

关于 Sensor flicker/banding现象的解释

In unity3d, billboard effect can be realized towards another target

Directx11 advanced tutorial cluster based deffered shading
随机推荐
[Yu Yue education] basic reference materials of accounting of Nanjing Normal University
Front desk display LED number (number type on calculator)
Makefile文件编写快速掌握
How do I get the date and time from the Internet- How to get DateTime from the internet?
sqlite交叉编译动态库
[untitled]
Guns框架多数据源配置,不修改配置文件
2D human pose estimation for pose estimation - pifpaf:composite fields for human pose estimation
User login [next]
单通道图片的读入
Automatic annotation of target detection based on lffd model to generate XML file
Simple spiral ladder generation for Houdini program modeling
【思维方法】之第一性原理
MySQL master-slave, 6 minutes to master
[untitled]
摄像头拍摄运动物体,产生运动模糊/拖影的原因分析
The unity3d script searches for colliders with overlaps within the specified radius
A month's worth of DDD will help you master it
Why doesn't the database use binary tree, red black tree, B tree and hash table? Instead, a b+ tree is used
Leetcode simple problem: converting an integer to the sum of two zero free integers