Visualkeras is a Python package to help visualize Keras (either standalone or included in TensorFlow) neural network architectures. It allows easy styling to fit most needs. This module supports layered style architecture generation which is great for CNNs (Convolutional Neural Networks), and a graph style architecture, which works great for most models including plain feed-forward networks.
MIT License
586
stars
69
forks
source link
Error when trying to visualise Functional API model:- AttributeError: 'Functional' object has no attribute '_layers' #41
Hi Team,
I receive the following error when I try and run my CNN model built using the Keras Functional API:
`--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Input In [18], in <cell line: 4>() 1 import visualkeras 2 from PIL import ImageFont ----> 4 visualkeras.graph_view(early_model)
File ~/.local/lib/python3.9/site-packages/visualkeras/graph.py:58, in graph_view(model, to_file, color_map, node_size, background_fill, padding, layer_spacing, node_spacing, connector_fill, connector_width, ellipsize_after, inout_as_tensor, show_neurons) 54 layer_y = list() 56 # Attach helper layers ---> 58 id_to_num_mapping, adj_matrix = model_to_adj_matrix(model) 59 model_layers = model_to_hierarchy_lists(model, id_to_num_mapping, adj_matrix) 61 # add fake output layers
File ~/.local/lib/python3.9/site-packages/visualkeras/layer_utils.py:39, in model_to_adj_matrix(model) 37 if not model.built: 38 model.build() ---> 39 layers = model._layers 41 adj_matrix = np.zeros((len(layers), len(layers))) 42 id_to_num_mapping = dict()
AttributeError: 'Functional' object has no attribute '_layers'`
Below you will find the function used to build my model:
`# CNN MODEL
def build_early_integration_CNN(X_train, learning_rate, momentum, seed):
And the code used to call the function:
`#EARLY INTEGRATION
learning_rate = 1e-2 # initial learning rate, decays via learning rate scheduler momentum = 0.5 initializer_seed = 42
early_model = build_early_integration_CNN(X_train, learning_rate, momentum, initializer_seed)`
I would really appreciate your support as I am using these models for my MSc project and would love to include visualisations in my report!
Kind regards, Alex