def _find_or_raise(self, tensor_name: str) -> tf.Tensor:
"""
Find the tensor with the given name in the default graph or raise an exception.
:param tensor_name: tensor name to be find
:return: tf.Tensor
"""
full_name = self._get_full_name(tensor_name)
try:
return tf.get_default_graph().get_tensor_by_name(full_name)
except (KeyError, ValueError, TypeError) as ex:
raise ValueError('Tensor `{}` with full name `{}` was not found.'.format(tensor_name, full_name)) from ex
评论列表
文章目录