Skip to content
Advertisement

layer.get_weights() is not equal in the same model layers

Why not all the layer weights equal:

JavaScript

Here is the output:

JavaScript

The a_weights == b_weights are not all the “True“.

What’s the problem?

Advertisement

Answer

Notice that the only time a_weights == b_weights is True, is when you are referencing a layer, which does not have any weights. np.array_equal is returning False because you are actually comparing lists of arrays and not the arrays themselves. Each trainable layer of yours has a kernel weight tensor and bias tensor. So actually your code should look like this:

JavaScript
JavaScript

You could also use a_weights == b_weights directly.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement