训练形状为(13708,46)的数据框X_train会出现以下错误:
ValueError:检查输入时出错:预期density_97_input具有形状(46,)但具有形状(6,)的数组
培训代码:
import keras as K
from keras.models import Sequential
from keras.layers import Dense
from keras.wrappers.scikit_learn import KerasClassifier
model = K.models.Sequential()
model.add(K.layers.Dense(units=46, input_shape=(46,), activation='relu', kernel_initializer='glorot_uniform',
bias_initializer='zeros'))
model.add(K.layers.Dense(units=30, activation='relu'))
model.add(K.layers.Dense(units=30, activation='softmax'))
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
model.summary()
h = model.fit(X_train, y_train, batch_size=512, epochs=20, verbose=1)
我该怎么办?