我对 Tensorflow 和 SageMaker 还很陌生,我正在尝试弄清楚如何编写我的serving_input_fn()
. 我已经尝试了很多方法来做到这一点,但无济于事。
我的输入函数有 3 个特征列amount_normalized, x_month and y_month
:
def construct_feature_columns():
amount_normalized = tf.feature_column.numeric_column(key='amount_normalized')
x_month = tf.feature_column.numeric_column(key='x_month')
y_month = tf.feature_column.numeric_column(key='y_month')
return set([amount_normalized, x_month, y_month])
我希望能够使用类似的东西来调用我部署的模型deployed_model.predict([1.23,0.3,0.8])
其中第一个元素是amount_normalized
,第二个是x_month
第三个是y_month
我试过这个:
FEATURES = ['amount_normalized', 'x_month', 'y_month']
def serving_input_fn(params):
feature_placeholders = {
key : tf.placeholder(tf.float32, [None]) \
for key in FEATURES
}
return tf.estimator.export.build_raw_serving_input_receiver_fn(feature_placeholders)()
但我得到的只是:
An error occurred (ModelError) when calling the InvokeEndpoint operation: Received server error (500) from model with message "".
任何帮助将不胜感激!