MCPcopy Create free account
hub / github.com/LBANN/lbann / __init__

Method __init__

python/lbann/modules/base.py:230–341  ·  view source on GitHub ↗

Initialize convolution module. Args: num_dims (int): Number of dimensions. out_channels (int): Number of output channels, i.e. number of filters. kernel_size (int) or (list): Size of convolution kernel. Either an int for square kernel or l

(self,
                 num_dims,
                 out_channels,
                 kernel_size,
                 stride=1,
                 padding=0,
                 dilation=1,
                 groups=1,
                 bias=True,
                 weights=[],
                 activation=None,
                 name=None,
                 transpose=False,
                 parallel_strategy={})

Source from the content-addressed store, hash-verified

228 global_count = 0 # Static counter, used for default names
229
230 def __init__(self,
231 num_dims,
232 out_channels,
233 kernel_size,
234 stride=1,
235 padding=0,
236 dilation=1,
237 groups=1,
238 bias=True,
239 weights=[],
240 activation=None,
241 name=None,
242 transpose=False,
243 parallel_strategy={}):
244 """Initialize convolution module.
245
246 Args:
247 num_dims (int): Number of dimensions.
248 out_channels (int): Number of output channels, i.e. number
249 of filters.
250 kernel_size (int) or (list): Size of convolution kernel. Either an int for square kernel or list of size num_dims.
251 has_vector (bool): If true then call with non-square kernel
252 padding, stride, dilation, and padding
253 stride (int) or (list): Convolution stride. Either an int for square kernel or list of size num_dims.
254 padding (int) or (list): Convolution padding. Either an int for square kernel or list of size num_dims.
255 dilation (int) or (list): Convolution dilation. Either an int for square kernel or list of size num_dims.
256 groups (int): Number of convolution groups.
257 bias (bool): Whether to apply channel-wise bias after
258 convolution.
259 weights (`Weights` or iterator of `Weights`): Weights in
260 convolution layer. There are at most two: the kernel
261 and the bias. If weights are not provided, the kernel
262 will be initialized with He normal initialization and
263 the bias with zeros.
264 name (str): Default name is in the form 'convmodule<index>'.
265 transpose (bool): If true call deconvolution (or convolution
266 transpose)
267 parallel_strategy dict): Data partitioning scheme.
268
269 """
270 super().__init__()
271 ConvolutionModule.global_count += 1
272 self.name = (name
273 if name
274 else 'convmodule{0}'.format(ConvolutionModule.global_count))
275
276 self.instance = 0
277 self.num_dims = num_dims
278 self.out_channels = out_channels
279
280 self.kernel_dims = list(make_iterable(kernel_size))
281
282 if (len(self.kernel_dims)) == 1:
283 self.kernel_dims = self.kernel_dims * self.num_dims
284 elif (len(self.kernel_dims)) != self.num_dims:
285 raise ValueError("Invalid kernel dimensions passed to {}".format(self.name))
286
287 self.stride = list(make_iterable(stride))

Callers 4

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 1

make_iterableFunction · 0.90

Tested by

no test coverage detected