Sets Tensor shape for each tensor if the shape is defined. Args: tensors: TensorFlow ops.Tensor. shapes: Dict of strings representing input tensor names to list of integers representing input shapes (e.g., {"foo": : [1, 16, 16, 3]}). Raises: ValueError: `shapes` contain
(tensors, shapes)
| 124 | |
| 125 | |
| 126 | def set_tensor_shapes(tensors, shapes): |
| 127 | """Sets Tensor shape for each tensor if the shape is defined. |
| 128 | |
| 129 | Args: |
| 130 | tensors: TensorFlow ops.Tensor. |
| 131 | shapes: Dict of strings representing input tensor names to list of |
| 132 | integers representing input shapes (e.g., {"foo": : [1, 16, 16, 3]}). |
| 133 | |
| 134 | Raises: |
| 135 | ValueError: |
| 136 | `shapes` contains an invalid tensor. |
| 137 | `shapes` contains an invalid shape for a valid tensor. |
| 138 | """ |
| 139 | if shapes: |
| 140 | tensor_names_to_tensor = { |
| 141 | get_tensor_name(tensor): tensor for tensor in tensors |
| 142 | } |
| 143 | for name, shape in shapes.items(): |
| 144 | if name not in tensor_names_to_tensor: |
| 145 | raise ValueError("Invalid tensor \'{}\' found in tensor shapes " |
| 146 | "map.".format(name)) |
| 147 | if shape is not None: |
| 148 | tensor = tensor_names_to_tensor[name] |
| 149 | try: |
| 150 | tensor.set_shape(shape) |
| 151 | except ValueError as error: |
| 152 | message = ("The shape of tensor '{0}' cannot be changed from {1} to " |
| 153 | "{2}. {3}".format(name, tensor.shape, shape, str(error))) |
| 154 | raise ValueError(message) |
| 155 | |
| 156 | |
| 157 | def get_grappler_config(optimizers_list): |
nothing calls this directly
no test coverage detected