Closed marlon-shiftone closed 1 year ago
@marlon-shiftone,
From the code, I can see you are using custom python functions for your data transformations. You need to use tft.apply_pyfunc to apply the custom functions to the input features. This function is for using inside a preprocessing_fn. It is a wrapper around tf.py_func
.
The functions added this way can run in Transform, and during training but TensorFlow Serving will not be able to serve this graph. for that we already have an issue #tfx/3178.
Note: This API can only be used when TF2 is disabled or tft_beam.Context.force_tf_compat_v1=True.
@singhniraj08 thanks for the comment. I have already fixed it and moved forward with the code. For the entire discussion check out this link:
https://discuss.tensorflow.org/t/tfx-transform-layer-returning-an-empty-dictionary/16781/9
@marlon-shiftone,
Requesting you to close this issue, if it's resolved for you. Thanks.
The issue has been solved: Moral: for saving the graph - or using it at the serving stage, what is the same here - there should be no Pythonic operation in the preprocessing_fn function. All the Pythonic methods have to be replaced by TensorFlow tf_compat_v1 methods. Also, the variables seem to have to be declared in the scope of the preprocessing_fn function. tf.py_func will work in the training phase, but it will not work in the serving phase, for the first reason.
I have created preprocessing_fn function for processing audio data - along with other functions. I have struggled to make all the functions able to generate a graph, however, I'm still getting the error:
ValueError: Missing data for input "audio_xf". You passed a data dictionary with keys []. Expected the following keys: ['audio_xf']
The graph loaded after preprocessing the data,transformed_features = model.tft_layer(parsed_features)
, returns an empty dictionary. I'm not sure if it is due to the nature of my function definitions and that's why I'm creating an issue - I would like to know at least the reason for the bug so I can try to solve it - spending more hours on it.Here comes my
preprocessing_fn
function:Here comes the bug logs:
Thanks