I'm having trouble reading a piece of sample code for a model deformation.
The goal of the sample code is to optimize the model geometry through a backpropagation algorithm, which allows us to transform an initial model into a model that we need.
However, in the forward process, the sample code first transforms the initial node coordinates: including the definitions of self.center
, self.displace
, and uses log
, tanh
, sigmoid
, relu
and other functions. What is the significance of these transformations, and why not take the original node coordinates as the initial value and optimize them directly?
The forward part is as follows:
def execute(self, batch_size):
base = jt.log(self.vertices.abs() / (1 - self.vertices.abs()))
centroid = jt.tanh(self.center)
vertices = (base + self.displace).sigmoid() * nn.sign(self.vertices)
vertices = nn.relu(vertices) * (1 - centroid) - nn.relu(-vertices) * (centroid + 1)
vertices = vertices + centroid
where self.vertices
is the original node coordinates. And self.center
and self.displace
are two newly defined parameters.
# optimize for displacement map and center
self.displace = jt.zeros(self.template_mesh.vertices.shape)
self.center = jt.zeros((1, 1, 3))
The link of the code: https://github.com/Jittor/jrender. in "Basic tutorial 2: Geometry Optimization", demo2-deform.py