# The designing of Neural network

For example, to design a Net, the input feature is an M-dimensional vector, the output is a D-dimensional vector, and then calculate the loss based on the value of the D-dimensional vector. When the output vector value is limited to a discrete value (such as [0, 1, 2, 3, 4]), Net does not seem to be updated, because the input feature forward propagation outputs the values of discrete D-dimensional vectors almost identically. Net is written like this:

class Net(torch.nn.Module):
def init(self, n_dim, n_obj, problem):
super(Net, self).init()
self.n_dim = n_dim
self.n_obj = n_obj
self.problem = problem
self.fc1 = nn.Linear(self.n_obj, 256)
self.fc2 = nn.Linear(256, 256)
# self.fc3 = nn.Linear(256, self.n_dim*5)

``````    self.fc3 = nn.Linear(256, self.n_dim)
def forward(self, pref):

x = torch.relu(self.fc1(pref))
x = torch.relu(self.fc2(x))
x = self.fc3(x)

x = torch.sigmoid(x) * 5
x = torch.floor(x)

return x.to(torch.float64)
``````

Any problems in my code? I want to know why that neural network is don’t work.

The `torch.floor` operation will return zero gradients and defined here and seen here:

``````x = torch.randn(10, 10, requires_grad=True)

y = torch.floor(x)
y.mean().backward()

print(x.grad)
# tensor([[0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
#         [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
#         [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
#         [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
#         [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
#         [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
#         [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
#         [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
#         [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.],
#         [0., 0., 0., 0., 0., 0., 0., 0., 0., 0.]])
``````

Working with a discrete output thus won’t work and you should use common approaches of e.g. using logits for multi-class classification use cases etc.