Jerome Ariola
Jerome Ariola

Reputation: 135

How to remove last layers of Inception model

Hi I followed a forum from Github about removing the last layers of a pre-trained model. However it's not working for me; perhaps I did something wrong

I'm following this and here's my code. I thought all I had to do was model.layers[-2].output but it's telling me AttributeError: 'Tensor' object has no attribute 'summary'

import tensorflow as tf
import tensorflow.keras as keras
import tensorflow.keras.backend as K
import numpy as np
from tensorflow.keras.layers import Dense, Input, Layer
from tensorflow.keras.models import Model
from tensorflow.keras.applications.inception_v3 import InceptionV3


model = InceptionV3()
print(model.summary())

modele = model.layers[-2].output
print(modele.summary())

Upvotes: 1

Views: 1327

Answers (1)

jbasquiat
jbasquiat

Reputation: 101

modele variable is only a layer. You have to do:

model = InceptionV3()
print(model.summary())

output = model.layers[-2].output
modele = Model(inputs = model.input, outputs = output)
print(modele.summary())

Upvotes: 1

Related Questions