If you have great ideas,
Let's talk!

blog

Meshgpt代码阅读【2】

3d相关export

5.MeshAutoEncoder **

# main face coordinate embedding

self.num_discrete_coors = num_discrete_coors
self.coor_continuous_range = coor_continuous_range

#用partial freeze function parameter
self.discretize_face_coords = partial(discretize, num_discrete = num_discrete_coors, continuous_range = coor_continuous_range)
self.coor_embed = nn.Embedding(num_discrete_coors, dim_coor_embed)

# derived feature embedding

self.discretize_angle = partial(discretize, num_discrete = num_discrete_angle, continuous_range = (0., pi))
self.angle_embed = nn.Embedding(num_discrete_angle, dim_angle_embed)

lo, hi = coor_continuous_range
self.discretize_area = partial(discretize, num_discrete = num_discrete_area, continuous_range = (0., (hi - lo) ** 2))
self.area_embed = nn.Embedding(num_discrete_area, dim_area_embed)

self.discretize_normals = partial(discretize, num_discrete = num_discrete_normals, continuous_range = coor_continuous_range)
self.normal_embed = nn.Embedding(num_discrete_normals, dim_normal_embed)

nn.linear 与 nn.embedding 区别

Linear(4,3) (input_dim, output_dim) 会生成(3,4)的linear.weight

y = wx 也就是(out, in) * (in, …)

w_linear(requires dense matrix → row.toarray())

Embedding(4,3) ← linear.weight.T

image.png

Dense 与 Sparse Matrix 区别

  • Sparse matrices are more memory-efficient than dense matrices when dealing with large matrices that have a significant number of zero elements. By storing only the non-zero elements explicitly, sparse matrices can save memory and computation time for certain operations.
  • However, there are situations where operations or algorithms may require dense matrices. For example, some mathematical operations, such as matrix multiplication or certain linear algebra operations, may be more efficient or easier to implement with dense matrices. Dense matrices allow for straightforward element-wise operations and can leverage optimized libraries for linear algebra computations.

SAGEConv

Implements the GraphSAGE (Graph Sample and Aggregated) convolutional layer

Each node in a graph updates its representation by aggregating features from its neighbors. Instead of using the entire neighborhood (as in standard GCNs), GraphSAGE uses a sampling mechanism to sample a fixed number of neighbors. After gathering information(With multiple possible aggregation functions) from the neighbors, the node combines its own features with the aggregated neighbor features to compute the updated node representation