<p dir="auto">I am using TimeDistributedMerge to merge outputs from lstm over time by returning sequences, since TimeDistributedMerge is deprecated, so I changed my implementation to use timedistributed wrapper then it gives error.</p>
<p dir="auto">File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 148, in create_node<br>
output_tensors = to_list(outbound_layer.call(input_tensors[0], mask=input_masks[0]))<br>
File "/Library/Python/2.7/site-packages/keras/layers/wrappers.py", line 131, in call<br>
y = self.layer.call(X)  # (nb_samples * timesteps, ...)<br>
File "/Library/Python/2.7/site-packages/keras/engine/topology.py", line 1189, in call<br>
'(at least 2). Got: ' + str(inputs))<br>
Exception: Merge must be called on a list of tensors (at least 2). Got: Reshape{2}.0</p>
<p dir="auto">My code<br>
model = Sequential()<br>
model.add(Embedding(max_features, 128, input_length=chunk_size, dropout=0.5))<br>
model.add(LSTM(128, dropout_W=0.5, dropout_U=0.1,return_sequences=True))<br>
model.add(TimeDistributed(Merge(layers=None,mode='ave')))<br>
model.add(Dense(num_classes))<br>
model.add(Activation("softmax"))</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/fchollet/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/fchollet">@fchollet</a> can you help me out with this by giving an example of how to use timedistributed wrapper for lstm return sequences</p>
<p dir="auto">I've got code that works in the keras-1 compatibility layer of keras-2, but fails when I use the new <code class="notranslate">concatenate()</code> API.</p>
<p dir="auto">Key lines:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="    concat_axis = 1 if K.image_data_format() == 'channels_first' else -1

    x_list = [x]

    for i in range(nb_layers):
        x = __conv_block(x, growth_rate, bottleneck,
                         dropout_rate, weight_decay)
        x_list.append(x)

        # commenting merge() and uncommenting concatenate() fails
        x = merge(x_list, mode='concat', concat_axis=concat_axis)
        # x = concatenate(x_list, concat_axis)

        if grow_nb_filters:
            nb_filter += growth_rate

    if return_concat_list:
        return x, nb_filter, x_list
    else:
        return x, nb_filter"><pre class="notranslate">    <span class="pl-s1">concat_axis</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span> <span class="pl-k">if</span> <span class="pl-v">K</span>.<span class="pl-en">image_data_format</span>() <span class="pl-c1">==</span> <span class="pl-s">'channels_first'</span> <span class="pl-k">else</span> <span class="pl-c1">-</span><span class="pl-c1">1</span>

    <span class="pl-s1">x_list</span> <span class="pl-c1">=</span> [<span class="pl-s1">x</span>]

    <span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-s1">nb_layers</span>):
        <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">__conv_block</span>(<span class="pl-s1">x</span>, <span class="pl-s1">growth_rate</span>, <span class="pl-s1">bottleneck</span>,
                         <span class="pl-s1">dropout_rate</span>, <span class="pl-s1">weight_decay</span>)
        <span class="pl-s1">x_list</span>.<span class="pl-en">append</span>(<span class="pl-s1">x</span>)

        <span class="pl-c"># commenting merge() and uncommenting concatenate() fails</span>
        <span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-en">merge</span>(<span class="pl-s1">x_list</span>, <span class="pl-s1">mode</span><span class="pl-c1">=</span><span class="pl-s">'concat'</span>, <span class="pl-s1">concat_axis</span><span class="pl-c1">=</span><span class="pl-s1">concat_axis</span>)
        <span class="pl-c"># x = concatenate(x_list, concat_axis)</span>

        <span class="pl-k">if</span> <span class="pl-s1">grow_nb_filters</span>:
            <span class="pl-s1">nb_filter</span> <span class="pl-c1">+=</span> <span class="pl-s1">growth_rate</span>

    <span class="pl-k">if</span> <span class="pl-s1">return_concat_list</span>:
        <span class="pl-k">return</span> <span class="pl-s1">x</span>, <span class="pl-s1">nb_filter</span>, <span class="pl-s1">x_list</span>
    <span class="pl-k">else</span>:
        <span class="pl-k">return</span> <span class="pl-s1">x</span>, <span class="pl-s1">nb_filter</span></pre></div>
<p dir="auto">Error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/Users/athundt/source/keras-contrib/keras_contrib/applications/densenet.py&quot;, line 712, in &lt;module&gt;
    dn = DenseNet()
  File &quot;/Users/athundt/source/keras-contrib/keras_contrib/applications/densenet.py&quot;, line 136, in DenseNet
    model = Model(inputs, x, name='densenet')
  File &quot;/usr/local/lib/python2.7/site-packages/Keras-2.0.1-py2.7.egg/keras/legacy/interfaces.py&quot;, line 87, in wrapper
    return func(*args, **kwargs)
  File &quot;/usr/local/lib/python2.7/site-packages/Keras-2.0.1-py2.7.egg/keras/engine/topology.py&quot;, line 1704, in __init__
    str(layers_with_complete_input))
RuntimeError: Graph disconnected: cannot obtain value for tensor Tensor(&quot;conv2d_2/convolution:0&quot;, shape=(?, 32, 32, 12), dtype=float32) at layer &quot;concatenate_1&quot;. The following previous layers were accessed without issue: ['input_1', 'initial_conv2D', 'batch_normalization_1', 'activation_1', 'conv2d_1']"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/Users/athundt/source/keras-contrib/keras_contrib/applications/densenet.py", line 712, in &lt;module&gt;
    dn = DenseNet()
  File "/Users/athundt/source/keras-contrib/keras_contrib/applications/densenet.py", line 136, in DenseNet
    model = Model(inputs, x, name='densenet')
  File "/usr/local/lib/python2.7/site-packages/Keras-2.0.1-py2.7.egg/keras/legacy/interfaces.py", line 87, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/Keras-2.0.1-py2.7.egg/keras/engine/topology.py", line 1704, in __init__
    str(layers_with_complete_input))
RuntimeError: Graph disconnected: cannot obtain value for tensor Tensor("conv2d_2/convolution:0", shape=(?, 32, 32, 12), dtype=float32) at layer "concatenate_1". The following previous layers were accessed without issue: ['input_1', 'initial_conv2D', 'batch_normalization_1', 'activation_1', 'conv2d_1']
</code></pre></div>
<p dir="auto">The full code is in <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/keras-team/keras-contrib/commit/bf95474bdd48a85df1c443db0fa108bf28dcf86a/hovercard" href="https://github.com/keras-team/keras-contrib/commit/bf95474bdd48a85df1c443db0fa108bf28dcf86a">keras-team/keras-contrib@<tt>bf95474</tt></a></p>
<p dir="auto">Thank you!</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>