0

I have a next word prediction model based on federated learning with tensorflow model. My server need to calculate the distance between the model weigtht I receive in each round. Do you have any idea how to do it?

1 Answer 1

0

Get the model weights using model.get_weights() for each model,

Then make them as a tensor. For example

model1_weights= model1.get_weights()
model2_weights= model2.get_weights()

weights= tf.constant([[model1_weights],[model2_weights]])

Then you can find the euclidean distance using

tf.math.reduce_euclidean_norm(x)

For more details you can refer to this gist. Thank You.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.