Custom Predict in Keras Model

71 views
Skip to first unread message

Mohammad Yahya

unread,
Mar 15, 2022, 9:06:35 PM3/15/22
to Keras-users
Hello All,

For building a custom model in keras, we can build a class that will extend keras.Model class. We can customize the training step with gradient tape, but how about customizing the prediction function that is usually called model.predict? 
class MiniInception(tf.keras.Model):
    def __init__(self, num_classes=10):
        super(MiniInception, self).__init__()

    def call(self, input_tensor, training=False, **kwargs):
        # forward pass 

    def build_graph(self, raw_shape): 
        pass

I would like to call our custom predict  MiniInception.custom_predict() not MiniInception.predict()? Can we do that please in keras? 

Thanks.
Reply all
Reply to author
Forward
0 new messages