Giter Site home page Giter Site logo

T-SNE about fedmax HOT 20 CLOSED

weichennone avatar weichennone commented on July 22, 2024
T-SNE

from fedmax.

Comments (20)

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

Hello, I am very interested in the picture of "t-SNE embedding of the activation vectors" in your paper. Could you please provide us with the code for this part? thanks.(E-Mail:[email protected]).

from fedmax.

weichennone avatar weichennone commented on July 22, 2024

from fedmax.

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

Many thanks.

from fedmax.

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

I still have a question. The activation vectors in the T-SNE plot are the activation vectors of the global model?

from fedmax.

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

Now, I get it. The activation of each client (models/Update.py) is saved. Gather them at the server, and use FedAvg (models/Fed.py) to aggregate them. Finally, the activation vectors in the T-SNE plot are got?

from fedmax.

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

Now, I get it. The activation of each client (models/Update.py) is saved. Gather them at the server, and use FedAvg (models/Fed.py) to aggregate them. Finally, the activation vectors in the T-SNE plot are got?

from fedmax.

weichennone avatar weichennone commented on July 22, 2024

Now, I get it. The activation of each client (models/Update.py) is saved. Gather them at the server, and use FedAvg (models/Fed.py) to aggregate them. Finally, the activation vectors in the T-SNE plot are got?

That's right. You get the idea

from fedmax.

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

Now, I get it. The activation of each client (models/Update.py) is saved. Gather them at the server, and use FedAvg (models/Fed.py) to aggregate them. Finally, the activation vectors in the T-SNE plot are got?

That's right. You get the idea

Okay, thank you.

from fedmax.

weichennone avatar weichennone commented on July 22, 2024

Now, I get it. The activation of each client (models/Update.py) is saved. Gather them at the server, and use FedAvg (models/Fed.py) to aggregate them. Finally, the activation vectors in the T-SNE plot are got?

That's right. You get the idea

Okay, thank you.

Sure, no problem!

from fedmax.

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

Bro, I draw the T-SNE plot by your method, but it may be wrong. Could you see my code and figure, and point out my fault? Thanks, bro.
T-SNE.docx

from fedmax.

weichennone avatar weichennone commented on July 22, 2024

Bro, I draw the T-SNE plot by your method, but it may be wrong. Could you see my code and figure, and point out my fault? Thanks, bro. T-SNE.docx

It seems you only plot the activations of the global model. Not sure if it is what you meant. But if you are trying to recreate the plot from my paper, the activations of local clients, you need to store their activations instead of averaging them in "FedAvg_TSNE". You may try to plot the activation directly from "aggregration_users_activation".

from fedmax.

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

Do you mean that the activations of local clients are drawn one by one in only one T-SNE plot? By the way, what are the experimental conditions of the "Mitigating Activation Divergence" part of your paper, that is, the number of client training and batch size (local_ep and local_bs in the code)?

from fedmax.

weichennone avatar weichennone commented on July 22, 2024

Do you mean that the activations of local clients are drawn one by one in only one T-SNE plot? By the way, what are the experimental conditions of the "Mitigating Activation Divergence" part of your paper, that is, the number of client training and batch size (local_ep and local_bs in the code)?

Yes. For example, I use "A" representing the 1st client, "B" representing the 2nd client, etc.
The number of clients is 10. I don't remember the exact batch size, maybe ~50. But the larger the batch size, the clearer you can see the pattern. The trade-off is, large batch size takes longer time to calculate T-SNE vectors.

from fedmax.

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

您的意思是本地客户的激活是在一个T-SNE图中逐个绘制的吗?顺便问一下,您的论文中的“缓解激活差异”部分的实验条件是什么,即客户培训的数量和批大小(代码中的local_ep和local_bs)?

是。例如,我使用“A”表示第一个客户端,“B”表示第二个客户端,等等。客户的数量是10,我不记得确切的批次大小,可能是50。但批处理的大小越大,您就越能清楚地看到模式。权衡的是,大批量计算T-SNE向量需要更长的时间.

Thanks. What is the number of iterations of client training? Do you see my code is correct? Various colors represent the activation vectors for different classes, while the letters denote the device IDs. How to ensure that various colors represent different types of activation vectors? plt.text(X[i, 0], X[i, 1], user_list[i // batch_size], color=color_list[i // batch_size])
T-SNE_V1.docx

from fedmax.

weichennone avatar weichennone commented on July 22, 2024

您的意思是本地客户的激活是在一个T-SNE图中逐个绘制的吗?顺便问一下,您的论文中的“缓解激活差异”部分的实验条件是什么,即客户培训的数量和批大小(代码中的local_ep和local_bs)?

是。例如,我使用“A”表示第一个客户端,“B”表示第二个客户端,等等。客户的数量是10,我不记得确切的批次大小,可能是50。但批处理的大小越大,您就越能清楚地看到模式。权衡的是,大批量计算T-SNE向量需要更长的时间.

Thanks. What is the number of iterations of client training? Do you see my code is correct? Various colors represent the activation vectors for different classes, while the letters denote the device IDs. How to ensure that various colors represent different types of activation vectors? plt.text(X[i, 0], X[i, 1], user_list[i // batch_size], color=color_list[i // batch_size]) T-SNE_V1.docx

Your code looks reasonable.
I did 600-3000 epochs for the training iteration. But to recreate the TSNE in the paper, I mainly focus on the first 10 iterations. Because each time after FedAvg, models of clients will be the same, and there'll be less difference among the activations of each client.
To recreate "Various colors represent the activation vectors for different classes, while the letters denote the device IDs.", you need to store more information from the clients, like the label of each activation (because you have the label of each input, it's equal to getting the label of each activation). Then after sending this information to "plot_embedding", and change plt.text(X[i, 0], X[i, 1], user_list[i // batch_size], color=color_list[i // batch_size]) to plt.text(X[i, 0], X[i, 1], user_list[i // batch_size], color=color_list[label_index]), where label_index is how you retrieve the index of corresponding label for each activation.
It may take some effort to modify the code, but I think it should be straightforward. Good luck!

from fedmax.

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

Thanks for your answer. Now, I have modified the code to get the label_index that each client owns. However, I still have a question. Because each client has two labels, how to determine which part of the activation vector belongs to which label (or class).

from fedmax.

weichennone avatar weichennone commented on July 22, 2024

Thanks for your answer. Now, I have modified the code to get the label_index that each client owns. However, I still have a question. Because each client has two labels, how to determine which part of the activation vector belongs to which label (or class).

When the model does the classification, it needs to calculate the loss between prediction and "true labels". This is how to determine the corresponding labels to activations.

from fedmax.

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

Thanks for your answer. Now, I have modified the code to get the label_index that each client owns. However, I still have a question. Because each client has two labels, how to determine which part of the activation vector belongs to which label (or class).

When the model does the classification, it needs to calculate the loss between prediction and "true labels". This is how to determine the corresponding labels to activations.

Your mean is that using the trainable model to predict the test data (fixed or known data) after one client train the model using local data, thus determining a 512D activation vector belongs to which class. Or other methods?

from fedmax.

xiuhaoLiang avatar xiuhaoLiang commented on July 22, 2024

Hi, bro. I wrote the code to draw the t-SNE plot according to your idea, but there is no clustering phenomenon. I think there are still some problems with my code, so the t-SNE plot of your paper is not reproduced.
Figure 2021-12-13 104232

from fedmax.

weichennone avatar weichennone commented on July 22, 2024

Hi, bro. I wrote the code to draw the t-SNE plot according to your idea, but there is no clustering phenomenon. I think there are still some problems with my code, so the t-SNE plot of your paper is not reproduced. Figure 2021-12-13 104232

Hi, I just sent you the debugging code to your email. It contains all the code you need to recreate TSNE plot. Hope that can help you.
And you need more epochs (check epoch number in paper) to find clusters forming in the plot, so make sure you have the same epoch number.

from fedmax.

Related Issues (1)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.