Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added vector output from skew-symmetric tensor #301

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion torchmdnet/models/tensornet.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ def vector_to_symtensor(vector):
S = 0.5 * (tensor + tensor.transpose(-2, -1)) - I
return S

def skewtensor_to_vector(tensor):
'''Converts a skew-symmetric tensor to a vector.'''
return torch.stack((tensor[:, :, 1, 2], tensor[:, :, 2, 0], tensor[:, :, 0, 1]), dim=-1)


def decompose_tensor(tensor):
"""Full tensor decomposition into irreducible components."""
Expand Down Expand Up @@ -265,10 +269,13 @@ def forward(
x = torch.cat((tensor_norm(I), tensor_norm(A), tensor_norm(S)), dim=-1)
x = self.out_norm(x)
x = self.act(self.linear((x)))
v = skewtensor_to_vector(A)
v = v.transpose(1, 2)
RaulPPelaez marked this conversation as resolved.
Show resolved Hide resolved
# # Remove the extra atom
if self.static_shapes:
x = x[:-1]
return x, None, z, pos, batch
v = v[:-1]
return x, v, z, pos, batch
RaulPPelaez marked this conversation as resolved.
Show resolved Hide resolved


class TensorEmbedding(nn.Module):
Expand Down
Loading