Skip to content

Commit

Permalink
Improve code documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
liyu98 committed May 7, 2022
1 parent 468a07b commit 5a6c874
Show file tree
Hide file tree
Showing 12 changed files with 1,725 additions and 81 deletions.
38 changes: 35 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,36 @@
# matrix_standalone
matrix standalone version
#### Matrix Standalone (Federated Learning Project)
A simple version of the horizontal federated learning project to achieve image classification learning. This project is simulated locally, and does not involve network communication details and failure processing. It only involves model aggregation functions, which can quickly verify the relevant algorithms and capabilities of federated learning.

test edit
### Operating Manual
```shell
python3 fl_integration.py
```

#### Simulation Ensemble Run(fl_integration)

It will define a server object and multiple client objects respectively to simulate horizontal federation training scenarios.


#### Server(fl_server)

Perform model aggregation on the local model uploaded by the selected client.



#### Client(fl_client)

Receive commands and global models from the server, and use local data to train local models.


##### Functional screenshot

<img src="./doc/img/20220507-024348.jpg" width="930">


##### Results screenshot

<img src="./doc/img/acc.jpg" width="930">

<img src="./doc/img/loss.jpg" width="930">

---
2 changes: 2 additions & 0 deletions cifar10.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import matplotlib.pyplot as plt
import tensorflow as tf


# Take a look at some samples from the dataset: each class shows some
def showPic(X_train, y_train):
classes = ['plane', 'car', 'bird', 'cat', 'deer', 'dog', 'frog', 'horse', 'ship', 'truck']
Expand All @@ -20,6 +21,7 @@ def showPic(X_train, y_train):
plt.title(cls)
plt.show()


if __name__ == '__main__':
(x_train, y_train), (x_test, y_test) = tf.keras.datasets.cifar10.load_data()
showPic(x_train, y_train)
Binary file added doc/image/acc.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/image/loss.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
150 changes: 150 additions & 0 deletions doc/result/centralized training
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
/Users/jacky/opt/anaconda3/envs/learn/bin/python /Users/jacky/Documents/iit/CS584/homework/project1/main.py
Files already downloaded and verified
begin global model training


1 节点 1 K


Global Epoch 0
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 0.13999999999999999
Epoch 0, acc: 0.140000, loss: 9.019233

Global Epoch 1
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 0.27999999999999997
Epoch 1, acc: 0.280000, loss: 7.860937

Global Epoch 2
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 0.49
Epoch 2, acc: 0.490000, loss: 7.028633

Global Epoch 3
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 1.2
Epoch 3, acc: 1.200000, loss: 6.383927

Global Epoch 4
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 2.23
Epoch 4, acc: 2.230000, loss: 5.866239

Global Epoch 5
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 4.5600000000000005
Epoch 5, acc: 4.560000, loss: 5.445751

Global Epoch 6
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 8.35
Epoch 6, acc: 8.350000, loss: 5.043958

Global Epoch 7
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 14.330000000000002
Epoch 7, acc: 14.330000, loss: 4.656721

Global Epoch 8
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 22.42
Epoch 8, acc: 22.420000, loss: 4.259869

Global Epoch 9
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 31.47
Epoch 9, acc: 31.470000, loss: 3.858892

Global Epoch 10
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 41.760000000000005
Epoch 10, acc: 41.760000, loss: 3.459392

Global Epoch 11
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 49.57
Epoch 11, acc: 49.570000, loss: 3.077812

Global Epoch 12
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 55.84
Epoch 12, acc: 55.840000, loss: 2.712965

Global Epoch 13
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 60.39
Epoch 13, acc: 60.390000, loss: 2.394304

Global Epoch 14
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 63.53
Epoch 14, acc: 63.530000, loss: 2.099478

Global Epoch 15
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 65.91
Epoch 15, acc: 65.910000, loss: 1.842624

Global Epoch 16
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 68.02
Epoch 16, acc: 68.020000, loss: 1.625131

Global Epoch 17
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 69.74000000000001
Epoch 17, acc: 69.740000, loss: 1.444850

Global Epoch 18
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 71.16
Epoch 18, acc: 71.160000, loss: 1.292109

Global Epoch 19
Epoch 0 done.
Epoch 1 done.
Epoch 2 done.
server acc 72.28
Epoch 19, acc: 72.280000, loss: 1.169403


进程已结束,退出代码0
Loading

0 comments on commit 5a6c874

Please sign in to comment.