错误:模型需要3个输入数组,但只接收一个数组。找到:有形状的阵列(10,20,50,50,1)

时间:2017-04-18 15:46:35

标签: tensorflow deep-learning keras conv-neural-network

 main_model = Sequential()
 main_model.add(Conv3D(32, 3, 3,3, input_shape=(20,50,50,1)))' 
 main_model.add(Activation('relu'))
 main_model.add(MaxPooling3D(pool_size=(2, 2,2))
 main_model.add(Conv3D(64, 3, 3,3))
 main_model.add(Activation('relu'))
 main_model.add(MaxPooling3D(pool_size=(2, 2,2)))
 main_model.add(Dropout(0.8))
 main_model.add(Flatten())

 #lower features model - CNN2
 lower_model1 = Sequential()
 lower_model1.add(Conv3D(32, 3, 3,3, input_shape=(20,50,50,1))) 
 lower_model1.add(Activation('relu'))
 lower_model1.add(MaxPooling3D(pool_size=(2, 2,2))) 
 lower_model1.add(Dropout(0.8))
 lower_model1.add(Flatten())

 #lower features model - CNN3
 lower_model2 = Sequential()
 lower_model2.add(Conv3D(32, 3, 3,3, input_shape=(20,50,50,1))) 
 lower_model2.add(Activation('relu'))
 lower_model2.add(MaxPooling3D(pool_size=(2, 2,2))) 
 lower_model2.add(Dropout(0.8))
 lower_model2.add(Flatten()) 

 merged_model = Merge([main_model, lower_model1,lower_model2],mode='concat') 
 final_model = Sequential()
 final_model.add(merged_model)
 final_model.add(Dense(1024,init='normal'))
 final_model.add(Activation('relu'))
 final_model.add(Dropout(0.5))
 final_model.add(Dense(2,init='normal'))
 final_model.add(Activation('softmax')) 
 final_model.compile(loss='binary_crossentropy', optimizer='Adam', metrics=
 ['accuracy'])
 train=train_data[-10:]
 test=train_data[-2:]
 X = np.array([i[0] for i in train]).reshape(-1,20,50,50,1)
 Y = [i[1] for i in train]
 test_x = np.array([i[0] for i in test]).reshape(-1,20,50,50,1)
 test_y = [i[1] for i in test]
 final_model.fit(np.array(X),np.array(Y),validation_data=
 (np.array(test_x),np.array(test_y)),batch_size=batch_size,nb_epoch = 
 nb_epoch,validation_split=0.2,shuffle=True,verbose=1)

我正在使用20块中包含的50x50图像,而我的numpy阵列是20x50x50 1st and 2nd models我使用顺序模型进行多尺度3d cnn网络...我不知道我得到了这种结果

see val_acc,val_loss stays the same in every epoch

0 个答案:

没有答案