MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / shape4d

Function shape4d

tensorpack/utils/argtools.py:110–125  ·  view source on GitHub ↗

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')

Source from the content-addressed store, hash-verified

108
109
110def 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

Callers 3

DynamicConvFilterFunction · 0.90
Conv2DFunction · 0.85
Conv2DTransposeFunction · 0.85

Calls 2

shape2dFunction · 0.85
get_data_formatFunction · 0.85

Tested by

no test coverage detected