Weighted Sum

USAGE

All functions can be imported using layers module

2D Layers

ws2d(input_data, out_filters, rf=4, strides=1, act_fn=<function lrelu>, kernel_initializer=None, bias_initializer=None, weight_decay=None, padding='VALID', data_format='NHWC', log=False, reuse=False, name='weighted_sum_2d_layer')[source]

Executes the Weighted Sum 2D layer on the input. It uses the 3D weighted sum to perform the computation extending the 2D input dimension in order to match the requirements of 3D layer (the new dimension doesn’t influence results, it can be considered like a placeholder)

Parameters:
  • input_data (List[int]) – A 4D tensor with dimensions [batch_size, height, width, in_channels]
  • out_filters (int) – Number of output filters
  • rf (Union[int, Tuple(int, int)]) – Receptive field (filter mask) size, can be an integer (same size will be used on all dimensions) or a tuple indicating (height, width)
  • strides (Union[int, Tuple(int, int)]) – Sliding step, can be an integer (same step will be used on all dimensions) or a tuple indicating (height, width)
  • act_fn – A valid activation function handler. Default is provided leaky_relu
  • kernel_initializer – Initializer used for kernel weights, default None (uses Xavier initializer)
  • bias_initializer – Initializer used for bias, default None (uses Xavier initializer)
  • weight_decay – L2 decay lambda value.
  • padding (str) – Type of padding, only VALID is supported.
  • data_format (str) – NHWC : Batch x Height x Width x Channels
  • log (bool) – Log networks structure (weights, bias and output)
  • reuse (bool) – Not used.
  • name (str) – Layer name, used in variable_scope
Returns:

Weighted Sum 2D tensor with output of size [batch_size, out_height, out_width, out_channels]

3D Layers

ws3d(input_data, out_filters, rf=(3, 4, 4), strides=(1, 1, 1), act_fn=<function lrelu>, kernel_initializer=None, bias_initializer=None, weight_decay=None, padding='VALID', data_format='NDHWC', log=False, reuse=False, name='weighted_sum_3d_layer')[source]

Executes the Weighted Sum 3D layer on the input

Parameters:
  • input_data (List[int]) – A 5D tensor with dimensions [batch_size, depth, height, width, in_channels]
  • out_filters (int) – Number of output filters
  • rf (Union[int, Tuple(int, int, int)]) – Receptive field (filter mask) size, can be an integer (same size will be used on all dimensions) or a tuple indicating (depth, height, width)
  • strides (Union[int, Tuple(int, int, int)]) – Sliding step, can be an integer (same step will be used on all dimensions) or a tuple indicating (depth, height, width)
  • act_fn – A valid activation function handler. Default is provided leaky_relu
  • kernel_initializer – Initializer used for kernel weights, default None (uses Xavier initializer)
  • bias_initializer – Initializer used for bias, default None (uses Xavier initializer)
  • weight_decay – L2 decay lambda value.
  • padding (str) – Type of padding, only VALID is supported.
  • data_format (str) – NDHWC : Batch x Depth x Height x Width x Channels
  • log (bool) – Log networks structure (weights, bias and output)
  • reuse (bool) – Not used.
  • name (str) – Layer name, used in variable_scope
Returns:

Weighted Sum 3D tensor with output of size [batch_size, out_depth, out_height, out_width, out_channels]