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

Where is the edge collapse operation in the code? #44

Open
liangqianqian123 opened this issue Nov 26, 2019 · 3 comments
Open

Where is the edge collapse operation in the code? #44

liangqianqian123 opened this issue Nov 26, 2019 · 3 comments
Labels

Comments

@liangqianqian123
Copy link

1

I want to know where is the change of edge feature after edge pooling in the code? Is it in the file mesh_pool.py? I only find the function "def __pool_side(self, mesh, edge_id, mask, edge_groups, side)", but this function didn't involve the change of the edge feature.
Thank you please.

@ranahanocka
Copy link
Owner

Hi @liangqianqian123 ,

It is called a "mesh union" in the code. Specifically, see union_groups line in __pool_side. This is defined in the Mesh_union class.

@ranahanocka ranahanocka added the question FAQ label Dec 2, 2019
@liangqianqian123
Copy link
Author

I want to know where is the change of edge feature, such as average operation of the edge features. Is it in the class MeshUnion "rebuild_features_average"?

`class MeshUnion:
def init(self, n, device=torch.device('cpu')):
self.__size = n
self.rebuild_features = self.rebuild_features_average
self.groups = torch.eye(n).to(device)

def union(self, source, target):
    self.groups[target, :] += self.groups[source, :]
  
def remove_group(self, index):
    return

def get_group(self, edge_key):
    return self.groups[edge_key, :]

def get_occurrences(self):
    return torch.sum(self.groups, 0)

def get_groups(self, tensor_mask):
    self.groups = torch.clamp(self.groups, 0, 1)
    return self.groups[tensor_mask, :]

def rebuild_features_average(self, features, mask, target_edges):
    self.prepare_groups(features, mask)
    fe = torch.matmul(features.squeeze(-1), self.groups)
    occurrences = torch.sum(self.groups, 0).expand(fe.shape)
    fe = fe / occurrences
    padding_b = target_edges - fe.shape[1]
    if padding_b > 0:
        padding_b = ConstantPad2d((0, padding_b, 0, 0), 0)
        fe = padding_b(fe)
    return fe

def prepare_groups(self, features, mask):
    tensor_mask = torch.from_numpy(mask)
    #tensor to numpy
    #   a.numpy()
    # numpy to tensor
    #   torch.from_numpy(a)
    self.groups = torch.clamp(self.groups[tensor_mask, :], 0, 1).transpose_(1, 0)
    padding_a = features.shape[1] - self.groups.shape[0]
    if padding_a > 0:
        padding_a = ConstantPad2d((0, 0, 0, padding_a), 0)
        self.groups = padding_a(self.groups)`

@ranahanocka
Copy link
Owner

Is it in the class MeshUnion "rebuild_features_average"?

yep!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants