我要使用彩色图片对图像进行分类。为此,我建立了深度学习模型。在网络中,我有三个用于颜色的输入,并且有一个用于分类的输出。训练模型时,出现了一些错误。
当我将RGB通道用于图像时,我所做的模型是否有变化?
def RNG_model_prediction(width,height,depth,classed):
Input1=Input(shape=(None,depth))#Color input R
Input2=Input(shape=(None,depth))#Color input G
Input3=Input(shape=(None,depth))#Color input B
#make up the model
model1=GRU(32,activation='tanh',return_sequences=True)(Input1)
model1_out=Dense(64,activation='relu')(model1)
model2=GRU(32,activation='tanh',return_sequences=True)(Input2)
model2_out=Dense(64,activation='relu')(model2)
model3=GRU(32,activation='tanh',return_sequences=True)(Input3)
model3_out=Dense(64,activation='relu')(model3)
model=concatenate([model1_out,model2_out,model3_out])
out=Dense(128,activation='relu')(model)
#output
out=Dense(classed,activation='softmax')(out)
model_al=Model([Input1,Input2,Input3],out)
return model_al
IMAGE_DIMS=[128,128,3]
model=vgg_16.RNG_model_prediction(width=IMAGE_DIMS[1],
height=IMAGE_DIMS[0],
depth=IMAGE_DIMS[2],classed=len(lb.classes_(6)))
opt =RMSprop(lr=0.1)
model.compile(loss="categorical_crossentropy", optimizer=opt,
metrics=["accuracy"])
#train the network
print("[INFO] training network...")
model.fit([train_data_B,train_data_G,train_data_R],labels,
epochs=50,batch_size=100)
train_data_R.shape
Out[8]: (466, 128, 128, 3)
ValueError: Error when checking input: expected input_10 to have 3
dimensions, but got array with shape (466, 128, 128, 3)