yu4u / convnet-drawer Goto Github PK
View Code? Open in Web Editor NEWPython script for illustrating Convolutional Neural Networks (CNN) using Keras-like model definitions
License: MIT License
Python script for illustrating Convolutional Neural Networks (CNN) using Keras-like model definitions
License: MIT License
Hi, I follow every step of the instruction, however, does not work, anyone can help me, thank you!
Traceback (most recent call last):
File "D:/lyceum/plot_CNN_architecture/CNN_archi.py", line 23, in
save_model_to_pptx(model, "1.pptx")
File "D:\lyceum\plot_CNN_architecture\pptx_util.py", line 63, in save_model_to_pptx
presentation.add_line(obj.x1, obj.y1, obj.x2, obj.y2, obj.color, obj.width, obj.dasharray)
File "D:\lyceum\plot_CNN_architecture\pptx_util.py", line 29, in add_line
connector.ln = connector.get_or_add_ln()
AttributeError: can't set attribute
Hi there,
I have come across some problem. convert_drawer_model
from keras_util
fail when GlobalAveragePooling2D
layer is included. But it is said here that GlobalAveragePooling2D
is supported.
Thanks in advance.
fix this problem. see pr #12
from keras_util import convert_drawer_model
from keras.preprocessing.image import ImageDataGenerator
from keras.models import Sequential
from keras.layers import Dense,Dropout,Activation,Flatten
from keras.layers import Conv2D,MaxPool2D,GlobalAveragePooling2D,AveragePooling2D
from keras import optimizers
from keras.callbacks import ReduceLROnPlateau,EarlyStopping
from keras.layers.normalization import BatchNormalization
from keras.regularizers import l2
batch_size = 128
epochs = 30
num_classes = 10
weight_decay = 1e-6
nets = 15
model = Sequential()
model.add(Conv2D(192,(5,5),padding='same',kernel_regularizer=l2(weight_decay),kernel_initializer='he_normal',input_shape=(28,28,1)))
#model.add(BatchNormalization())
#model.add(Activation('relu'))
model.add(Conv2D(160,(1,1),padding='same',kernel_regularizer=l2(weight_decay),kernel_initializer='he_normal'))
#model.add(BatchNormalization())
#model.add(Activation('relu'))
model.add(Conv2D(96,(1,1),padding='same',kernel_regularizer=l2(weight_decay),kernel_initializer='he_normal'))
#model.add(BatchNormalization())
#model.add(Activation('relu'))
model.add(MaxPool2D(pool_size=(3,3),strides=(2,2),padding='same'))
#model.add(Dropout(0.2))
model.add(Conv2D(192,(5,5),padding='same',kernel_regularizer=l2(weight_decay),kernel_initializer='he_normal'))
#model.add(BatchNormalization())
#model.add(Activation('relu'))
model.add(Conv2D(192,(1,1),padding='same',kernel_regularizer=l2(weight_decay),kernel_initializer='he_normal'))
#model.add(BatchNormalization())
#model.add(Activation('relu'))
model.add(Conv2D(192,(1,1),padding='same',kernel_regularizer=l2(weight_decay),kernel_initializer='he_normal'))
#model.add(BatchNormalization())
#model.add(Activation('relu'))
model.add(MaxPool2D(pool_size=(3,3),strides=(2,2),padding='same'))
#model.add(Dropout(0.2))
model.add(Conv2D(192,(3,3),padding='same',kernel_regularizer=l2(weight_decay),kernel_initializer='he_normal'))
#model.add(BatchNormalization())
#model.add(Activation('relu'))
model.add(Conv2D(192,(1,1),padding='same',kernel_regularizer=l2(weight_decay),kernel_initializer='he_normal'))
#model.add(BatchNormalization())
#model.add(Activation('relu'))
model.add(Conv2D(10,(1,1),padding='same',kernel_regularizer=l2(weight_decay),kernel_initializer='he_normal'))
#model.add(BatchNormalization())
#model.add(Activation('relu'))
model.add(GlobalAveragePooling2D())
#model.add(Activation('softmax'))
#adam = optimizers.rmsprop()
#model.compile(loss='categorical_crossentropy',optimizer=adam,metrics=['accuracy'])
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-19-677489d1360a> in <module>
----> 1 convert_drawer_model(model).save_fig('tmp.svg')
~/python_lib/convnet_drawer/keras_util.py in convert_drawer_model(model)
36 class_config = config.get("config", False)
37 if class_name and class_config:
---> 38 class_obj = is_class_object(class_name)
39 if class_name == "Conv2D":
40 conv_2d = get_conv2d_obj(class_obj, class_config)
~/python_lib/convnet_drawer/keras_util.py in is_class_object(class_name)
26
27 def is_class_object(class_name):
---> 28 return eval(class_name)
29
30
~/python_lib/convnet_drawer/keras_util.py in <module>
NameError: name 'GlobalAveragePooling2D' is not defined
AttributeError: 'LSTM' object has no attribute 'filters'.How to solve this problem?
I really love your work, as I said earlier but why don't you add the other layers, (Batch Normalization, Activation, Dropout, Zero Padding 2D, Max Pooling 2D), or at least package your code?
I am ready and willing to contribute with you, if you want..
Hi there,
Another error to declare:
File "C:\Users\ngenne\Desktop\PRIVE-Deep-Learning\NIH\chest-xray\convnet_drawer\pptx_util.py", line 63, in save_model_to_pptx
for feature_map in model.feature_maps + model.layers:
AttributeError: 'Sequential' object has no attribute 'feature_maps'
Code is below:
from convnet_drawer.convnet_drawer import Model, Conv2D, MaxPooling2D, Flatten, Dense
from convnet_drawer.keras_util import convert_drawer_model
from convnet_drawer.matplotlib_util import save_model_to_file
from convnet_drawer.pptx_util import save_model_to_pptx
from keras.models import Sequential
from convnet_drawer.keras_models import AlexNet
classifier = Sequential()
classifier = Model(input_shape=(1024, 1024, 1))
classifier.add(Conv2D(512, (256,256), strides=(4, 4), padding="same"))
classifier.add(MaxPooling2D(pool_size=(2, 2)))
classifier.add(Conv2D(512, (256,256), strides=(4, 4), padding="same"))
classifier.add(Conv2D(512, (256,256), strides=(4, 4), padding="same"))
classifier.add(MaxPooling2D(pool_size=(2, 2)))
classifier.add(Flatten())
classifier.add(Dense(4096))
classifier.add(Dense(4096))
classifier.add(Dense(1000))
classifier = AlexNet.get_model()
classifier_seq = convert_drawer_model(classifier)
classifier.save_model_to_pptx(classifier, "classifier.pptx")
Could you help me please?
Getting import error after installing via pip... Can anyone please help?
I've installed python-pptx, but this error occurred while I was running:
from convnet_drawer import Model, Conv2D, Deconv2D
ImportError: No module named 'convnet_drawer'
So I was wondering if its possible to visualize a multihead model [1], as I can only define one Input.
Is there anything i missed out?
The Dropout-Layer doesnt seem to be represented.
Error comes from the keras_util
NameError: name 'Dropout' is not defined
Hi there,
I'm getting an error everytime I want to generate the graph into the pdf file:
File "C:\Users\ngenne\Desktop\PRIVE-Deep-Learning\NIH\chest-xray\convnet_drawer\matplotlib_util.py", line 10, in save_model_to_file
plt.xlim(model.x, model.x + model.width)
AttributeError: 'Sequential' object has no attribute 'x'
Below my code:
from convnet_drawer.convnet_drawer import Model, Conv2D, MaxPooling2D, Flatten, Dense
from convnet_drawer.keras_util import convert_drawer_model
from convnet_drawer.matplotlib_util import save_model_to_file
from keras.models import Sequential
from convnet_drawer.keras_models import AlexNet
classifier = Sequential()
classifier = Model(input_shape=(1024, 1024, 1))
classifier.add(Conv2D(512, (256,256), strides=(4, 4), padding="same"))
classifier.add(MaxPooling2D(pool_size=(2, 2)))
classifier.add(Conv2D(512, (256,256), strides=(4, 4), padding="same"))
classifier.add(Conv2D(512, (256,256), strides=(4, 4), padding="same"))
classifier.add(MaxPooling2D(pool_size=(2, 2)))
classifier.add(Flatten())
classifier.add(Dense(4096))
classifier.add(Dense(4096))
classifier.add(Dense(1000))
classifier = AlexNet.get_model()
classifier_seq = convert_drawer_model(classifier)
Do you have a trick for me?
Running the example (AlexNet.py) I get the error "TypeError: super() takes at least 1 argument (0 given" from the line "model = Model(input_shape=(224, 224, 3))." Any ideas?
I receive an error about 'str' object has no attribute 'get':
from keras.models import Sequential
from keras.layers import Dense, Conv2D, Flatten, Dropout, MaxPooling2Dmodel = Sequential()
model.add(Conv2D(16, kernel_size=3, strides=3, activation='relu',
data_format="channels_last", input_shape=(129,1173,1)))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(32, kernel_size=3, strides=3, activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Conv2D(64, kernel_size=3, strides=3, activation='relu'))
model.add(Flatten())
model.add(Dense(units=256, activation='relu'))
model.add(Dense(units=128, activation='relu'))
model.add(Dense(units=64, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1))
model.compile(loss='mae', optimizer='adam')model_draw = convert_drawer_model(model)
model_draw.save_fig("11.svg")
AttributeError Traceback (most recent call last)
in
----> 1 model_draw = convert_drawer_model(model)
2 model_draw.save_fig("11.svg")~/Notebooks/convnet-drawer/keras_util.py in convert_drawer_model(model)
33 figure = Model(input_shape=_input_shape[1:])
34 for config in model.get_config():
---> 35 class_name = config.get("class_name", False)
36 class_config = config.get("config", False)
37 if class_name and class_config:AttributeError: 'str' object has no attribute 'get'
Hi there,
Thanks for making this great project! I am interested in using the project to export CNN diagrams in powerpoint, however I am running into an issue I was wondering if you maybe know how to troubleshoot.
I downloaded AlexNet.pptx from your repo and the graph looks like its not being rendered on the powerpoint correctly, here is a screenshot of what I am seeing in powerpoint:
It seems that the render location is going beyond the white region area, and going off the slides. Is this an issue on my powerpoint file, or do I have to offset the location in order to have the diagram rendered correctly.
When I export it to jpg, the rendering issue exists.
Please advise if you need more information, and I look forward to your response!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.