深度学习模型用于预测多边形中心点。

huangapple go评论41阅读模式
英文:

Deep Learning Model to predict polygon centroids

问题

I understand your request, and I will only provide translations for the text you've provided without any additional content or responses. Here's the translated text:

我知道这似乎复杂化了一个非常简单的问题,但我已经受到了我的主管的指示,他希望找到一个大分子的每个分子面的质心。这个问题可以简化为找到一个n边形的质心,其中n≥3,并且可以在不同的多边形之间变化。模型的输入是多边形的顶点集,其中每个顶点都表示为3D坐标,输出必须是质心的3D坐标。

我尝试使用ReLU函数执行了一个图卷积网络来解决这个问题,输入维度为3(用于3D坐标),输出维度为3,认为我会获得3个输出维度的x、y和z坐标。然而,我得到的是基于多边形的每个顶点的质心预测,而不是基于多边形本身的质心。

为了解决这个问题,我已经将找到质心向量z的问题制定为找到权重w1, w2, w3....wn的问题,使得z=w1 * z1 + w2 * z2 + w3 * z3 + ... + wn * zn,其中w1, w2, w3,.....,wn的理想值应为1/n。尽管使用了带有softmax函数的GCN,尽管我对权重的预测取得了令人满意的结果,但质心的结果远未令人满意。

英文:

I know this seems like complicating a very simple problem, but I have been instructed to do this by my supervisor who wishes to find the centroid of each molecular face of a large molecule. This problem can be reduced to finding the centroid of an n-sided polygon, where n>=3 and can vary between polygons. The input to the model is a set of vertices of the polygon, where each vertex is represented as 3D coordinates, and the output must be the 3D coordinates of the centroid.

I have tried executing a Graph Convolutional Network with the ReLU function for this approach, with input dimension as 3 (for the 3D coordinates) and output dimension as 3, thinking that I would obtain the x, y and z coordinates the 3 output dimensions. However, what I get is a prediction of the centroid based on each vertex of the polygon, and not based on the polygon itself.

To tackle this problem, I have formulated the problem of finding the centroid vector z as finding weights w1, w2, w3....wn such that z=w1 * z1 + w2 * z2 + w3 * z3 + ... + wn * zn, where the ideal values of w1, w2, w3,.....,wn would be 1/n. Using the GCN with the softmax function, even though I achieved satisfactory predictions for the weights, the results for the centroid was far from satisfactory.

答案1

得分: 2

你使用 softmax 函数的方法应该可行,因为所有权重 wi 的总和应该为1。事实上,如果你将网络训练了相当少的周期,w1 的值将会收敛到你所需的值。

我可以想到一种可能的架构如下:

    def __init__(self, input, hidden, output):
        # 在这里添加代码:
        
        # GCN 架构。你可以使用 GCNConv 而不是 CustomGraphConv
        self.gcn1=CustomGraphConv(input, hidden)
        self.gcn2=CustomGraphConv(hidden, hidden)
        self.fc=nn.Linear(hidden, output)
        self.softmax=nn.Softmax(dim=0)
        
    def forward(self, x, edges):
        x=self.gcn1(x, edges)
        x=F.relu(x)
        x=self.gcn2(x, edges)
        x=F.relu(x)
        x=self.fc(x)
        x=self.softmax(x)
        return x

在继续使用此代码之前,请注意张量的维度,特别是对于 Softmax 函数。

英文:

Your approach of using the softmax function should work, since the sum of all weights wi should be 1. In fact, if you train the network for a fairly small number of epochs, the values of w1 will converge to your required values.

One possible architecture which I can think of is below:

    def __init__(self, input, hidden, output):
        # Add code here:
        
        # GCN architecture. You can use the GCNConv instead of CustomGraphConv
        self.gcn1=CustomGraphConv(input, hidden)
        self.gcn2=CustomGraphConv(hidden, hidden)
        self.fc=nn.Linear(hidden, output)
        self.softmax=nn.Softmax(dim=0)
        
    def forward(self, x, edges):
        x=self.gcn1(x, edges)
        x=F.relu(x)
        x=self.gcn2(x, edges)
        x=F.relu(x)
        x=self.fc(x)
        x=self.softmax(x)
        return x

Take care of the dimensions of the tensor before proceeding with this code, especially for the Softmax function.

huangapple
  • 本文由 发表于 2023年6月13日 18:51:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76464145.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定