Aer*_*rin 5 python typeerror word-embedding pytorch
我收到此错误消息
RuntimeError: Expected object of type torch.LongTensor but found type torch.cuda.LongTensor for argument #3 'index'
Run Code Online (Sandbox Code Playgroud)
但是,这是什么意思argument #3 "index"呢?我index在torch.embedding(来源:https://pytorch.org/docs/stable/_modules/torch/nn/modules/sparse.html#Embedding)中找不到“ ”参数,似乎我传递了错误的嵌入参数。
我什至如下更改了输入的数据类型,但错误仍然存在。
RuntimeError: Expected object of type torch.LongTensor but found type torch.cuda.LongTensor for argument #3 'index'
Run Code Online (Sandbox Code Playgroud)
任何评论(即使很短!)或仅列出要查看的关键字都将受到高度赞赏!
这是完整的追溯。
batch['doc_tok'] = batch['doc_tok'].long()
batch['query_tok'] = batch['query_tok'].long()
Run Code Online (Sandbox Code Playgroud)
更新:我什至将整个model.network发送到cpu,但仍然收到相同的错误。
batch['doc_tok']=batch['doc_tok'].long().cpu()
batch['query_tok']=batch['query_tok'].long().cpu()
self.network.cpu()
print(batch['doc_tok'].dtype, batch['query_tok'].dtype) # They are both torch.int64 torch.int64
start, end, _ = self.network(batch)
Run Code Online (Sandbox Code Playgroud)
在这一点上,我怀疑这可能是一个错误...
model.py代码:https : //github.com/byorxyz/san_mrc/blob/master/src/model.py
定义的网络:https://github.com/byorxyz/san_mrc/blob/master/src/dreader.py
尝试这个:
batch['doc_tok']=batch['doc_tok'].long().cpu()
batch['query_tok']=batch['query_tok'].long().cpu()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3307 次 |
| 最近记录: |