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
个赞
请登录后评论
TOP
切换版块
可以加下easydl的沟通群交流下 QQ交流群:1097307223