def batch_norm_dnn(layer, **kwargs):
 nonlinearity = getattr(layer, 'nonlinearity', None)
 if (nonlinearity is not None):
  layer.nonlinearity = nonlinearities.identity
 if (hasattr(layer, 'b') and (layer.b is not None)):
  del layer.params[layer.b]
  layer.b = None
 bn_name = (kwargs.pop('name', None) or (getattr(layer, 'name', None) and (layer.name + '_bn')))
 layer = BatchNormDNNLayer(layer, name=bn_name, **kwargs)
 if (nonlinearity is not None):
  from .special import NonlinearityLayer
  nonlin_name = (bn_name and (bn_name + '_nonlin'))
  layer = NonlinearityLayer(layer, nonlinearity, name=nonlin_name)
 return layer

def batch_norm_dnn ( layer , ** kwargs ) : nonlinearity = getattr ( layer , 'nonlinearity' , None ) if ( nonlinearity is not None ) : layer . nonlinearity = nonlinearities . identity if ( hasattr ( layer , 'b' ) and ( layer . b is not None ) ) : del layer . params [ layer . b ] layer . b = None bn_name = ( kwargs . pop ( 'name' , None ) or ( getattr ( layer , 'name' , None ) and ( layer . name + '_bn' ) ) ) layer = BatchNormDNNLayer ( layer , name = bn_name , ** kwargs ) if ( nonlinearity is not None ) : from . special import NonlinearityLayer nonlin_name = ( bn_name and ( bn_name + '_nonlin' ) ) layer = NonlinearityLayer ( layer , nonlinearity , name = nonlin_name ) return layer
apply cudnn batch normalization to an existing layer .