RedaOps / ann-visualizer

A python library for visualizing Artificial Neural Networks (ANN)
MIT License
1.24k stars 216 forks source link

ValueError: ANN Visualizer: Layer not supported for visualizing #30

Open juanpamm opened 4 years ago

juanpamm commented 4 years ago

Hello, I am trying to plot my model but it keeps throwing the exception ValueError: ANN Visualizer: Layer not supported for visualizing

Here is my code:

from tensorflow import keras
from ann_visualizer.visualize import ann_viz

def add_layers_to_network(model, nodes, activation_func):
    if activation_func == 'relu':
        model.add(keras.layers.Dense(nodes, activation=tf.nn.relu))
    elif activation_func == 'sigmoid':
        model.add(keras.layers.Dense(nodes, activation=tf.nn.sigmoid))
    elif activation_func == 'tanh':
        model.add(keras.layers.Dense(nodes, activation=tf.nn.tanh))
    elif activation_func == 'elu':
        model.add(keras.layers.Dense(nodes, activation=tf.nn.elu))
    elif activation_func == 'softmax':
        model.add(keras.layers.Dense(nodes, activation=tf.nn.softmax))

def build_neural_network(nlayers, nodes, act_functions, output_act_func):
    model = keras.Sequential([
       keras.layers.Flatten(input_shape=(utils.width, utils.height))
 ])

# Construction of the hidden layers
for i in range(nlayers):
    add_layers_to_network(model, nodes[i], act_functions[i])

# Construction of the output layer
add_layers_to_network(model, len(utils.class_names), output_act_func)

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

model.fit(train_images, train_labels, epochs=epochs)

ann_viz(model, title="My first neural network")

Thanks in advance.