python类cross()的实例源码

test_torch.py 文件源码 项目:pytorch-dist 作者: apaszke 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def test_cross(self):
        x = torch.rand(100, 3, 100)
        y = torch.rand(100, 3, 100)
        res1 = torch.cross(x, y)
        res2 = torch.Tensor()
        torch.cross(res2, x, y)
        self.assertEqual(res1, res2)
linalg.py 文件源码 项目:pytorch 作者: tylergenter 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def forward(self, input, other):
        self.save_for_backward(input, other)
        return torch.cross(input, other, self.dim)
linalg.py 文件源码 项目:pytorch 作者: tylergenter 项目源码 文件源码 阅读 36 收藏 0 点赞 0 评论 0
def backward(self, grad_output):
        input, other = self.saved_tensors
        grad_input = torch.cross(other, grad_output, self.dim)
        grad_other = torch.cross(grad_output, input, self.dim)
        return grad_input, grad_other
test_torch.py 文件源码 项目:pytorch 作者: tylergenter 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_cross(self):
        x = torch.rand(100, 3, 100)
        y = torch.rand(100, 3, 100)
        res1 = torch.cross(x, y)
        res2 = torch.Tensor()
        torch.cross(x, y, out=res2)
        self.assertEqual(res1, res2)
linalg.py 文件源码 项目:pytorch-coriander 作者: hughperkins 项目源码 文件源码 阅读 29 收藏 0 点赞 0 评论 0
def forward(self, input, other):
        self.save_for_backward(input, other)
        return torch.cross(input, other, self.dim)
linalg.py 文件源码 项目:pytorch-coriander 作者: hughperkins 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def backward(self, grad_output):
        input, other = self.saved_tensors
        grad_input = torch.cross(other, grad_output, self.dim)
        grad_other = torch.cross(grad_output, input, self.dim)
        return grad_input, grad_other
test_torch.py 文件源码 项目:pytorch-coriander 作者: hughperkins 项目源码 文件源码 阅读 16 收藏 0 点赞 0 评论 0
def test_cross(self):
        x = torch.rand(100, 3, 100)
        y = torch.rand(100, 3, 100)
        res1 = torch.cross(x, y)
        res2 = torch.Tensor()
        torch.cross(x, y, out=res2)
        self.assertEqual(res1, res2)
linalg.py 文件源码 项目:pytorch 作者: ezyang 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def forward(ctx, input, other, dim=-1):
        ctx.dim = dim
        ctx.save_for_backward(input, other)
        return torch.cross(input, other, ctx.dim)
linalg.py 文件源码 项目:pytorch 作者: ezyang 项目源码 文件源码 阅读 41 收藏 0 点赞 0 评论 0
def backward(ctx, grad_output):
        input, other = ctx.saved_variables
        grad_input = other.cross(grad_output, ctx.dim)
        grad_other = grad_output.cross(input, ctx.dim)
        return grad_input, grad_other, None
test_torch.py 文件源码 项目:pytorch 作者: ezyang 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def test_cross(self):
        x = torch.rand(100, 3, 100)
        y = torch.rand(100, 3, 100)
        res1 = torch.cross(x, y)
        res2 = torch.Tensor()
        torch.cross(x, y, out=res2)
        self.assertEqual(res1, res2)
test_torch.py 文件源码 项目:pytorch 作者: pytorch 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def test_cross(self):
        x = torch.rand(100, 3, 100)
        y = torch.rand(100, 3, 100)
        res1 = torch.cross(x, y)
        res2 = torch.Tensor()
        torch.cross(x, y, out=res2)
        self.assertEqual(res1, res2)


问题


面经


文章

微信
公众号

扫码关注公众号