RedaOps / ann-visualizer

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

Support for CNN/RNN models #1

Closed tobegit3hub closed 6 years ago

tobegit3hub commented 6 years ago

The project is great and it works for DNN models. But if we try to visualize the CNN/RNN models, it throws errors and draw the misleading images.

It would be great to support CNN/RNN as well. And here is the example code of Keras to test.

from ann_visualizer.visualize import ann_viz
model = build_cnn_model()
ann_viz(model, title="")

def build_cnn_model():
  model = keras.models.Sequential()

  model.add(
      Conv2D(
          32, (3, 3),
          padding="same",
          input_shape=(32, 32, 3),
          activation="relu"))
  model.add(Dropout(0.2))

  model.add(
      Conv2D(
          32, (3, 3),
          padding="same",
          input_shape=(32, 32, 3),
          activation="relu"))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  model.add(Dropout(0.2))

  model.add(
      Conv2D(
          64, (3, 3),
          padding="same",
          input_shape=(32, 32, 3),
          activation="relu"))
  model.add(Dropout(0.2))

  model.add(
      Conv2D(
          64, (3, 3),
          padding="same",
          input_shape=(32, 32, 3),
          activation="relu"))
  model.add(MaxPooling2D(pool_size=(2, 2)))
  model.add(Dropout(0.2))

  model.add(Flatten())
  model.add(Dense(512, activation="relu"))
  model.add(Dropout(0.2))

  model.add(Dense(10, activation="softmax"))

  return model
hzitoun commented 6 years ago

+1

RedaOps commented 6 years ago

Right now it only supports ANNs. I will try to add features for CNNs (because it would be awesome), but I have a lot of side projects regarding neural networks. Pull requests are extremely welcomed, but I will try to make some time and add features for CNNs.

Thanks for the suggestion!

RedaOps commented 6 years ago

fe1615e4c5b825fb4fcb169c5dd35f4e32942392

Version 2.0 is out. It now supports visualizing the following layers: