# [Regression problem with PyTorch] Predict coordinate with sensors data

Hi, I tried to predict the mobile device screen coordinate, but the result were not well.

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).

The `Up Distance` value is the distance between correct coordinate and user touch point, and the `Predict Distance` value is the distance between correct coordinate and predict output. The target is to decrease `Predict Distance` as possible.

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.

The following are parameters, model and results:

``````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
``````