Add documentation for get_input_details()
PiperOrigin-RevId: 380293370
Change-Id: Ia6224da29582f770d38b5c230a8cbd9656f63430
diff --git a/tensorflow/lite/python/interpreter.py b/tensorflow/lite/python/interpreter.py
index 5d09668..3513050 100644
--- a/tensorflow/lite/python/interpreter.py
+++ b/tensorflow/lite/python/interpreter.py
@@ -559,10 +559,30 @@
return tensor_details
def get_input_details(self):
- """Gets model input details.
+ """Gets model input tensor details.
Returns:
- A list of input details.
+ A list in which each item is a dictionary with details about
+ an input tensor. Each dictionary contains the following fields
+ that describe the tensor:
+
+ + `name`: The tensor name.
+ + `index`: The tensor index in the interpreter.
+ + `shape`: The shape of the tensor.
+ + `shape_signature`: Same as `shape` for models with known/fixed shapes.
+ If any dimension sizes are unkown, they are indicated with `-1`.
+ + `dtype`: The numpy data type (such as `np.int32` or `np.uint8`).
+ + `quantization`: Deprecated, use `quantization_parameters`. This field
+ only works for per-tensor quantization, whereas
+ `quantization_parameters` works in all cases.
+ + `quantization_parameters`: A dictionary of parameters used to quantize
+ the tensor:
+ ~ `scales`: List of scales (one if per-tensor quantization).
+ ~ `zero_points`: List of zero_points (one if per-tensor quantization).
+ ~ `quantized_dimension`: Specifies the dimension of per-axis
+ quantization, in the case of multiple scales/zero_points.
+ + `sparsity_parameters`: A dictionary of parameters used to encode a
+ sparse tensor. This is empty if the tensor is dense.
"""
return [
self._get_tensor_details(i) for i in self._interpreter.InputIndices()
@@ -616,10 +636,12 @@
self._interpreter.ResizeInputTensor(input_index, tensor_size, strict)
def get_output_details(self):
- """Gets model output details.
+ """Gets model output tensor details.
Returns:
- A list of output details.
+ A list in which each item is a dictionary with details about
+ an output tensor. The dictionary contains the same fields as
+ described for `get_input_details()`.
"""
return [
self._get_tensor_details(i) for i in self._interpreter.OutputIndices()