Reputation: 1886
I'm getting a “Unknown model type error” when training a model on Azure ML. It's a Keras TensorFlow model and here is my code that's failing:
mlflow.keras.log_model(
model=model,
registered_model_name=registered_model_name,
artifact_path=registered_model_name,
extra_pip_requirements=["protobuf~=3.20"],
)
mlflow.keras.save_model(
keras_model=model,
path=os.path.join(registered_model_name, "trained_model"),
extra_pip_requirements=["protobuf~=3.20"],
)
Error:
Epoch 20/20 - 3s - loss: 0.0047 - accuracy: 0.9988 - val_loss: 0.1677 - val_accuracy: 0.9809 2023/08/12 14:33:23 WARNING mlflow.tensorflow: You are saving a TensorFlow Core model or Keras model without a signature. Inference with mlflow.pyfunc.spark_udf() will not work unless the model's pyfunc representation accepts pandas DataFrames as inference inputs. Test loss: 0.1676583289883102 Test accuracy: 0.98089998960495 Registering the model via MLFlow -- 1 Traceback (most recent call last): File "keras_mnist.py", line 176, in mlflow.keras.log_model( File "/azureml-envs/azureml_e6c91049350b2ff55519ca4d0d2aa0dc/lib/python3.8/site-packages/mlflow/tensorflow/init.py", line 208, in log_model return Model.log( File "/azureml-envs/azureml_e6c91049350b2ff55519ca4d0d2aa0dc/lib/python3.8/site-packages/mlflow/models/model.py", line 572, in log flavor.save_model(path=local_path, mlflow_model=mlflow_model, **kwargs) File "/azureml-envs/azureml_e6c91049350b2ff55519ca4d0d2aa0dc/lib/python3.8/site-packages/mlflow/tensorflow/init.py", line 451, in save_model raise MlflowException(f"Unknown model type: {type(model)}") mlflow.exceptions.MlflowException: Unknown model type: <class 'keras.engine.sequential.Sequential'>
Conda Environment:
name: keras-env channels:
- conda-forge dependencies:
- python=3.8
- pip=21.2.4
- pip:
- protobuf~=3.20
- numpy==1.21.2
- tensorflow-gpu==2.2.0
- keras==2.3.1
- matplotlib
- mlflow==2.5.0
- azureml-mlflow==1.52.0
Upvotes: 0
Views: 577
Reputation: 1886
This turned out to be a dependencies issue. Here are the versions that worked for me.
name: keras-env
channels:
- conda-forge
dependencies:
- python=3.8
- pip=21.2.4
- pip:
- protobuf==3.19.6
- numpy==1.24.4
- tensorflow-gpu==2.11.0
- keras==2.11.0
- matplotlib==3.7.2
- azureml-mlflow==1.52.0
- mlflow==2.5.0
Upvotes: 0