How to use 'list of tensors when single tensor expected' in Python

Every line of 'list of tensors when single tensor expected' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
296def __check_tensor_list(self, tensor_list):
297 expected = self._flat_tensor_specs
298 specs = [type_spec_from_value(t) for t in tensor_list]
299 if len(specs) != len(expected):
300 raise ValueError("Incompatible input: wrong number of tensors")
301 for i, (s1, s2) in enumerate(zip(specs, expected)):
302 if not s1.is_compatible_with(s2):
303 raise ValueError("Incompatible input: tensor %d (%s) is incompatible "
304 "with %s" % (i, tensor_list[i], s2))

Related snippets