首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >已经支持autograd - Pytorch的复杂函数

已经支持autograd - Pytorch的复杂函数
EN

Stack Overflow用户
提问于 2020-11-05 07:42:33
回答 2查看 498关注 0票数 1

我正在使用这个自定义函数来重塑自定义损失函数中的张量。

代码语言:javascript
复制
def reshape_fortran(x, shape):
if len(x.shape) > 0:
    x = x.permute(*reversed(range(len(x.shape))))
return x.reshape(*reversed(shape)).permute(*reversed(range(len(shape))))

尽管如此,我还是收到这个错误:

RuntimeError: _unsafe_view does not support automatic differentiation for outputs with complex dtype.

用于reshape_fortran输出。

你知道问题出在哪里吗?在复数的Pytorch autograd中不支持哪个函数?

EN

回答 2

Stack Overflow用户

发布于 2021-06-22 00:03:07

Complex Autograd在测试版1.8中,但现在是稳定的,应该完全支持像1.9这样的操作。

票数 1
EN

Stack Overflow用户

发布于 2020-11-06 10:16:59

我能够通过使用这个函数来解决这个问题,但我不知道为什么它不能工作,为什么它现在能工作:

代码语言:javascript
复制
def convert_output84_torch(input):
  shape84 = (8,4)
  T1 = torch.transpose(input,0,2).permute(0,1,2).contiguous()
  T2 = T1.view(shape84[::-1])
  output = torch.transpose(T2,0,1)
  return output

我用view替换了reshape,它工作得很好(目前)。但由于我的代码之前运行良好,我不确定这是否是一个长期的解决方案,因为我不知道主要的源代码。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64689253

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档