Completed
Push — master ( ed5c34...292ca9 )
by Dafne van
07:01
created

generate_base_hyper_parameter_set()   B

Complexity

Conditions 1

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 28
ccs 5
cts 5
cp 1
crap 1
rs 8.8571
1 1
from keras.models import Sequential
2 1
from keras.layers import Dense, Activation, Convolution1D, Flatten, MaxPooling1D, Lambda, Convolution2D, Flatten, Reshape, LSTM, Dropout, TimeDistributed, Permute, BatchNormalization
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (182/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
3 1
from keras.regularizers import l2
4 1
from keras.optimizers import Adam
5 1
import numpy as np
6
7
8 1
def generate_models(
9
    x_shape, number_of_classes, number_of_models=5, model_type=None,
10
    cnn_min_layers=1, cnn_max_layers=10,
11
    cnn_min_filters=10, cnn_max_filters=100,
12
    cnn_min_fc_nodes=10, cnn_max_fc_nodes=100,
13
    deepconvlstm_min_conv_layers=1, deepconvlstm_max_conv_layers=10,
14
    deepconvlstm_min_conv_filters=10, deepconvlstm_max_conv_filters=100,
15
    deepconvlstm_min_lstm_layers=1, deepconvlstm_max_lstm_layers=5,
16
    deepconvlstm_min_lstm_dims=10, deepconvlstm_max_lstm_dims=100,
17
    low_lr=1, high_lr=4, low_reg=1, high_reg=4
18
):
19
    """
20
    Generate one or multiple Keras models with random hyperparameters.
21
22
    Parameters
23
    ----------
24
    x_shape
25
        Shape of the input dataset: (num_samples, num_timesteps, num_channels)
26
    number_of_classes
27
        Number of classes for classification task
28
    number_of_models
29
        Number of models to generate
30
    model_type : str (optional)
31
        Type of model to build: 'CNN' or 'DeepConvLSTM'. Default option None generates both models.
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (99/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
32
    cnn_min_layers : int
33
        minimum of Conv layers in CNN model
34
    cnn_max_layers : int
35
        maximum of Conv layers in CNN model
36
    cnn_min_filters : int
37
        minimum number of filters per Conv layer in CNN model
38
    cnn_max_filters : int
39
        maximum number of filters per Conv layer in CNN model
40
    cnn_min_fc_nodes : int
41
        minimum number of hidden nodes per Dense layer in CNN model
42
    cnn_max_fc_nodes : int
43
        maximum number of hidden nodes per Dense layer in CNN model
44
    deepconvlstm_min_conv_layers : int
45
        minimum number of Conv layers in DeepConvLSTM model
46
    deepconvlstm_max_conv_layers : int
47
        maximum number of Conv layers in DeepConvLSTM model
48
    deepconvlstm_min_conv_filters : int
49
        minimum number of filters per Conv layer in DeepConvLSTM model
50
    deepconvlstm_max_conv_filters : int
51
        maximum number of filters per Conv layer in DeepConvLSTM model
52
    deepconvlstm_min_lstm_layers : int
53
        minimum number of Conv layers in DeepConvLSTM model
54
    deepconvlstm_max_lstm_layers : int
55
        maximum number of Conv layers in DeepConvLSTM model
56
    deepconvlstm_min_lstm_dims : int
57
        minimum number of hidden nodes per LSTM layer in DeepConvLSTM model
58
    deepconvlstm_max_lstm_dims : int
59
        maximum number of hidden nodes per LSTM layer in DeepConvLSTM model
60
    low_lr : float
61
        minimum of log range for learning rate: learning rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (119/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
62
    high_lr : float
63
        maximum  of log range for learning rate: learning rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (120/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
64
    low_reg : float
65
        minimum  of log range for regularization rate: regularization rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (132/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
66
    high_reg : float
67
        maximum  of log range for regularization rate: regularization rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (132/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
68
69
    Returns
70
    -------
71
    List of compiled models
72
    """
73 1
    models = []
74 1
    for _ in range(0, number_of_models):
75 1
        if model_type is None:  # random model choice:
76 1
            current_model_type = 'CNN' if np.random.random(
77
            ) < 0.5 else 'DeepConvLSTM'
78
        else:  # user-defined model choice:
79
            current_model_type = model_type
80 1
        generate_model = None
81 1
        if current_model_type == 'CNN':
82 1
            generate_model = generate_CNN_model  # object is a function
83 1
            hyperparameters = generate_CNN_hyperparameter_set(
84
                min_layers=cnn_min_layers, max_layers=cnn_max_layers,
85
                min_filters=cnn_min_filters, max_filters=cnn_max_filters,
86
                min_fc_nodes=cnn_min_fc_nodes, max_fc_nodes=cnn_max_fc_nodes,
87
                low_lr=low_lr, high_lr=high_lr, low_reg=low_reg, high_reg=high_reg)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (83/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
88 1
        if current_model_type == 'DeepConvLSTM':
89
            generate_model = generate_DeepConvLSTM_model  # object is a function
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (80/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
90
            hyperparameters = generate_DeepConvLSTM_hyperparameter_set(
91
                min_conv_layers=deepconvlstm_min_conv_layers, max_conv_layers=deepconvlstm_max_conv_layers,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (107/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
92
                min_conv_filters=deepconvlstm_min_conv_filters, max_conv_filters=deepconvlstm_max_conv_filters,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (111/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
93
                min_lstm_layers=deepconvlstm_min_lstm_layers, max_lstm_layers=deepconvlstm_max_lstm_layers,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (107/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
94
                min_lstm_dims=deepconvlstm_min_lstm_dims, max_lstm_dims=deepconvlstm_max_lstm_dims,
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (99/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
95
                low_lr=low_lr, high_lr=high_lr, low_reg=low_reg, high_reg=high_reg)
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (83/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
96 1
        models.append(
97
            (generate_model(x_shape, number_of_classes, **hyperparameters), hyperparameters, current_model_type))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (113/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
98 1
    return models
99
100
101 1
def generate_DeepConvLSTM_model(
0 ignored issues
show
Coding Style Naming introduced by
The name generate_DeepConvLSTM_model does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
102
    x_shape, class_number, filters, lstm_dims, learning_rate=0.01,
103
        regularization_rate=0.01):
104
    """
105
    Generate a model with convolution and LSTM layers.
106
    See Ordonez et al., 2016, http://dx.doi.org/10.3390/s16010115
107
108
    Parameters
109
    ----------
110
    x_shape : tuple
111
        Shape of the input dataset: (num_samples, num_timesteps, num_channels)
112
    class_number : int
113
        Number of classes for classification task
114
    filters : list of ints
115
        number of filters for each convolutional layer
116
    lstm_dims : list of ints
117
        number of hidden nodes for each LSTM layer
118
    learning_rate : float
119
    regularization_rate : float
120
121
    Returns
122
    -------
123
    The compiled Keras model
124
    """
125 1
    dim_length = x_shape[1]  # number of samples in a time series
126 1
    dim_channels = x_shape[2]  # number of channels
127 1
    output_dim = class_number  # number of classes
128 1
    weightinit = 'lecun_uniform'  # weight initialization
129 1
    model = Sequential()  # initialize model
130 1
    model.add(BatchNormalization(input_shape=(dim_length, dim_channels)))
131
    # reshape a 2 dimensional array per file/person/object into a
132
    # 3 dimensional array
133 1
    model.add(
134
        Reshape(target_shape=(1, dim_length, dim_channels)))
135 1
    for filt in filters:
136
        # filt: number of filters used in a layer
137
        # filters: vector of filt values
138 1
        model.add(
139
            Convolution2D(filt, nb_row=3, nb_col=1, border_mode='same',
140
                          W_regularizer=l2(regularization_rate), init=weightinit))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (82/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
141 1
        model.add(Activation('relu'))
142
    # reshape 3 dimensional array back into a 2 dimensional array,
143
    # but now with more dept as we have the the filters for each channel
144 1
    model.add(Reshape(target_shape=(dim_length, filters[-1] * dim_channels)))
145
146 1
    for lstm_dim in lstm_dims:
147 1
        model.add(LSTM(output_dim=lstm_dim, return_sequences=True,
148
                       activation='tanh'))
149
150 1
    model.add(Dropout(0.5))  # dropout before the dense layer
151
    # set up final dense layer such that every timestamp is given one
152
    # classification
153 1
    model.add(
154
        TimeDistributed(Dense(output_dim, W_regularizer=l2(regularization_rate))))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (82/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
155 1
    model.add(Activation("softmax"))
156
    # Final classification layer - per timestep
157 1
    model.add(Lambda(lambda x: x[:, -1, :], output_shape=[output_dim]))
158
159 1
    model.compile(loss='categorical_crossentropy',
160
                  optimizer=Adam(lr=learning_rate),
161
                  metrics=['accuracy'])
162
163 1
    return model
164
165
166 1
def generate_CNN_model(x_shape, class_number, filters, fc_hidden_nodes,
0 ignored issues
show
Coding Style Naming introduced by
The name generate_CNN_model does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
167
                       learning_rate=0.01, regularization_rate=0.01):
168
    """
169
    Generate a convolutional neural network (CNN) model.
170
171
    The compiled Keras model is returned.
172
173
    Parameters
174
    ----------
175
    x_shape : tuple
176
        Shape of the input dataset: (num_samples, num_timesteps, num_channels)
177
    class_number : int
178
        Number of classes for classification task
179
    filters : list of ints
180
        number of filters for each convolutional layer
181
    fc_hidden_nodes : int
182
        number of hidden nodes for the hidden dense layer
183
    learning_rate : float
184
    regularization_rate : float
185
186
    Returns
187
    -------
188
    The compiled Keras model
189
    """
190 1
    dim_length = x_shape[1]  # number of samples in a time series
191 1
    dim_channels = x_shape[2]  # number of channels
192 1
    outputdim = class_number  # number of classes
193 1
    weightinit = 'lecun_uniform'  # weight initialization
194 1
    model = Sequential()
195 1
    model.add(BatchNormalization(input_shape=(dim_length, dim_channels)))
196 1
    for filter_number in filters:
197 1
        model.add(Convolution1D(filter_number, 3, border_mode='same',
198
                                W_regularizer=l2(regularization_rate), init=weightinit))
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (88/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
199 1
        model.add(Activation('relu'))
200 1
    model.add(Flatten())
201 1
    model.add(Dense(output_dim=fc_hidden_nodes,
202
                    W_regularizer=l2(regularization_rate), init=weightinit))  # Fully connected layer
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (101/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
203 1
    model.add(Activation('relu'))  # Relu activation
204 1
    model.add(Dense(output_dim=outputdim, init=weightinit))
205 1
    model.add(Activation("softmax"))  # Final classification layer
206
207 1
    model.compile(loss='categorical_crossentropy',
208
                  optimizer=Adam(lr=learning_rate),
209
                  metrics=['accuracy'])
210
211 1
    return model
212
213
214 1
def generate_CNN_hyperparameter_set(min_layers=1, max_layers=10,
0 ignored issues
show
Coding Style Naming introduced by
The name generate_CNN_hyperparameter_set does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
215
                                    min_filters=10, max_filters=100,
216
                                    min_fc_nodes=10, max_fc_nodes=100,
217
                                    low_lr=1, high_lr=4, low_reg=1, high_reg=4):
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (80/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
218
    """ Generate a hyperparameter set that define a CNN model.
219
220
    Parameters
221
    ----------
222
    min_layers : int
223
        minimum of Conv layers
224
    max_layers : int
225
        maximum of Conv layers
226
    min_filters : int
227
        minimum number of filters per Conv layer
228
    max_filters : int
229
        maximum number of filters per Conv layer
230
    min_fc_nodes : int
231
        minimum number of hidden nodes per Dense layer
232
    max_fc_nodes : int
233
        maximum number of hidden nodes per Dense layer
234
    low_lr : float
235
        minimum of log range for learning rate: learning rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (119/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
236
    high_lr : float
237
        maximum  of log range for learning rate: learning rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (120/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
238
    low_reg : float
239
        minimum  of log range for regularization rate: regularization rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (132/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
240
    high_reg : float
241
        maximum  of log range for regularization rate: regularization rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (132/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
242
243
    Returns
244
    ----------
245
    hyperparameters : dict
246
        parameters for a CNN model
247
    """
248 1
    hyperparameters = generate_base_hyper_parameter_set(
249
        low_lr, high_lr, low_reg, high_reg)
250 1
    number_of_layers = np.random.randint(min_layers, max_layers + 1)
251 1
    hyperparameters['filters'] = np.random.randint(
252
        min_filters, max_filters + 1, number_of_layers)
253 1
    hyperparameters['fc_hidden_nodes'] = np.random.randint(
254
        min_fc_nodes, max_fc_nodes + 1)
255 1
    return hyperparameters
256
257
258 1
def generate_DeepConvLSTM_hyperparameter_set(
0 ignored issues
show
Coding Style Naming introduced by
The name generate_DeepConvLSTM_hyperparameter_set does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
259
    min_conv_layers=1, max_conv_layers=10,
260
    min_conv_filters=10, max_conv_filters=100,
261
    min_lstm_layers=1, max_lstm_layers=5,
262
    min_lstm_dims=10, max_lstm_dims=100,
263
        low_lr=1, high_lr=4, low_reg=1, high_reg=4):
264
    """ Generate a hyperparameter set that defines a DeepConvLSTM model.
265
266
    Parameters
267
    ----------
268
    min_conv_layers : int
269
        minimum number of Conv layers in DeepConvLSTM model
270
    max_conv_layers : int
271
        maximum number of Conv layers in DeepConvLSTM model
272
    min_conv_filters : int
273
        minimum number of filters per Conv layer in DeepConvLSTM model
274
    max_conv_filters : int
275
        maximum number of filters per Conv layer in DeepConvLSTM model
276
    min_lstm_layers : int
277
        minimum number of Conv layers in DeepConvLSTM model
278
    max_lstm_layers : int
279
        maximum number of Conv layers in DeepConvLSTM model
280
    min_lstm_dims : int
281
        minimum number of hidden nodes per LSTM layer in DeepConvLSTM model
282
    max_lstm_dims : int
283
        maximum number of hidden nodes per LSTM layer in DeepConvLSTM model
284
    low_lr : float
285
        minimum of log range for learning rate: learning rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (119/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
286
    high_lr : float
287
        maximum  of log range for learning rate: learning rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (120/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
288
    low_reg : float
289
        minimum  of log range for regularization rate: regularization rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (132/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
290
    high_reg : float
291
        maximum  of log range for regularization rate: regularization rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (132/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
292
293
    Returns
294
    ----------
295
    hyperparameters: dict
296
        hyperparameters for a DeepConvLSTM model
297
    """
298 1
    hyperparameters = generate_base_hyper_parameter_set(
299
        low_lr, high_lr, low_reg, high_reg)
300 1
    number_of_conv_layers = np.random.randint(
301
        min_conv_layers, max_conv_layers + 1)
302 1
    hyperparameters['filters'] = np.random.randint(
303
        min_conv_filters, max_conv_filters + 1, number_of_conv_layers)
304 1
    number_of_lstm_layers = np.random.randint(
305
        min_lstm_layers, max_lstm_layers + 1)
306 1
    hyperparameters['lstm_dims'] = np.random.randint(
307
        min_lstm_dims, max_lstm_dims + 1, number_of_lstm_layers)
308 1
    return hyperparameters
309
310
311 1
def generate_base_hyper_parameter_set(
0 ignored issues
show
Coding Style Naming introduced by
The name generate_base_hyper_parameter_set does not conform to the function naming conventions ([a-z_][a-z0-9_]{2,30}$).

This check looks for invalid names for a range of different identifiers.

You can set regular expressions to which the identifiers must conform if the defaults do not match your requirements.

If your project includes a Pylint configuration file, the settings contained in that file take precedence.

To find out more about Pylint, please refer to their site.

Loading history...
312
    low_lr=1,
313
    high_lr=4,
314
    low_reg=1,
315
        high_reg=4):
316
    """ Generate a base set of hyperparameters that are necessary for any model, but sufficient for none.
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (105/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
317
318
    Parameters
319
    ----------
320
    low_lr : float
321
        minimum of log range for learning rate: learning rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (119/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
322
    high_lr : float
323
        maximum  of log range for learning rate: learning rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (120/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
324
    low_reg : float
325
        minimum  of log range for regularization rate: regularization rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (132/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
326
    high_reg : float
327
        maximum  of log range for regularization rate: regularization rate is sampled between `10**(-low_reg)` and `10**(-high_reg)`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (132/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
328
329
    Returns
330
    -------
331
    hyperparameters : dict
332
        basis hyperpameters
333
    """
334 1
    hyperparameters = {}
335 1
    hyperparameters['learning_rate'] = get_learning_rate(low_lr, high_lr)
336 1
    hyperparameters['regularization_rate'] = get_regularization(
337
        low_reg, high_reg)
338 1
    return hyperparameters
339
340
341 1
def get_learning_rate(low=1, high=4):
342
    """ Return random learning rate 10^-n where n is sampled uniformly between low and high bounds.
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (99/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
343
344
    Parameters
345
    ----------
346
    low : float
347
        low bound
348
    high : float
349
        high bound
350
    """
351 1
    result = 10 ** (-np.random.uniform(low, high))
352 1
    return result
353
354
355 1
def get_regularization(low=1, high=4):
356
    """ Return random regularization rate 10^-n where n is sampled uniformly between low and high bounds.
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (105/79).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
357
358
    Parameters
359
    ----------
360
    low : float
361
        low bound
362
    high : float
363
        high bound
364
    """
365
    return 10 ** (-np.random.uniform(low, high))
366