You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# If the input sample has less than 2 dimensions, then an exception is raised.
216
216
iflen(input_shape) <2:
217
-
raiseValueError("The Input2D class creates an input layer for data inputs with at least 2 dimensions but ({num_dim}) dimensions found.".format(num_dim=len(input_shape)))
217
+
raiseValueError(f"The Input2D class creates an input layer for data inputs with at least 2 dimensions but ({len(input_shape)}) dimensions found.")
218
218
# If the input sample has exactly 2 dimensions, the third dimension is set to 1.
raiseValueError("The softmax activation function cannot be used in a conv layer.")
263
263
else:
264
-
raiseValueError("The specified activation function '{activation_function}' is not among the supported activation functions {supported_activation_functions}. Please use one of the supported functions.".format(activation_function=activation_function, supported_activation_functions=supported_activation_functions))
264
+
raiseValueError(f"The specified activation function '{activation_function}' is not among the supported activation functions {supported_activation_functions}. Please use one of the supported functions.")
265
265
266
266
# The activation function used in the current layer.
raiseValueError("The specified activation function '{activation_function}' is not among the supported activation functions {supported_activation_functions}. Please use one of the supported functions.".format(activation_function=activation_function, supported_activation_functions=supported_activation_functions))
645
+
raiseValueError(f"The specified activation function '{activation_function}' is not among the supported activation functions {supported_activation_functions}. Please use one of the supported functions.")
raiseValueError("The training data input has {num_dims} but it must have 4 dimensions. The first dimension is the number of training samples, the second & third dimensions represent the width and height of the sample, and the fourth dimension represents the number of channels in the sample.".format(num_dims=train_inputs.ndim))
742
742
743
743
if (train_inputs.shape[0] !=len(train_outputs)):
744
-
raiseValueError("Mismatch between the number of input samples and number of labels: {num_samples_inputs} != {num_samples_outputs}.".format(num_samples_inputs=train_inputs.shape[0], num_samples_outputs=len(train_outputs)))
744
+
raiseValueError(f"Mismatch between the number of input samples and number of labels: {train_inputs.shape[0]} != {len(train_outputs)}.")
raiseValueError("The data input has {num_dims} but it must have 4 dimensions. The first dimension is the number of training samples, the second & third dimensions represent the width and height of the sample, and the fourth dimension represents the number of channels in the sample.".format(num_dims=data_inputs.ndim))
831
+
raiseValueError("The data input has {data_inputs.ndim} but it must have 4 dimensions. The first dimension is the number of training samples, the second & third dimensions represent the width and height of the sample, and the fourth dimension represents the number of channels in the sample.")
# Validating the number of solutions within the population.
27
27
ifnot (num_solutionsisNone):
28
28
ifnum_solutions<2:
29
-
raiseValueError("num_solutions: The number of solutions within the population must be at least 2. The current value is {num_solutions}.".format(num_solutions=num_solutions))
30
-
29
+
raiseValueError(f"num_solutions: The number of solutions within the population must be at least 2. The current value is {num_solutions}.")
30
+
31
31
# Validating the number of neurons in the input layer.
32
32
ifnum_neurons_inputisintandnum_neurons_input<=0:
33
33
raiseValueError("num_neurons_input: The number of neurons in the input layer must be > 0.")
34
34
35
35
# Validating the number of neurons in the output layer.
raiseValueError("num_neurons_output: The number of neurons in the output layer must be > 0.")
38
-
38
+
39
39
# Validating the type of the 'num_neurons_hidden_layers' parameter which is expected to be list or tuple.
40
40
ifnot (type(num_neurons_hidden_layers) in [list, tuple]):
41
-
raiseTypeError("num_neurons_hidden_layers: A list or a tuple is expected but {hidden_layers_neurons_type} found.".format(hidden_layers_neurons_type=type(num_neurons_hidden_layers)))
42
-
41
+
raiseTypeError(f"num_neurons_hidden_layers: A list or a tuple is expected but {type(num_neurons_hidden_layers)} found.")
42
+
43
43
# Frequently used error messages.
44
-
unexpected_output_activation_value="Output activation function: The activation function of the output layer is passed as a string not {activation_type}."
44
+
unexpected_output_activation_value=f"Output activation function: The activation function of the output layer is passed as a string not {type(output_activation)}."
45
45
unexpected_activation_value="Activation function: The supported values for the activation function are {supported_activations} but an unexpected value is found:\n{activations}"
46
46
unexpected_activation_type="Activation Function: A list, tuple, or a string is expected but {activations_type} found."
47
47
length_mismatch="Hidden activation functions: When passing the activation function(s) as a list or a tuple, its length must match the length of the 'num_neurons_hidden_layers' parameter but a mismatch is found:\n{mismatched_lengths}"
else: # In case there are no hidden layers (num_hidden_layers == 0)
84
-
print("WARNING: There are no hidden layers however a value is assigned to the parameter 'hidden_activations'. It will be reset to [].".format(hidden_activations=hidden_activations))
84
+
print("WARNING: There are no hidden layers however a value is assigned to the parameter 'hidden_activations'. It will be reset to [].")
85
85
hidden_activations= []
86
-
86
+
87
87
# If the value passed to the 'hidden_activations' parameter is actually a list, then its elements are checked to make sure the listed name(s) of the activation function(s) are supported.
ifnotself.suppress_warnings: warnings.warn("Failed to find a unique value for gene with index {gene_idx} whose value is {gene_value}. Consider adding more values in the gene space or use a wider range for initial population or random mutation.".format(gene_idx=duplicate_index, gene_value=solution[duplicate_index]))
95
+
ifnotself.suppress_warnings: warnings.warn(f"Failed to find a unique value for gene with index {duplicate_index} whose value is {solution[duplicate_index]}. Consider adding more values in the gene space or use a wider range for initial population or random mutation.")
ifnotself.suppress_warnings: warnings.warn("Failed to find a unique value for gene with index {gene_idx} whose value is {gene_value}. Consider adding more values in the gene space or use a wider range for initial population or random mutation.".format(gene_idx=duplicate_index, gene_value=new_solution[duplicate_index]))
277
+
ifnotself.suppress_warnings: warnings.warn(f"Failed to find a unique value for gene with index {duplicate_index} whose value is {new_solution[duplicate_index]}. Consider adding more values in the gene space or use a wider range for initial population or random mutation.")
# If the gene space has only 1 value, then select it. The old and new values of the gene are identical.
452
452
iflen(curr_gene_space) ==1:
453
453
value_from_space=curr_gene_space[0]
454
-
ifnotself.suppress_warnings: warnings.warn("You set 'allow_duplicate_genes=False' but the space of the gene with index {gene_idx} has only a single value. Thus, duplicates are possible.".format(gene_idx=gene_idx))
454
+
ifnotself.suppress_warnings: warnings.warn(f"You set 'allow_duplicate_genes=False' but the space of the gene with index {gene_idx} has only a single value. Thus, duplicates are possible.")
455
455
# If the gene space has more than 1 value, then select a new one that is different from the current value.
0 commit comments