<p dir="auto">I built a project using (Merge, merge) layer once, and use share layer in another. The problem I can't find any documentation that explains how merge or share layer works like convolution or max-pooling layers.<br>
I will be grateful if anyone can direct me or suggest some paper to me ???</p>
<ul class="contains-task-list">
<li class="task-list-item">
<p dir="auto"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Check that you are up-to-date with the master branch of Keras. You can update with:<br>
pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps</p>
</li>
<li class="task-list-item">
<p dir="auto"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found <a href="https://www.tensorflow.org/get_started/os_setup" rel="nofollow">here</a>.</p>
</li>
<li class="task-list-item">
<p dir="auto"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short).</p>
</li>
</ul>
<p dir="auto"><a href="https://github.com/fchollet/keras/blob/master/keras/preprocessing/image.py#L417">ImageDataGenerator.flow()</a> expects numpy arrays and does not accept but TF tensors containing the same image data. Should this be updated to accept TF tensors of images and labels, and are there any plans to do so?</p>
<p dir="auto">Proposed example code of loading such data from a TFRecord for semantic segmentation:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import tensorflow as tf
from keras.preprocessing.image import ImageDataGenerator

    # tfrecord_filenames_queue : tfrecord filename queue
    #    String queue object from tf.train.string_input_producer()
    reader = tf.TFRecordReader()

    _, serialized_example = reader.read(tfrecord_filenames_queue)

    features = tf.parse_single_example(
      serialized_example,
      features={
        'height': tf.FixedLenFeature([], tf.int64),
        'width': tf.FixedLenFeature([], tf.int64),
        'image_raw': tf.FixedLenFeature([], tf.string),
        'mask_raw': tf.FixedLenFeature([], tf.string)
        })

    
    image = tf.decode_raw(features['image_raw'], tf.uint8)
    annotation = tf.decode_raw(features['mask_raw'], tf.uint8)
    
    height = tf.cast(features['height'], tf.int32)
    width = tf.cast(features['width'], tf.int32)
    
    image_shape = tf.pack([height, width, 3])
    annotation_shape = tf.pack([height, width, 1])
    
    image = tf.reshape(image, image_shape)
    annotation = tf.reshape(annotation, annotation_shape)


    # This will do preprocessing and realtime data augmentation:
    datagen = ImageDataGenerator(
        featurewise_center=False,  # set input mean to 0 over the dataset
        samplewise_center=False,  # set each sample mean to 0
        featurewise_std_normalization=False,  # divide inputs by std of the dataset
        samplewise_std_normalization=False,  # divide each input by its std
        zca_whitening=False,  # apply ZCA whitening
        rotation_range=0,  # randomly rotate images in the range (degrees, 0 to 180)
        width_shift_range=0.1,  # randomly shift images horizontally (fraction of total width)
        height_shift_range=0.1,  # randomly shift images vertically (fraction of total height)
        horizontal_flip=True,  # randomly flip images
        vertical_flip=False)  # randomly flip images

        datagen.flow(image, annotation,
                        batch_size=32)"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">tensorflow</span> <span class="pl-k">as</span> <span class="pl-s1">tf</span>
<span class="pl-k">from</span> <span class="pl-s1">keras</span>.<span class="pl-s1">preprocessing</span>.<span class="pl-s1">image</span> <span class="pl-k">import</span> <span class="pl-v">ImageDataGenerator</span>

    <span class="pl-c"># tfrecord_filenames_queue : tfrecord filename queue</span>
    <span class="pl-c">#    String queue object from tf.train.string_input_producer()</span>
    <span class="pl-s1">reader</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-v">TFRecordReader</span>()

    <span class="pl-s1">_</span>, <span class="pl-s1">serialized_example</span> <span class="pl-c1">=</span> <span class="pl-s1">reader</span>.<span class="pl-en">read</span>(<span class="pl-s1">tfrecord_filenames_queue</span>)

    <span class="pl-s1">features</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">parse_single_example</span>(
      <span class="pl-s1">serialized_example</span>,
      <span class="pl-s1">features</span><span class="pl-c1">=</span>{
        <span class="pl-s">'height'</span>: <span class="pl-s1">tf</span>.<span class="pl-v">FixedLenFeature</span>([], <span class="pl-s1">tf</span>.<span class="pl-s1">int64</span>),
        <span class="pl-s">'width'</span>: <span class="pl-s1">tf</span>.<span class="pl-v">FixedLenFeature</span>([], <span class="pl-s1">tf</span>.<span class="pl-s1">int64</span>),
        <span class="pl-s">'image_raw'</span>: <span class="pl-s1">tf</span>.<span class="pl-v">FixedLenFeature</span>([], <span class="pl-s1">tf</span>.<span class="pl-s1">string</span>),
        <span class="pl-s">'mask_raw'</span>: <span class="pl-s1">tf</span>.<span class="pl-v">FixedLenFeature</span>([], <span class="pl-s1">tf</span>.<span class="pl-s1">string</span>)
        })

    
    <span class="pl-s1">image</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">decode_raw</span>(<span class="pl-s1">features</span>[<span class="pl-s">'image_raw'</span>], <span class="pl-s1">tf</span>.<span class="pl-s1">uint8</span>)
    <span class="pl-s1">annotation</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">decode_raw</span>(<span class="pl-s1">features</span>[<span class="pl-s">'mask_raw'</span>], <span class="pl-s1">tf</span>.<span class="pl-s1">uint8</span>)
    
    <span class="pl-s1">height</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">cast</span>(<span class="pl-s1">features</span>[<span class="pl-s">'height'</span>], <span class="pl-s1">tf</span>.<span class="pl-s1">int32</span>)
    <span class="pl-s1">width</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">cast</span>(<span class="pl-s1">features</span>[<span class="pl-s">'width'</span>], <span class="pl-s1">tf</span>.<span class="pl-s1">int32</span>)
    
    <span class="pl-s1">image_shape</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">pack</span>([<span class="pl-s1">height</span>, <span class="pl-s1">width</span>, <span class="pl-c1">3</span>])
    <span class="pl-s1">annotation_shape</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">pack</span>([<span class="pl-s1">height</span>, <span class="pl-s1">width</span>, <span class="pl-c1">1</span>])
    
    <span class="pl-s1">image</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">reshape</span>(<span class="pl-s1">image</span>, <span class="pl-s1">image_shape</span>)
    <span class="pl-s1">annotation</span> <span class="pl-c1">=</span> <span class="pl-s1">tf</span>.<span class="pl-en">reshape</span>(<span class="pl-s1">annotation</span>, <span class="pl-s1">annotation_shape</span>)


    <span class="pl-c"># This will do preprocessing and realtime data augmentation:</span>
    <span class="pl-s1">datagen</span> <span class="pl-c1">=</span> <span class="pl-v">ImageDataGenerator</span>(
        <span class="pl-s1">featurewise_center</span><span class="pl-c1">=</span><span class="pl-c1">False</span>,  <span class="pl-c"># set input mean to 0 over the dataset</span>
        <span class="pl-s1">samplewise_center</span><span class="pl-c1">=</span><span class="pl-c1">False</span>,  <span class="pl-c"># set each sample mean to 0</span>
        <span class="pl-s1">featurewise_std_normalization</span><span class="pl-c1">=</span><span class="pl-c1">False</span>,  <span class="pl-c"># divide inputs by std of the dataset</span>
        <span class="pl-s1">samplewise_std_normalization</span><span class="pl-c1">=</span><span class="pl-c1">False</span>,  <span class="pl-c"># divide each input by its std</span>
        <span class="pl-s1">zca_whitening</span><span class="pl-c1">=</span><span class="pl-c1">False</span>,  <span class="pl-c"># apply ZCA whitening</span>
        <span class="pl-s1">rotation_range</span><span class="pl-c1">=</span><span class="pl-c1">0</span>,  <span class="pl-c"># randomly rotate images in the range (degrees, 0 to 180)</span>
        <span class="pl-s1">width_shift_range</span><span class="pl-c1">=</span><span class="pl-c1">0.1</span>,  <span class="pl-c"># randomly shift images horizontally (fraction of total width)</span>
        <span class="pl-s1">height_shift_range</span><span class="pl-c1">=</span><span class="pl-c1">0.1</span>,  <span class="pl-c"># randomly shift images vertically (fraction of total height)</span>
        <span class="pl-s1">horizontal_flip</span><span class="pl-c1">=</span><span class="pl-c1">True</span>,  <span class="pl-c"># randomly flip images</span>
        <span class="pl-s1">vertical_flip</span><span class="pl-c1">=</span><span class="pl-c1">False</span>)  <span class="pl-c"># randomly flip images</span>

        <span class="pl-s1">datagen</span>.<span class="pl-en">flow</span>(<span class="pl-s1">image</span>, <span class="pl-s1">annotation</span>,
                        <span class="pl-s1">batch_size</span><span class="pl-c1">=</span><span class="pl-c1">32</span>)</pre></div>