![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
pytorch
文章平均质量分 61
欣欣然xl
这个作者很懒,什么都没留下…
展开
-
Expected tensor for argument #1 ‘indices‘ to have scalar type Long; but got torch.cuda.FloatTensor i
Expected tensor for argument #1 'indices' to have scalar type Long; but got torch.cuda.FloatTensor instead (while checking arguments for embedding)我遇到这个问题时是由于我nn.Embedding()的输入并非torch.int64(torch.LongTensor),解决方法是使用torch.LongTensor()或者是dtype=int64,这是证明原创 2021-03-08 16:59:19 · 5249 阅读 · 3 评论 -
在使用pytorch的时候我遇到的一些不熟悉的方法
在使用pytorch的时候我遇到的一些不熟悉的方法tensor.size()[:-2] + (20,)取除了倒数两个维度之前的维度,并且加上最后一个维度,比如说是(2, 3, 4, 5),变成了(2, 3, 20)tensor.permute(0, 2, 1, 3)对于四维的tensor,交换第二个和第三个维度tensor.transpose(-1, -2)对于一个tensor,交换倒数两个维度跟permute类似,但是transpose只能交换两个维度,但是permute可以交换多原创 2020-07-08 21:54:27 · 1151 阅读 · 0 评论