简体   繁体   中英

Can I use a neural network on a linear regression using Keras? If yes , How?

I'm having difficulties setting up a NN in Keras. Please help me!

This is my code and I'm getting random values every time when I predict.

model = Sequential()
layer1 = Dense(5, input_shape = (5,))
model.add(layer1)
model.add(Activation('relu'))

layer2 = Dense(1)
model.add(layer2)   
model.add(Activation('relu'))


model.compile(loss='mean_squared_error', optimizer='adam')
model.fit(xtrain, ytrain, verbose=1)

I have 5 input features and want to predict a single continuous value as an output

Input space have five features. The problem was that i am getting random prediction at same input. Now, I have reach the solution. It is happening just because of that i am not doing the normalisation of features.

Thanks

From my point of view,

you are not giving your input shape correctly

layer1 = Dense(5, input_shape = (5,))

What is your actual input shape?

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