nerdexam
Google

PROFESSIONAL-MACHINE-LEARNING-ENGINEER · Question #2

You trained a text classification model. You have the following SignatureDefs: You started a TensorFlow-serving component server and tried to send an HTTP request to get a prediction using: headers =

The correct answer is D. data = json.dumps({"signature_name": "serving_default", "instances" [[`a', `b'], [`c', `d'], [`e', `f']]}). A negative number in the shape enables auto expand (https://stackoverflow.com/questions/37956197/what-is-the-negative-index-in-shape-arrays-used- for-tensorflow). Then the first number -1 out of the shape (-1, 2) speaks the number of 1 dimensional arrays within the tensor (and it

Submitted by renata2k· Apr 18, 2026ML pipeline operationalization

Question

You trained a text classification model. You have the following SignatureDefs: You started a TensorFlow-serving component server and tried to send an HTTP request to get a prediction using: headers = {"content-type": "application/json"} json_response = requests.post('http: //localhost:8501/v1/models/text_model:predict', data=data, headers=headers) What is the correct way to write the predict request?

Exhibit

PROFESSIONAL-MACHINE-LEARNING-ENGINEER question #2 exhibit

Options

  • Adata = json.dumps({"signature_name": "seving_default", "instances" [[ab', bc', `cd']]})
  • Bdata = json.dumps({"signature_name": "serving_default", "instances" [[a', b', c', d', e', f']]})
  • Cdata = json.dumps({"signature_name": "serving_default", "instances" [[a', b', c'], [d', e', f']]})
  • Ddata = json.dumps({"signature_name": "serving_default", "instances" [[a', b'], [c', d'], [e', f']]})

How the community answered

(36 responses)
  • A
    3% (1)
  • B
    11% (4)
  • C
    6% (2)
  • D
    81% (29)

Explanation

A negative number in the shape enables auto expand (https://stackoverflow.com/questions/37956197/what-is-the-negative-index-in-shape-arrays-used- for-tensorflow). Then the first number -1 out of the shape (-1, 2) speaks the number of 1 dimensional arrays within the tensor (and it can autoexpand) while the second numer (2) sets the number of elements in the inner array at 2.

Topics

#TensorFlow Serving#Prediction API#JSON Request Format#Text Model Input

Community Discussion

No community discussion yet for this question.

Full PROFESSIONAL-MACHINE-LEARNING-ENGINEER Practice