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

How to get pool_3 layer from inception using Keras #50

Open
RahulGupta-Reflektion opened this issue Mar 31, 2017 · 5 comments
Open

How to get pool_3 layer from inception using Keras #50

RahulGupta-Reflektion opened this issue Mar 31, 2017 · 5 comments

Comments

@RahulGupta-Reflektion
Copy link

RahulGupta-Reflektion commented Mar 31, 2017

I used the following code following example in Readme.md


    base_model = InceptionV3(include_top=False, weights='imagenet')
    model = Model(input=base_model.input, output=base_model.get_layer('pool_3').output)
    
    img_path = 'elephant.jpg'
    img = image.load_img(img_path, target_size=(224, 224))
    x = image.img_to_array(img)
    x = np.expand_dims(x, axis=0)
    x = preprocess_input(x)

    pool_3_features = model.predict(x)


I get following error. What am I doing wrong.

Traceback (most recent call last):

  File "inception_v3.py", line 420, in <module>
    model = Model(input=base_model.input, output=base_model.get_layer('pool_3').output)
AttributeError: 'NoneType' object has no attribute 'output'
@RahulGupta-Reflektion
Copy link
Author

I got this code to work


    model = InceptionV3(weights='imagenet', include_top=False)

    img = image.load_img(img_path, target_size=(224, 224))
    x = image.img_to_array(img)
    x = np.expand_dims(x, axis=0)
    x = preprocess_input(x)

    features = model.predict(x)

Is it getting pool_3 layer or some other layer. dimensions seems to match.

@prashanthdumpuri
Copy link

model.summary() will print all the layers (along with the dimensions and parameters).

@Moondra
Copy link

Moondra commented Nov 26, 2017

@prashanthdumpuri Is there a way to look at specific layers from the summary? Inception has over 300 layers. Say I want to look at 35-50, is there a way to do this?

@prashanthdumpuri
Copy link

prashanthdumpuri commented Nov 27, 2017 via email

@Moondra
Copy link

Moondra commented Nov 30, 2017

@prashanthdumpuri Thank you very much.

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

3 participants