如何检查两个张量的形状不兼容?
是否有一种简单的方法来检查两个张量是否具有不兼容的形状(即,一个不可能的形状无法广播到另一个形状)?诸如
RuntimeError: The size of tensor a (?) must match the size of tensor b (?) at non-singleton dimension ?
我可以使用t1.size()[2]!= t2.size()[2]
之类的错误(即,我知道何时以及如何发生)更复杂的场景),但是我如何习惯地说呢?
Is there a simple way to check if two tensors have incompatible shapes (i.e., one can not be broadcast to the shape of the other) before multiplying them? Errors such as
RuntimeError: The size of tensor a (?) must match the size of tensor b (?) at non-singleton dimension ?
I could use t1.size()[2] != t2.size()[2]
in what I do (i.e., I know when and how that happens, but there could be more complicated scenarios), but how do I say it idiomatically?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论