[Regression problem with PyTorch] Predict coordinate with sensors data

username: Lindosun
cooked: <p>Hi, I tried to predict the mobile device screen coordinate, but the result were not well.</p>
<p>The input data [300*16] are 300 time points with 16 ACTION_DOWN/ACTION_UP/4 sensors coordinates, the output data [1*2] are correct coordinate (x, y).</p>
<p>The <code>Up Distance</code> value is the distance between correct coordinate and user touch point, and the <code>Predict Distance</code> value is the distance between correct coordinate and predict output. The target is to decrease <code>Predict Distance</code> as possible.</p>
<p>I tried to change optimizer, loss function, model construct etc. but I couldn’t find out where the problem is. Can anyone help me? Thanks so much.</p>
<p>The following are parameters, model and results:</p>
<pre><code class="lang-auto">BATCH_SIZE = 128
LEARNING_RATE = 0.01
DROPOUT = 0.3

optimizer = torch.optim.SGD(model.parameters(), lr=LEARNING_RATE)
criterion = torch.nn.SmoothL1Loss()

class CustomModel(torch.nn.Module):
    def __init__(self):
        super(CustomModel, self).__init__()
        self.conv1_1 = torch.nn.Conv1d(
            in_channels=FEATURE_CHANNEL, out_channels=FEATURE_CHANNEL, kernel_size=3, stride=2)
        self.pool_1 = torch.nn.MaxPool1d(kernel_size=3, stride=2)
        
        self.conv1_2 = torch.nn.Conv1d(
            in_channels=FEATURE_CHANNEL, out_channels=FEATURE_CHANNEL, kernel_size=3, stride=2)
        self.pool_2 = torch.nn.MaxPool1d(kernel_size=3, stride=2)

        self.dropout = torch.nn.Dropout(DROPOUT)
        
        self.conv1_3 = torch.nn.Conv1d(
            in_channels=FEATURE_CHANNEL, out_channels=FEATURE_CHANNEL, kernel_size=3, stride=2)
        self.pool_3 = torch.nn.MaxPool1d(kernel_size=3, stride=2)
        
        self.conv1_4 = torch.nn.Conv1d(
            in_channels=FEATURE_CHANNEL, out_channels=FEATURE_CHANNEL, kernel_size=2, stride=2)
        
        self.fc1 = torch.nn.Linear(16, 2)
        
    def forward(self, x):
        x = self.conv1_1(x)
        x = torch.nn.functional.relu(x)
        x = self.pool_1(x)
        
        x = self.conv1_2(x)
        x = torch.nn.functional.relu(x)
        x = self.pool_2(x)
        
        x = self.dropout(x)
        
        x = self.conv1_3(x)
        x = torch.nn.functional.relu(x)
        x = self.pool_3(x)
        
        x = self.conv1_4(x)
        x = torch.nn.functional.relu(x)
        
        x = x.view(-1, 1*16)

        x = self.fc1(x)

        return x
</code></pre>
<p><div class="lightbox-wrapper"><a class="lightbox" href="https://discuss.pytorch.org/uploads/default/original/3X/c/d/cd13daf9fb1fde7627f6b63d55b957e734ff3b5b.jpeg" data-download-href="https://discuss.pytorch.org/uploads/default/cd13daf9fb1fde7627f6b63d55b957e734ff3b5b" title="%E5%9C%96%E7%89%872"><img src="https://discuss.pytorch.org/uploads/default/optimized/3X/c/d/cd13daf9fb1fde7627f6b63d55b957e734ff3b5b_2_517x245.jpeg" alt="%E5%9C%96%E7%89%872" data-base62-sha1="tgcq7PfjYmT99x228g6SlSJFGYz" width="517" height="245" srcset="https://discuss.pytorch.org/uploads/default/optimized/3X/c/d/cd13daf9fb1fde7627f6b63d55b957e734ff3b5b_2_517x245.jpeg, https://discuss.pytorch.org/uploads/default/optimized/3X/c/d/cd13daf9fb1fde7627f6b63d55b957e734ff3b5b_2_775x367.jpeg 1.5x, https://discuss.pytorch.org/uploads/default/optimized/3X/c/d/cd13daf9fb1fde7627f6b63d55b957e734ff3b5b_2_1034x490.jpeg 2x" data-dominant-color="F7F3F6"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">%E5%9C%96%E7%89%872</span><span class="informations">1920×910 197 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div></p>