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
# Currently, the weights of the layers are in the reverse order. In other words, the weights of the first layer are at the last index of the 'network_weights' list while the weights of the last layer are at the first index.
40
40
# Reversing the 'network_weights' list to order the layers' weights according to their location in the network architecture (i.e. the weights of the first layer appears at index 0 of the list).
# Currently, the weights of the layers are in the reverse order. In other words, the weights of the first layer are at the last index of the 'network_weights' list while the weights of the last layer are at the first index.
114
114
# Reversing the 'network_weights' list to order the layers' weights according to their location in the network architecture (i.e. the weights of the first layer appears at index 0 of the list).
115
115
network_weights.reverse()
116
-
returnnumpy.array(network_weights)
116
+
returnnetwork_weights
117
117
118
118
deflayers_activations(last_layer):
119
119
"""
@@ -192,17 +192,23 @@ def softmax(layer_outputs):
192
192
deftrain(num_epochs,
193
193
last_layer,
194
194
data_inputs,
195
-
data_outputs,
196
-
learning_rate):
195
+
data_outputs,
196
+
problem_type="classification",
197
+
learning_rate=0.01):
197
198
"""
198
199
Trains the neural network.
199
200
200
201
num_epochs: Number of epochs.
201
202
last_layer: Reference to the last (output) layer in the network architecture.
202
203
data_inputs: Data features.
203
204
data_outputs: Data outputs.
204
-
learning_rate: Learning rate.
205
+
problem_type: Can be either classification or regression to define the problem type.
206
+
learning_rate: Learning rate which defaults to 0.01.
raiseValueError("The value of the problem_type parameter can be either classification or regression but {problem_type_val} found.".format(problem_type_val=problem_type))
211
+
206
212
# To fetch the initial weights of the layer, the 'initial' argument is set to True.
raiseValueError("The value of the problem_type parameter can be either classification or regression but {problem_type_val} found.".format(problem_type_val=problem_type))
298
+
279
299
# To fetch the trained weights of the layer, the 'initial' argument is set to False.
280
300
weights=layers_weights(last_layer, initial=False)
281
301
activations=layers_activations(last_layer)
282
302
283
303
iflen(weights) !=len(activations):
284
304
raiseTypeError("The length of layers {num_layers} is not equal to the number of activations functions {num_activations} and they must be equal.".format(num_layers=len(weights), num_activations=len(activations)))
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))
0 commit comments