Convert v into a list.
(v, arg_name)
| 194 | |
| 195 | |
| 196 | def make_shape(v, arg_name): |
| 197 | """Convert v into a list.""" |
| 198 | # Args: |
| 199 | # v: A TensorShapeProto, a list of ints, or a tensor_shape.TensorShape. |
| 200 | # arg_name: String, for error messages. |
| 201 | |
| 202 | # Returns: |
| 203 | # None if the rank is unknown, otherwise a list of ints (or Nones in the |
| 204 | # position where the dimension is unknown). |
| 205 | try: |
| 206 | shape = tensor_shape.as_shape(v) |
| 207 | except TypeError as e: |
| 208 | raise TypeError("Error converting %s to a TensorShape: %s." % (arg_name, e)) |
| 209 | except ValueError as e: |
| 210 | raise ValueError("Error converting %s to a TensorShape: %s." % (arg_name, |
| 211 | e)) |
| 212 | if shape.ndims is None: |
| 213 | return None |
| 214 | else: |
| 215 | return shape.as_list() |
| 216 | |
| 217 | |
| 218 | def make_tensor(v, arg_name): |