Complete the code to import TensorFlow Serving's model server module.
from tensorflow_serving.apis import [1]
The prediction_service_pb2_grpc module is used to communicate with TensorFlow Serving's gRPC API.
Complete the code to create a gRPC channel to the TensorFlow Serving server running on localhost port 8500.
channel = grpc.insecure_channel('[1]')
The default gRPC port for TensorFlow Serving is 8500, and localhost is the address for the local machine.
Fix the error in the code to create a PredictRequest and set the model name to 'my_model'.
request = predict_pb2.PredictRequest() request.model_spec.name = '[1]'
The model name must match the name used when starting TensorFlow Serving. Here, it is 'my_model'.
Fill both blanks to set the input tensor name and assign a numpy array named 'input_data' to the request.
request.inputs['[1]'].CopyFrom(tf.make_tensor_proto([2]))
The input tensor name must match the model's expected input name, often 'input_tensor'. The data assigned is the numpy array 'input_data'.
Fill all three blanks to send the request, get the response, and extract the output tensor named 'output_tensor'.
stub = prediction_service_pb2_grpc.PredictionServiceStub([1]) response = stub.Predict(request, [2]) output = tf.make_ndarray(response.outputs['[3]'])
The stub uses the gRPC channel to communicate. The timeout is set in seconds (10.0). The output tensor name must match the model's output signature.
