我的简单回归模型(按keras的方法)不起作用

时间:2018-11-27 12:57:22

标签: keras neural-network deep-learning

我是学习神经网络的初学者。 我正在进行kaggle项目-自行车共享需求。 我想通过keras使用简单的神经网络,但损失并未减少。 我该怎么办?

-----------代码--------------

# dataset from pandas

feature_names = ["season", "holiday", "workingday", "weather",
             "temp", "atemp", "humidity", "windspeed",
             "datetime_year", "datetime_hour", "datetime_dayofweek"]
label_name = ["count"]
X_train = train[feature_names]   #shape (10886, 11)
Y_train = train[label_name]      #shape (10886, 1)
X_test = test[feature_names]

# layers

model = Sequential()
model.add(Dense(units = 50, kernel_initializer = 'uniform', activation = 'relu', input_dim=11))
model.add(Dropout(0.3))
model.add(Dense(units = 50, kernel_initializer = 'uniform', activation = 'relu'))
model.add(Dropout(0.3))
model.add(Dense(units = 5, kernel_initializer = 'uniform', activation = 'relu'))
model.add(Dropout(0.3))
model.add(Dense(units = 1, kernel_initializer = 'uniform', activation = 'sigmoid'))


model.compile(optimizer = 'adam', loss = 'mean_squared_error', metrics = ['accuracy'])

# Train
model.fit(X_train, Y_train, batch_size = 100, epochs = 200)

---------结果------------

Epoch 1/200
10886/10886 [==============================] - 4s 325us/step - loss: 69206.2478 - acc: 0.0094
Epoch 2/200
10886/10886 [==============================] - 1s 93us/step - loss: 69184.5435 - acc: 0.0096
Epoch 3/200
10886/10886 [==============================] - 1s 89us/step - loss: 69181.6330 - acc: 0.0096
Epoch 4/200
10886/10886 [==============================] - 1s 93us/step - loss: 69179.0222 - acc: 0.0096
Epoch 5/200
10886/10886 [==============================] - 1s 91us/step - loss: 69175.7442 - acc: 0.0096
Epoch 6/200
10886/10886 [==============================] - 1s 109us/step - loss: 69171.9052 - acc: 0.0096
Epoch 7/200
10886/10886 [==============================] - 1s 122us/step - loss: 69171.6164 - acc: 0.0096
Epoch 8/200
10886/10886 [==============================] - 1s 92us/step - loss: 69167.6923 - acc: 0.0096
Epoch 9/200
10886/10886 [==============================] - 1s 91us/step - loss: 69166.2911 - acc: 0.0096
Epoch 10/200
10886/10886 [==============================] - 1s 94us/step - loss: 69164.1145 - acc: 0.0096
...

1 个答案:

答案 0 :(得分:0)

尝试在model.compile部分中设置学习率。从0.0001开始,然后从0.0010.01开始,看看会发生什么。