[英]How to train a dual streams inputs of CNN model with two DataIterator(s)?
I'm building a convolutional neural network (CNN) model consisting of dual stream image data input of 'RGB'
channels and 'grayscale'
channel converging into singular stream of shape (None, width, height, 4*C)
, then Dense()
. I'm building a convolutional neural network (CNN) model consisting of dual stream image data input of
'RGB'
channels and 'grayscale'
channel converging into singular stream of shape (None, width, height, 4*C)
, then Dense()
.
With big dataset, I must / forced to utilise <class 'ImageDataGenerator'>
:对于大数据集,我必须/被迫使用
<class 'ImageDataGenerator'>
:
from tensorflow.keras.preprocessing.image import ImageDataGenerator
datagen = ImageDataGenerator()
and flow the dataset via directory:并通过目录流动数据集:
train_C = datagen.flow_from_directory(
... ,
color_mode = 'rgb',
...
)
train_gr = datagen.flow_from_directory(
... ,
color_mode = 'grayscale',
...
)
Unfortunately, to train the model with fit
method as the following :不幸的是,要使用以下
fit
方法训练 model:
model.fit( x = [input_1, input_2], ... )
it raised the following error:它引发了以下错误:
ValueError: Failed to find data adapter that can handle input: (<class 'list'> containing values of types {"<class 'keras_preprocessing.image.directory_iterator.DirectoryIterator'>"}), <class 'NoneType'>
So, how should I resolve this issue?那么,我应该如何解决这个问题呢?
Note: Python 3.X & Tensorflow 2.X注: Python 3.X & Tensorflow 2.X
train_generator = zip(train_C, train_gr)
train_generator = zip(train_C, train_gr)
fused_1 = concatenate([averagepool, maxpool])
fused_1 = concatenate([averagepool, maxpool])
top_model = Dense(4096, activation='relu',name="dense_one")(fused_1)
top_model = Dense(4096, activation='relu',name="dense_one")(fused_1)
model = Model(inputs=[model1.input, model2.input], outputs=[top_model])
model = Model(inputs=[model1.input, model2.input], outputs=[top_model])
history = model.fit_generator(train_generator, ...)
history = model.fit_generator(train_generator, ...)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.