我在Keras的訓練神經網絡的迴歸問題。 爲什麼輸出只有一個尺寸,每個Epoch的精度始終顯示acc:0.0000e + 00?在Keras的零準確性訓練神經網絡
這樣子:
1000/199873 [..............................] - ETA:5s - 損失:0.0057 - acc:0.0000e + 00
2000/199873 [..............................] - ETA:4s - 損失:0.0058 - acc:0.0000e + 00
3000/199873 [........................... ...] - ETA:3s - 損失:0.0057 - acc:0.0000e + 00
4000/199873 [....................... .......] - ETA:3s - 損失:0.0060 - acc: 0.0000e + 00 ...
198000/199873 [============================>。] - ETA:0s - 損失:0.0055 - acc:0.0000e + 00
199000/199873 [============================>。] - ETA :0s - 損失:0.0055 - acc:0.0000e + 00
199873/199873 [============================= =] - 4S - 損失:0.0055 - ACC:0.0000E + 00 - val_loss:0.0180 - val_acc:0.0000E + 00
曆元50/50
但是,如果輸出是兩個維度或以上,準確性沒有問題。
我的模型如下:`
input_dim = 14
batch_size = 1000
nb_epoch = 50
lrelu = LeakyReLU(alpha = 0.1)
model = Sequential()
model.add(Dense(126, input_dim=input_dim)) #Dense(output_dim(also hidden wight), input_dim = input_dim)
model.add(lrelu) #Activation
model.add(Dense(252))
model.add(lrelu)
model.add(Dense(1))
model.add(Activation('linear'))
model.compile(loss= 'mean_squared_error', optimizer='Adam', metrics=['accuracy'])
model.summary()
history = model.fit(X_train_1, y_train_1[:,0:1],
batch_size=batch_size,
nb_epoch=nb_epoch,
verbose=1,
validation_split=0.2)
loss = history.history.get('loss')
acc = history.history.get('acc')
val_loss = history.history.get('val_loss')
val_acc = history.history.get('val_acc')
'''saving model'''
from keras.models import load_model
model.save('XXXXX')
del model
'''loading model'''
model = load_model('XXXXX')
'''prediction'''
pred = model.predict(X_train_1, batch_size, verbose=1)
ans = [np.argmax(r) for r in y_train_1[:,0:1]]
謝謝你的答案,但它仍然顯示ACC:0.0000E + 00。 – soartseng