Ensuer a 4D shape, to use with 4D symbolic functions. Args: a: a int or tuple/list of length 2 Returns: list: of length 4. if ``a`` is a int, return ``[1, a, a, 1]`` or ``[1, 1, a, a]`` depending on data_format.
(a, data_format='NHWC')
| 108 | |
| 109 | |
| 110 | def shape4d(a, data_format='NHWC'): |
| 111 | """ |
| 112 | Ensuer a 4D shape, to use with 4D symbolic functions. |
| 113 | |
| 114 | Args: |
| 115 | a: a int or tuple/list of length 2 |
| 116 | |
| 117 | Returns: |
| 118 | list: of length 4. if ``a`` is a int, return ``[1, a, a, 1]`` |
| 119 | or ``[1, 1, a, a]`` depending on data_format. |
| 120 | """ |
| 121 | s2d = shape2d(a) |
| 122 | if get_data_format(data_format, False) == 'NHWC': |
| 123 | return [1] + s2d + [1] |
| 124 | else: |
| 125 | return [1, 1] + s2d |
| 126 | |
| 127 | |
| 128 | @memoized |
no test coverage detected