Ensure a 2D shape. Args: a: a int or tuple/list of length 2 Returns: list: of length 2. if ``a`` is a int, return ``[a, a]``.
(a)
| 79 | |
| 80 | |
| 81 | def shape2d(a): |
| 82 | """ |
| 83 | Ensure a 2D shape. |
| 84 | |
| 85 | Args: |
| 86 | a: a int or tuple/list of length 2 |
| 87 | |
| 88 | Returns: |
| 89 | list: of length 2. if ``a`` is a int, return ``[a, a]``. |
| 90 | """ |
| 91 | if type(a) == int: |
| 92 | return [a, a] |
| 93 | if isinstance(a, (list, tuple)): |
| 94 | assert len(a) == 2 |
| 95 | return list(a) |
| 96 | raise RuntimeError("Illegal shape: {}".format(a)) |
| 97 | |
| 98 | |
| 99 | def get_data_format(data_format, keras_mode=True): |
no test coverage detected