MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / _set_batch_size

Method _set_batch_size

tensorflow/lite/python/lite.py:1016–1034  ·  view source on GitHub ↗

Sets the first dimension of the input tensor to `batch_size`. Args: batch_size: Batch size for the model. Replaces the first dimension of an input size array if undefined. (default 1) Raises: ValueError: input_tensor is not defined.

(self, batch_size)

Source from the content-addressed store, hash-verified

1014 return self._input_tensors and self._output_tensors
1015
1016 def _set_batch_size(self, batch_size):
1017 """Sets the first dimension of the input tensor to `batch_size`.
1018
1019 Args:
1020 batch_size: Batch size for the model. Replaces the first dimension of an
1021 input size array if undefined. (default 1)
1022
1023 Raises:
1024 ValueError: input_tensor is not defined.
1025 """
1026 if not self._has_valid_tensors():
1027 raise ValueError("The batch size cannot be set for this model. Please "
1028 "use input_shapes parameter.")
1029
1030 for tensor in self._input_tensors:
1031 shape = tensor.shape.as_list()
1032 if shape[0] is None:
1033 shape[0] = batch_size
1034 tensor.set_shape(shape)
1035
1036
1037@_tf_export(v1=["lite.TocoConverter"])

Callers 2

testValidConstructorMethod · 0.95
convertMethod · 0.95

Calls 3

_has_valid_tensorsMethod · 0.95
as_listMethod · 0.45
set_shapeMethod · 0.45

Tested by 1

testValidConstructorMethod · 0.76