def wider_next_dense(layer, start_dim, total_dim, n_add, weighted=True):
    '''wider next dense layer.
    '''
    if not weighted:
        return StubDense(layer.input_units + n_add, layer.units)
    teacher_w, teacher_b = layer.get_weights()
    student_w = teacher_w.copy()
    n_units_each_channel = int(teacher_w.shape[1] / total_dim)

    new_weight = np.zeros((teacher_w.shape[0], n_add * n_units_each_channel))
    student_w = np.concatenate(
        (
            student_w[:, : start_dim * n_units_each_channel],
            add_noise(new_weight, student_w),
            student_w[
                :, start_dim * n_units_each_channel : total_dim * n_units_each_channel
            ],
        ),
        axis=1,
    )

    new_layer = StubDense(layer.input_units + n_add, layer.units)
    new_layer.set_weights((student_w, teacher_b))
    return new_layer
def wider_next_dense ( layer , start_dim , total_dim , n_add , weighted = True ) : if not weighted : return StubDense ( layer . input_units + n_add , layer . units ) teacher_w , teacher_b = layer . get_weights ( ) student_w = teacher_w . copy ( ) n_units_each_channel = int ( teacher_w . shape [ 1 ] / total_dim ) new_weight = np . zeros ( ( teacher_w . shape [ 0 ] , n_add * n_units_each_channel ) ) student_w = np . concatenate ( ( student_w [ : , : start_dim * n_units_each_channel ] , add_noise ( new_weight , student_w ) , student_w [ : , start_dim * n_units_each_channel : total_dim * n_units_each_channel ] , ) , axis = 1 , ) new_layer = StubDense ( layer . input_units + n_add , layer . units ) new_layer . set_weights ( ( student_w , teacher_b ) ) return new_layer
wider next dense layer.