Hi, thanks for help with rotation matrix, now when i got it, iam trying to rotate matrix and then find angle with Pytorch. This is my code - iam not sure if loss function is good but my angle_pred and loss does not change after 100 loops.
Do you have idea where problem is ?
import torch

x = torch.rand((256,2))
angle = torch.tensor(0.08)
rot = torch.tensor([[torch.cos(angle), -torch.sin(angle)], [torch.sin(angle), torch.cos(angle)]])

x_rot = torch.matmul(x, rot)

angle_pred = torch.nn.Parameter(torch.zeros(1), requires_grad=True)

optimizer = torch.optim.Adam([angle_pred], lr = 0.1)


for step in range(100):
    rot_back = torch.tensor([[torch.cos(-angle_pred), -torch.sin(-angle_pred)], [torch.sin(-angle_pred), torch.cos(-angle_pred)]], requires_grad=True)
    x_pred = torch.matmul(x_rot, rot_back)

    loss = ((x_pred-x)**2).mean()

    optimizer.zero_grad()
    loss.backward()
    optimizer.step()
    print(loss)