Returns name of the input tensor. Args: tensor: tf.Tensor Returns: str
(tensor)
| 66 | |
| 67 | |
| 68 | def get_tensor_name(tensor): |
| 69 | """Returns name of the input tensor. |
| 70 | |
| 71 | Args: |
| 72 | tensor: tf.Tensor |
| 73 | |
| 74 | Returns: |
| 75 | str |
| 76 | """ |
| 77 | parts = tensor.name.split(":") |
| 78 | if len(parts) > 2: |
| 79 | raise ValueError("Tensor name invalid. Expect 0 or 1 colon, got {0}".format( |
| 80 | len(parts) - 1)) |
| 81 | |
| 82 | # To be consistent with the tensor naming scheme in tensorflow, we need |
| 83 | # drop the ':0' suffix for the first tensor. |
| 84 | if len(parts) > 1 and parts[1] != "0": |
| 85 | return tensor.name |
| 86 | return parts[0] |
| 87 | |
| 88 | |
| 89 | def get_tensors_from_tensor_names(graph, tensor_names): |
no test coverage detected