[Python] How Can I Get Positive Responses Only from a Neural Net?

Discussão em 'Python' iniciado por Stack, Maio 4, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using TensorFlow. I have many simulated datasets for which values are real. Each one consists of 200 rows and two columns (variables). I'm using a convolutional neural net. I want the simulated data to be the input, and the three parameters in the model that I use to generate that data to be the output. These parameters must be positive. One of them specifically is usually a small fraction. I am using the below code, but the parameter that's usually a small fraction sometimes has negative predicted values. What changes can I make to restrict it to being at least zero? Thanks!

    model=models.Sequential()

    model.add(layers.Conv1D(32,3, activation='relu', input_shape=(200, 2)))
    model.add(layers.MaxPooling1D(2))
    model.add(layers.Conv1D(64, 3, activation='relu'))
    model.add(layers.MaxPooling1D(2))
    model.add(layers.Conv1D(128, 3, activation='relu'))
    model.add(layers.Flatten())
    model.add(layers.Dense(3))

    Continue reading...

Compartilhe esta Página