Input datatype for deployed model

Hey all!

I think I’m struggling with a core concept here so bare with me! I’ve created a simple model to test my deployment infrastructure. I am using structured data and have followed this guide from the TF site. One of the key steps in model training is converting the data into tensors using tf.data.Dataset.from_tensor_slices. I understand why this is done but when I have deployed my model and I make a request to the endpoint I have to send my data in the JSON format, not as a tensor. This appears to cause a data type issue.

Do I have to create a preprocessing layer in my model that converts JSON or a dataframe into a Tensor using the above function? I have struggled to find examples of this so any help would be greatly appreciated!

Thanks :slight_smile:

1 Like

Hi @Alex_Ashford,

Yes, I recommend creating a separate layer for preprocessing for converting JSON data to a tensor/array. I’ve included a sample code for converting JSON_to_tensor.

Additionally, tf.data.Dataset.from_tensor_slices() method allows you to easily create a dataset from the tensor/array.

Thank You!!

1 Like