Keras: Model summary not displaying "Connected to" contents

Created on 17 Apr 2017  路  4Comments  路  Source: keras-team/keras

Hi,
when using a model which in the summary output should display the "Connected to" column, I don't get any output there.
I am using keras 2.0.3 with the tensorflow backend.

The issue seems to be in utils/layer_utils.py in the print_layer_summary_with_connections internal function of the print_summary function. The condition "if node_key not in relevant_nodes" is never true, because node_key is a string and relevant nodes is a list containing keras.engine.topology.Node, not strings...
When removing the condition, the summary displays the content of the "Connected to" column.

Does anybody else have this issue? Is it only a tensorflow issue, meaning that with the theano backend it doesn't occur?

A small script for replicating the problem:

import keras
from keras.layers import Input
from keras.layers.core import Activation
from keras.layers.convolutional import Convolution2D, MaxPooling2D, ZeroPadding2D
from keras.layers.merge import Concatenate
from keras.layers.normalization import BatchNormalization
from keras.models import Model

if __name__=="__main__":
    input1 = Input(shape=(112, 224, 3), name="input1")
    input2 = Input(shape=(112, 224, 3), name="input2")
    x = Concatenate(axis=1, input_shape=[(112, 224, 3), (112, 224, 3)])([input1, input2])
    x = ZeroPadding2D(padding=(2, 2), input_shape=(224, 224, 3))(x)
    x = Convolution2D(filters=96, kernel_size=(11, 11), strides=(4, 4), name="conv1")(x)
    x = BatchNormalization()(x)
    x = Activation("relu")(x)
    output = MaxPooling2D(pool_size=(3, 3), strides=(2, 2), name="pool1")(x)

    model = Model([input1, input2], output)
    model.compile(optimizer=keras.optimizers.SGD(), loss=keras.losses.categorical_crossentropy)
    model.summary()

I will try to fix this issue. Please let me know if this issue also occurs for others..

stale

Most helpful comment

Same issue to me. I am using Keras 2.1.2.

All 4 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.

This still happens at Keras 2.1.2, see the code below for an example.

a = Sequential()
a.add(InputLayer(input_shape=(2,)) )
a.add(Dense(32) )
a.add(Dense(32) )
a.add(Dense(32) )
a.add(Dense(32) )
a = Model(inputs=[a.input], outputs=[a.output])
a.summary()

Output:

Layer (type)                 Output Shape              Param #   
=================================================================
input_21 (InputLayer)        (None, 2)                 0         
_________________________________________________________________
dense_56 (Dense)             (None, 32)                96        
_________________________________________________________________
dense_57 (Dense)             (None, 32)                1056      
_________________________________________________________________
dense_58 (Dense)             (None, 32)                1056      
_________________________________________________________________
dense_59 (Dense)             (None, 32)                1056      
=================================================================
Total params: 3,264
Trainable params: 3,264
Non-trainable params: 0
_________________________________________________________________

Same issue to me. I am using Keras 2.1.2.

Using keras 2.1.6-tf and also don't see connection info in .summary() calls.

from tensorflow.python.keras.models import Model
from tensorflow.python.keras.layers import Input, Dense

a = Input(shape=(32,))
b = Dense(32)(a)
model = Model(inputs=a, outputs=b)
model.summary()
Layer (type)                 Output Shape              Param #   
=================================================================
input_3 (InputLayer)         (None, 32)                0         
_________________________________________________________________
dense (Dense)                (None, 32)                1056      
=================================================================
Total params: 1,056
Trainable params: 1,056
Non-trainable params: 0
_________________________________________________________________
Was this page helpful?
0 / 5 - 0 ratings