def wider_bn(layer, start_dim, total_dim, n_add, weighted=True):
    '''wider batch norm layer.
    '''
    n_dim = get_n_dim(layer)
    if not weighted:
        return get_batch_norm_class(n_dim)(layer.num_features + n_add)

    weights = layer.get_weights()

    new_weights = [
        add_noise(np.ones(n_add, dtype=np.float32), np.array([0, 1])),
        add_noise(np.zeros(n_add, dtype=np.float32), np.array([0, 1])),
        add_noise(np.zeros(n_add, dtype=np.float32), np.array([0, 1])),
        add_noise(np.ones(n_add, dtype=np.float32), np.array([0, 1])),
    ]

    student_w = tuple()
    for weight, new_weight in zip(weights, new_weights):
        temp_w = weight.copy()
        temp_w = np.concatenate(
            (temp_w[:start_dim], new_weight, temp_w[start_dim:total_dim])
        )
        student_w += (temp_w,)
    new_layer = get_batch_norm_class(n_dim)(layer.num_features + n_add)
    new_layer.set_weights(student_w)
    return new_layer
def wider_bn ( layer , start_dim , total_dim , n_add , weighted = True ) : n_dim = get_n_dim ( layer ) if not weighted : return get_batch_norm_class ( n_dim ) ( layer . num_features + n_add ) weights = layer . get_weights ( ) new_weights = [ add_noise ( np . ones ( n_add , dtype = np . float32 ) , np . array ( [ 0 , 1 ] ) ) , add_noise ( np . zeros ( n_add , dtype = np . float32 ) , np . array ( [ 0 , 1 ] ) ) , add_noise ( np . zeros ( n_add , dtype = np . float32 ) , np . array ( [ 0 , 1 ] ) ) , add_noise ( np . ones ( n_add , dtype = np . float32 ) , np . array ( [ 0 , 1 ] ) ) , ] student_w = tuple ( ) for weight , new_weight in zip ( weights , new_weights ) : temp_w = weight . copy ( ) temp_w = np . concatenate ( ( temp_w [ : start_dim ] , new_weight , temp_w [ start_dim : total_dim ] ) ) student_w += ( temp_w , ) new_layer = get_batch_norm_class ( n_dim ) ( layer . num_features + n_add ) new_layer . set_weights ( student_w ) return new_layer
wider batch norm layer.