How to make integers output layer?

259 Views Asked by At

I have network like this, I want to make last layer to return integers (target data is integers)

connection=[
    layers.Input(4),
    layers.Sigmoid(50),layers.Sigmoid(50),
    layers.Sigmoid(1),
],
1

There are 1 best solutions below

0
On

You cannot do it during the training, because you will need to round your values and it will completely vanish information for the gradient, but you can make predictions that very close to the integer and when you need to use it you can just convert value to the integer

from neupy import algorithms, layers

network = algorithms.GradientDescent([
    layers.Input(4),
    layers.Relu(50),
    layers.Relu(50),
    layers.Relu(1), 
])
prediction = network.predict(data).round()