Search code examples
tensorflowkerasgoogle-colaboratorygraphvizgraph-visualization

Google Colab (tensorflow) aan visulizer


I am trying to visualise my neural network architecture on Google Colab. However, for some reason it is not producing any visual outcome. Could you tell me why my code does not work on Colab? I cannot use anything like python IDE. It has to be Google Colab.

!pip3 install keras
!pip3 install ann_visualizer
!pip install graphviz

from keras.models import Sequential  
from keras.layers import Dense  
from ann_visualizer.visualize import ann_viz  

network = Sequential()  
#Hidden Layer#1  
network.add(Dense(units=2, activation='relu',  kernel_initializer='uniform', input_dim=2))  
#Output Layer  
network.add(Dense(units=1, activation='sigmoid', kernel_initializer='uniform'))  
ann_viz(network, title="")

Solution

  • One workaround would be to give your call to ann_viz a filename and then download the file.

    ann_viz(network, view=True, title="test", filename="visualized")
    

    Now when you click the file folder on the left, you'll see the output file as a PDF with the filename 'visualized'.

    enter image description here