简体   繁体   中英

The correct way of using keras sequatial()

Please, someone, check what I have done in the code below. I'm not getting the result am anticipating it. I Am trying to build a model for a regression problem. My data contains 9 features and 1 target.

# define the model
def baseline():
    # create model
    model = ()
    
    # add one fully connected layer
    model.add(Dense(units = 9, input_dim=9, activation='relu'))
    model.add(Dense(units = 9, activation='relu'))
    model.add(Dense(units = 9, activation='relu'))
    model.add(Dense(units = 9, activation='relu'))
    model.add(Dense(units = 9, activation='relu'))
    model.add(Dense(units = 9, activation='relu'))
    model.add(Dense(units = 9, activation='relu'))
    model.add(Dense(units = 9, activation='relu'))
    model.add(Dense(units = 9, activation='relu'))
    model.add(Dense(units = 5, activation='relu'))

    
    # add a fully connected layer for the output
    model.add(Dense(units=1, activation='sigmoid'))
    
    # Compile model
    model.compile(loss='mse', optimizer='adam',metrics=[metrics.mse])
    
    return model

you will need to define a model like this model = Sequential() but other than that everything is correct

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM