Sandeep vy
Sandeep vy

Reputation: 11

How to change softmax activation function layer of InceptionV3 into linear activation function layer?

I have imported InceptionV3 but need to change only softmax layer into linear activation function layer. I have implemented this much from tensorflow.keras.applications import InceptionV3

pre_model = InceptionV3(input_shape = (224, 224, 3), 
                                include_top = False, 
                                weights = 'imagenet')

# Make all the layers in the pre-model non-trainable
for layer in pre_model.layers:
    layer.trainable = False

What to do next?

layers.Dense  (1, activation='linear')

Where to place above code inorder to change activation='softmax' into activation='linear' in this architecture? (I don't need softmax I need linear activation function) I am training a model which predicts continuous value from a given image.

Upvotes: 0

Views: 315

Answers (1)

NanoBit
NanoBit

Reputation: 196

Try something like this,

model = Sequential([ pre_model, Dense(1, activation="linear") ])

Look up transfer learning.

Ref:

https://www.tensorflow.org/api_docs/python/tf/keras/Sequential https://www.tensorflow.org/tutorials/images/transfer_learning

Upvotes: 1

Related Questions