Seems like pytorch 0.4.1 doesn’t support matrix inverse of more than 2D.
>>> a = torch.rand(3, 2, 2) >>> inva = torch.inverse(a) Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: tensor should be 2 dimensional
But I found that pytorch 1.0.0 supports batched inverse, a way to invert higher dimensional matrix.
>>> x = torch.randn(2, 3, 4, 4) # from 1.0.0 doc >>> y = torch.inverse(x)
How can I inverse a 3D matrix with batched inverse?
Can I inverse 3D matrix in pytorch 0.4.1 and below?