RedaOps / ann-visualizer

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

Added features to CNN visualizations #4

Closed ayansengupta17 closed 6 years ago

ayansengupta17 commented 6 years ago
  1. Now input and output shapes are visible along the edges.
  2. Now padding is visible in Convolution layer block.
  3. padding and stride length are shown in Maxpool layer.
RedaOps commented 6 years ago

Can you post a photo of a CNN generated using your modified version?

ayansengupta17 commented 6 years ago

For a sample CNN model in Keras, I have attached the pdf file generated. network.gv.pdf

RedaOps commented 6 years ago
  1. The labels on the edges make the graph look bad and confusing.
  2. There is too much information on the convolutional and max pooling layers. I didn't want to add the padding info or other extra info because it is more advanced and the graph will become more complicated. Our goal is to make a simple visualization.

Thanks for the contribution!

ayansengupta17 commented 6 years ago

When I do machine learning projects I always require the input and output shapes. I thought it was something you really need to show. I agree that padding and strides are really optional. So do you want to make the function have options so that the user might have the choice of what information to show ?

RedaOps commented 6 years ago

The input and output shapes are shown through the number of nodes (in case of dense layers) or pixels when the first layer is a Conv2D layer.

ayansengupta17 commented 6 years ago

Do you use Keras? Someone who does, "(None, 16, 16, 32)" will make a lot of sense to him. It is simply 16x16 images with 32 filters. One can imagine it as a 3d model with stacks of images (convoluted). So I don't understand what you mean by "The input and output shapes are shown through the pixels when the first layer is a Conv2D layer". Shapes may change after conv layer and pool layers, so either you have to calculate them with help of pool size, stride, padding or you just show them and save the pain. Although for basic NN, its rather simple and can be seen from the number of nodes. (As you have already mentioned). If you still don't want to add input and output shapes that's fine. I have attached how in general (without graphs) keras display the architecture.

model

RedaOps commented 6 years ago

I know how keras displays a model, but I have created this script for people to visualize their models so they can explain them to other people who are not as tech savy.

A keras visualization would make no sense to someone who just wants to understand neural networks.

Same goes for "(None, 16, 16, 32)", a normal person would not understand what it means. I have included a layer showing the feature maps(after each conv layer) so the "output" of a conv layer can be understood more easily.

In what places exactly, do you think the graph has unclear output/input shapes, or where it needs to be improved?

RedaOps commented 6 years ago

I just want to keep the graphs simple. If you can find creative ways to display more information without making the graph seem overcomplicated, I would be more than happy to merge!

ayansengupta17 commented 6 years ago

ok, our purposes are somewhat different. I would be glad if this package has options so that all type of users can use this. This project has a lot of potentials.

RedaOps commented 6 years ago

I will release a version with advanced visualizations one day, but I want them to be creative, not just type info on the screen.

ayansengupta17 commented 6 years ago

just a suggestion: Use classes next time, It's easy to expand.