Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/tensorflow/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Keras:使用来自目录的flow_的fit_生成器的多个输入_Python_Tensorflow_Keras - Fatal编程技术网

Python Keras:使用来自目录的flow_的fit_生成器的多个输入

Python Keras:使用来自目录的flow_的fit_生成器的多个输入,python,tensorflow,keras,Python,Tensorflow,Keras,fit_生成器中是否可能有两个来自_目录的流_ 比如说 train_generator_1 = train_datagen.flow_from_directory( train_data_dir_1, target_size=(img_height, img_width), batch_size=batch_size, class_mode='binary') train_generator_2 = train_datagen.flow_from_directo

fit_生成器中是否可能有两个来自_目录的流_

比如说

train_generator_1 = train_datagen.flow_from_directory(
    train_data_dir_1,
    target_size=(img_height, img_width),
    batch_size=batch_size,
    class_mode='binary')

train_generator_2 = train_datagen.flow_from_directory(
    train_data_dir_2,
    target_size=(img_height, img_width),
    batch_size=batch_size,
    class_mode='binary')

custom_vgg_model.fit_generator(
    [train_generator_1, train_generator_2],
    steps_per_epoch=nb_train_samples,
    epochs=epochs,
    validation_data=validation_generator,
    validation_steps=nb_validation_samples,
    callbacks=[checkpointer, csv_logger])

您可以尝试制作一个同时包含以下内容的生成器:

在python 3中:

def doubleGenerator(generator1,generator2):

    while True:
        for (x1,y1),(x2,y2) in zip(generator1,generator2):
            yield ([x1,x2],y1)

您想要两个并行输入吗?您的模型是否使用两个输入?输出结果如何?两个并行输出?@DanielMöller是的,我的模型有两个CNN。每个都有不同的输入。输出是相同的。输入基本上是相同的图像,但每个CNN都有不同的预处理图像。好的,输出。。。您想从生成器1还是生成器2获取它们?@DanielMöller这两个生成器的输出应该相同。所以两者都可以。我感谢你的帮助!另一个我推荐你。一个问题:这是检查在每个目录中找到的文件名吗?它是如何将imageA1与标签A和imageA2连接起来的,而imageA2也有标签A?