'Initializes kernels and biases for this convolutional net.
Args:
component: parent ComponentBuilderBase object.
Parameters used to construct the network:
widths: comma separated list of ints, number of steps input to the
convolutional kernel at every layer.
depths: comma separated list of ints, number of channels input to the
convolutional kernel at every layer.
output_embedding_dim: int, number of output channels for the convolutional
kernel of the last layer, which receives no ReLU activation and
therefore can be used in a softmax output. If zero, this final
layer is disabled entirely.
nonlinearity (\'relu\'): Name of function from module "tf.nn" to apply to
each hidden layer; e.g., "relu" or "elu".
dropout_keep_prob (-1.0): The probability that an input is not dropped.
If >= 1.0, disables dropout.  If < 0.0, uses the global |dropout_rate|
hyperparameter.
dropout_per_sequence (False): If true, sample the dropout mask once per
sequence, instead of once per step.  See Gal and Ghahramani
(https://arxiv.org/abs/1512.05287).
Hyperparameters used:
dropout_rate: The probability that an input is not dropped.  Only used
when the |dropout_keep_prob| parameter is negative.'

def __init__(self, component):

    super(ConvNetwork, self).__init__(component)
    self._attrs = get_attrs_with_defaults(component.spec.network_unit.parameters, defaults={'widths': '', 'depths': '', 'output_embedding_dim': 0, 'nonlinearity': 'relu', 'dropout_keep_prob': (-1.0), 'dropout_per_sequence': False})
    self._weights = []
    self._biases = []
    self._widths = map(int, self._attrs['widths'].split(','))
    self._depths = map(int, self._attrs['depths'].split(','))
    self._output_dim = self._attrs['output_embedding_dim']
    if self._output_dim:
        self._depths.append(self._output_dim)
    self.kernel_shapes = []
    for i in range((len(self._depths) - 1)):
        self.kernel_shapes.append([1, self._widths[i], self._depths[i], self._depths[(i + 1)]])
    for i in range((len(self._depths) - 1)):
        with tf.variable_scope(('conv%d' % i)):
            self._weights.append(tf.get_variable('weights', self.kernel_shapes[i], initializer=tf.random_normal_initializer(stddev=0.0001), dtype=tf.float32))
            bias_init = (0.0 if (i == (len(self._widths) - 1)) else 0.2)
            self._biases.append(tf.get_variable('biases', self.kernel_shapes[i][(-1)], initializer=tf.constant_initializer(bias_init), dtype=tf.float32))
    self._nonlinearity = getattr(tf.nn, self._attrs['nonlinearity'])
    self._dropout_rate = self._attrs['dropout_keep_prob']
    if (self._dropout_rate < 0.0):
        self._dropout_rate = component.master.hyperparams.dropout_rate
    self._params.extend((self._weights + self._biases))
    self._layers.append(Layer(component, name='conv_output', dim=self._depths[(-1)]))
    self._regularized_weights.extend((self._weights[:(-1)] if self._output_dim else self._weights))
