Last active
November 20, 2020 12:52
-
-
Save ahmedfgad/bad30781383c095380d5de42eaa5892d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def model_averaging(self, model, other_model): | |
model_weights = pygad.nn.layers_weights(last_layer=model, initial=False) | |
other_model_weights = pygad.nn.layers_weights(last_layer=other_model, initial=False) | |
new_weights = numpy.array(model_weights + other_model_weights)/2 | |
pygad.nn.update_layers_trained_weights(last_layer=model, final_weights=new_weights) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This commit solves this bug:
Error Decoding the Client's Data: unsupported operand type(s) for /: 'list' and 'int'.
It occurs due to this line in the model_averaging() method in the SocketThread class:
new_weights = (model_weights + other_model_weights)/2
The reason is that (model_weights + other_model_weights) is a list which is then divided by 2. This is an illegal list operation.
The solution is to convert (model_weights + other_model_weights) into a NumPy array then perform the division by 2:
new_weights = numpy.array(model_weights + other_model_weights)/2