Relative Content

Tag Archive for tensorflowkerasdeep-learning

How do I get rid of this error and unfreeze the top half of the layers for fine-tuning?

# Function to build the model def build_model(hp): base_model = MobileNetV3Large(weights=’imagenet’, include_top=False, input_shape=(224, 224, 3)) base_model.trainable = False # Freeze the base model x = base_model.output x = GlobalAveragePooling2D()(x) x = Dense(hp.Int(‘units’, min_value=64, max_value=512, step=64), activation=’relu’)(x) x = Dense(1, activation=’sigmoid’)(x) model = Model(inputs=base_model.input, outputs=x) model.compile(optimizer=Adam(hp.Choice(‘learning_rate’, [1e-2, 1e-3, 1e-4])), loss=’binary_crossentropy’, metrics=[‘accuracy’]) return model # Hyperparameter tuning […]

How to save a keras model just for inference?

I trained a CNN model and saved it as a .keras file. Now I want other people to use it for making predictions. I am planning on deploying it using a flask server and package the whole thing in an exe. The problem is When I do a .summary() after I load it back, I am able to see the entire model architecture. I was also able to see the values of the hyperparameters that I used when I trained the model.