Fit a Gaussian curve with a neural network using Pytorch
Suppose the following model : 

import torch.nn as nn

class PGN(nn.Module):
    def __init__(self, input_size):
        super(PGN, self).__init__()

        self.linear = nn.Sequential(
            nn.Linear(in_features=input_size, out_features=128),
            nn.ReLU(),
            nn.Linear(in_features=128, out_features=1)
        )

    def forward(self, x):
        return self.linear(x)


I figure I have to modify the model to fit a 2-dimensional curve.

Is there a way to fit a Gaussian curve with mu=0 and sigma=0 using Pytorch? If so, can you show me?

A neural network can approximate an arbitrary function of any number of parameters to a space of any dimension.

To fit a 2 dimensional curve your network should be fed with vectors of size 2, that is a vector of x and y coordinates. The output is a single value of size 1.

For training you must generate ground truth data, that is a mapping between coordinates (x and y) and the value (z). The loss function should compare this ground truth value with the estimate of your network.

If it is just a tutorial to learn Pytorch and not a real application, you can define a function that for a given x and y output the gaussian value according to your parameters.

Then during training you randomly choose a x and y and feed this to the networks then do backprop with the true value.
