我有一个非常简单的数据集。我清理了数据(一个热门编码,正常化数据并检查缺失值或NaN),而且我的学习率非常低。但是,当试图运行使用Keras和Theano作为后端的简单回归Keras Logistic回归在第一个时代返回nan
model = Sequential()
model.add(Dense(input_dim=84, activation='softmax',
bias_initializer='normal', units=6))
rms = RMSprop(lr=0.001, rho=0.9, epsilon=1e-08, decay=0.0)
model.compile(optimizer=rms, loss='categorical_crossentropy')
batch_size = 100
nb_epoch = 1
n = X.shape[0] # number of training examples
history = model.fit(X, Y_oh, batch_size=batch_size, epochs=nb_epoch)
错误:
Epoch 1/1
5459/5459 [==============================] - 0s - loss: nan
我检查here,并试图降级Theano所提到的版本,但它仍然给出了同样的错误
这里是X的样子
[[ 0.35755179 0.13747887 0.3 ..., 0. 0. 0. ]
[ 0.36401758 0.14963742 0.55 ..., 0. 0. 0. ]
[ 0.37889517 0.13775149 0.275 ..., 0. 0. 0. ]
...,
[ 0.34387947 0.18706723 0.05 ..., 0. 0. 0. ]
[ 0.35708726 0.12905512 0.75 ..., 0. 0. 0. ]
[ 0.37915882 0.08061174 0.05 ..., 0. 1. 0. ]]
和Y_oh(使用下面的代码生成):
Y_oh = np_utils.to_categorical(Y.T[0],6)
[[ 0. 0. 0. 0. 0. 1.]
[ 0. 0. 0. 0. 0. 1.]
[ 0. 0. 0. 0. 0. 1.]
...,
[ 1. 0. 0. 0. 0. 0.]
[ 1. 0. 0. 0. 0. 0.]
[ 1. 0. 0. 0. 0. 0.]]