How to register a model in Azure Machine Learning when the model is a self made class encapsulating a tensorflow model ?

2022-11-04T11:08:44.293+00:00

Hello,

I'm training a tensor flow model locally, and using it in a self made class to add pre/post code to the TF model prediction.

I can't find how to register the model because a tensor flow model (ans thus my class containing it) can't be pickled (and apparently is not advised) so I can't use
Model.register(workspace, model_name=..., model_path=..., tags=..., description=...)

As I train my model locally and don't use experiments, it seems I can't either use run.register(...) as I don't have a run.

Also, I've seen from the documentation that I can add model_framework and model_framework_version parameters to the register method but I'm not sure what I should put in these parameters as I guess the framework is not just tensorflow but my self made class ?

Here is the structure of my class in case it can help:

   class DNN():  
         
       def __init__(self, dim, tokenizer, max_len):  
           """  
           Initialize Neural Network recommender.  
             
           Parameters  
           ----------  
           dim : int Dimension of the output Embedding layer.  
           tokenizer : The tokenize() generator  
           max_len : int Maximum number of elements for each list.  
           """  
           self.dim = dim  
           self.tokenizer = tokenizer  
           self.max_len = max_len  
               
       def fit(self, X, Y):  
           self.model = Sequential()  
           self.model.add(...)  
           self.model.compile(...)  
           self.model.fit(x=X, y=Y, ...)  
           return self  
     
       def predict(self, x):  
           apply_preprocessing(x)  
           pred = self.model.predict(padded_order)[0]  
           res = apply_postprocessing(pred )    
           return res  

Thank you for your help !

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,127 questions
{count} votes