merge - merge layer classes

The file yann.layers.merge.py contains the definition for the merge layers.

class yann.layers.merge.dropout_merge_layer(x, input_shape, id=-1, error='rmse', rng=None, dropout_rate=0.5, verbose=2)[source]

This is a dropotu merge layer. This takes two layer inputs and produces an error between them if the type argument supplied was 'error'. It does other things too accordingly.

Parameters:
  • x – a list of inputs (lenght must be two basically)
  • input_shape – List of the shapes of all inputs.
  • type'error' creates an error layer. other options are 'sum' and 'concatenate'
  • error – If the type was 'error', then this variable is used. options include, 'rmse', 'l2', 'l1',``’cross_entropy’``.
class yann.layers.merge.merge_layer(x, input_shape, id=-1, type='error', error='rmse', input_type='layer', verbose=2)[source]

This is a merge layer. This takes two layer inputs and produces an error between them if the type argument supplied was 'error'. It does other things too accordingly.

Parameters:
  • x – a list of inputs (lenght must be two basically)
  • input_shape – List of the shapes of all inputs.
  • type'error' creates an error layer. other options are 'sum', 'batch' and 'concatenate'
  • error – If the type was 'error', then this variable is used. options include, 'rmse', 'l2', 'l1',``’cross_entropy’``.
  • input_type – If this argument was 'tensor', we simply merge the ouptus, if this was not provided or was 'layer', this merges the outputs of the two layers.

Notes

'concatenate' concatenates the outputs on the channels where as 'batch' concatenates across the batches. It will increase the batchsize.

loss(type=None)[source]

This method will return the cost function of the merge layer. This can be used by the optimizer module for instance to acquire a symbolic loss function that tries to minimize the distance between the two layers.

Parameters:
  • y – symbolic theano.ivector variable of labels to calculate loss from.
  • type – options None - Simple error ‘log’ - log loss
Returns:

loss value.

Return type:

theano symbolic variable

output_shape = None[source]

if len(input_shape) == 2 – self.num_neurons = self.output_shape[-1] elif len(input_shape) == 4:

self.num_neurons = self.output_shape[1]