aws / amazon-sagemaker-examples

Example 📓 Jupyter notebooks that demonstrate how to build, train, and deploy machine learning models using 🧠 Amazon SageMaker.
https://sagemaker-examples.readthedocs.io
Apache License 2.0
10.18k stars 6.79k forks source link

Sagemaker Neo compiled model is giving slightly different results than the actual keras model #2022

Closed anubhav1 closed 3 years ago

anubhav1 commented 3 years ago

Describe the bug Sagemaker Neo compiled model is giving slighthly different results than the actual keras model.

To Reproduce I created a simple Keras regression model and trained it and then saved it in h5 format. Then in order to deploy on greengrass, i compiled this model using neo and then deployed it and inferenced using lamda function. Final prediction result is slightly different than the prediction of actual keras model.

Model:

import pandas as pd
from keras.models import Sequential
from keras.layers import *

model = Sequential()
model.add(Dense(50, input_dim=9, activation='relu'))
model.add(Dense(100, activation='relu'))
model.add(Dense(50, activation='relu'))
model.add(Dense(1, activation='linear'))
model.compile(loss='mean_squared_error', optimizer='adam')

Is it an expected behaviour?

hongshanli23 commented 3 years ago

hi @anubhav1 , it's unlikely to be the expected behavior. Try here https://stackoverflow.com/questions/tagged/amazon-sagemaker