mahyar-amiri / keras-visualizer

A Keras Model Visualizer
MIT License
25 stars 2 forks source link

Explicitly defined input layers seem to break enumeration code #8

Closed n-garc closed 1 year ago

n-garc commented 1 year ago

I have a model with an explicitly defined input layer (e.g., model.add(layers.Input(shape=))). I am getting the following error:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[66], line 1
----> 1 visualizer(model, file_name='C:/graph.png', file_format='png', view=True, settings=None)

File ~\anaconda3\envs\psychopy_tf\lib\site-packages\keras_visualizer\__init__.py:61, in visualizer(model, file_name, file_format, view, settings)
     59 for num, layer in enumerate(model.layers, 1):
     60     if num == 1:
---> 61         input_layer = layer.input_shape[1]
     62     if num == len(model.layers):
     63         output_layer = layer.output_shape[1]

IndexError: list index out of range

For some reason, the input shape for the Input layer is a list with a tuple in it, rather than a tuple like the following layers


print(model.layers[0].input_shape)
print(model.layers[1].input_shape)
print(model.layers[2].input_shape)

[(None, 20, 80, 80, 1)]
(None, 20, 80, 80, 1)
(None, 18, 78, 78, 48)
mahyar-amiri commented 1 year ago

Hi,

The bug has been fixed in the new version (Version 3.1.2).

Thanks for your feedback.