Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
848 views
in Technique[技术] by (71.8m points)

tensorflow2.0 - How to enable ServingInputReceiver to accept and parse serialized examples in different format?

Given this function, I'm able to let my model accept incoming ExampleListWithContext message, but I want it to also accept message in TFExample format. How could I reach this?

    def build_ELWC_parsing_serving_input_receiver_fn(self,
                                                     default_batch_size=None,
                                                     input_name="inputs"):
       
        shared_feature_spec, example_feature_spec = self.create_feature_spec_for_elwc()

        def serving_input_receiver_fn():
            """An input_fn that expects a serialized ExampleListWithContext."""
            serialized_elwc_tensor = tf.compat.v1.placeholder(
                dtype=tf.dtypes.string,
                shape=[default_batch_size],
                name="input_elwc_tensor",
            )
            receiver_tensors = {input_name: serialized_elwc_tensor}
            features = parse_from_example_list(
                serialized_elwc_tensor,
                context_feature_spec=shared_feature_spec,
                example_feature_spec=example_feature_spec,
            )
            return ServingInputReceiver(features, receiver_tensors)
        return serving_input_receiver_fn
question from:https://stackoverflow.com/questions/65948459/how-to-enable-servinginputreceiver-to-accept-and-parse-serialized-examples-in-di

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...