2

I want to create an experiment with my pretrained and saved model on azure ml. When using this model, I get this error:

Got exception when invoking script: ''Sequential' object has no attribute '_distribution_strategy''.

It probably has something to do with the installed libraries, however, I don't know how to fix it. Here is the code:

    import pandas as pd
    import numpy as np
    import sys
    import pickle
    import io
    import os
    os.system(f"pip install keras")
    os.system(f"pip install tensorflow=2.2")
    
    import keras
    
    from sklearn.feature_extraction.text import TfidfVectorizer
    
    def azureml_main(df, dataframe2 = None):
    
    
        sys.path.insert(0,"./Script Bundle")
        tfidf, clf = pickle.load(open("./Script Bundle/model.pkl", 'rb'))
    
        f = tfidf.transform(df.description)
       
        y_pred = clf.predict_classes(f.toarray()) ### this line causes the error
        y_probability = np.around(clf.predict_proba(f.toarray()),4)
        df_pred = pd.DataFrame(y_pred).transpose()
        df_probability = pd.DataFrame(y_probability).transpose()
            
        df_all = pd.concat([df_pred.transpose(),df_probability.transpose()],axis=1)
    
        return df_all,

Hope someone can help.

impaler
  • 21
  • 1
  • Does [this](https://stackoverflow.com/questions/59765784/attributeerror-sequential-object-has-no-attribute-get-distribution-strategy) answer your question ? If not please share complete code to replicate your issue. so that we can help you. Thanks! –  Nov 05 '20 at 11:41

0 Answers0