:에 ValueError : 타겟 검사 오류 : 예상 dense_2하는 4 차원이 있지만 모양 배열있어 행 (7942, 1)
def create_model(X_train, X_test):
visible = Input(shape=(X_train.shape[0], X_train.shape[1], 1))
conv1 = Conv2D(32, kernel_size=4, activation='relu')(visible)
hidden1 = Dense(10, activation='relu')(pool2)
output = Dense(1, activation='sigmoid')(hidden1)
model = Model(inputs = visible, outputs = output)
model.compile(loss='binary_crossentropy',
optimizer='rmsprop',
metrics=['accuracy'])
return model
X_tr = np.reshape(X_train, (1,X_train.shape[0], X_train.shape[1], 1))
X_te = np.reshape(X_test, (1,X_test.shape[0], X_test.shape[1], 1))
model = create_model(X_train, X_test)
model.fit(X_tr, y_train, validation_split = 0.1, batch_size=10, epochs=10, verbose = 1, callbacks=[EarlyStopping(patience=5,verbose=1)])
여기서, X_train
은 7942 * 6400 차원 목록이고 y_train
은 해당 7942 레이블이있는 1-D 목록입니다.
오류 : 나는 기능 API에 안돼서으로 가능성이 잘못 무슨
ValueError: Error when checking target: expected dense_2 to have 4 dimensions, but got array with shape (7942, 1)
을 간?
'X_train'에 이미지가 포함되어있는 경우 이미지에 6400 값이 어떻게 분포되어 있습니까? 높이, 너비 및 채널은 무엇입니까? –
CSV 파일에서 기능 값을 읽습니다. 각 행은 6400 픽셀과 해당 레이블을 포함합니다. 그래서 제가 고려하고있는 (높이, 너비, 채널)은 (1, 6400, 1)입니다. –
이것은 작동하지 않습니다. 그것들이 2D라면, (800,800,1)과 같은 것입니다. –