ERNIE快速使用示例中的pooled是什么
谁都不惹谁哭丶 发布于2021-02 浏览:1724 回复:1
0
收藏

ernie在guthub上的教程中,展示的快速上手示例,请问pooled和encoded分别是什么?
pooled是句向量,encoded是每个字的字向量,这样想对吗?小白先谢谢大家解答!

代码如下:

import numpy as np
import paddle as P
from ernie.tokenizing_ernie import ErnieTokenizer
from ernie.modeling_ernie import ErnieModel

model = ErnieModel.from_pretrained('ernie-1.0') # Try to get pretrained model from server, make sure you have network connection
model.eval()
tokenizer = ErnieTokenizer.from_pretrained('ernie-1.0')

ids, _ = tokenizer.encode('hello world')
ids = P.to_tensor(np.expand_dims(ids, 0)) # insert extra `batch` dimension
pooled, encoded = model(ids) # eager execution        <<------------------------------------------------------就是这一行的pooled,encoded
print(pooled.numpy()) # convert results to numpy

收藏
点赞
0
个赞
共1条回复 最后由饭小团回复于2021-02
#2饭小团回复于2021-02

可以加下easydl的沟通群交流下 QQ交流群:1097307223

0
TOP
切换版块