Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Matplotlib_util get an error #5

Open
ngenne opened this issue Sep 4, 2018 · 1 comment
Open

Matplotlib_util get an error #5

ngenne opened this issue Sep 4, 2018 · 1 comment

Comments

@ngenne
Copy link

ngenne commented Sep 4, 2018

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?

@yu4u
Copy link
Owner

yu4u commented Sep 5, 2018

Please carefully read examples.
You do not need to use Keras APIs.

from convnet_drawer import Model, Conv2D, MaxPooling2D, Flatten, Dense
from matplotlib_util import save_model_to_file

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))
save_model_to_file(classifier, "example.pdf")

The above code is enough.
But conv256x256 is not expected (usually 3x3 - 11x11) thus the resulting image seems to be broken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants