|
Algorithm 1: pseudo code of AGGD |
| 1 |
Tensor , Tensor
|
| 2 |
Parameters: : Weight Parameters of Neural Network Nodes in the Previous Training Epoch; : Loss Values of the Neural Network for the Previous n Training Epochs. |
| 3 |
Operation: The algorithm is based on the Pytorch framework, please refer to Pytorch [47] for related torch operations. |
| 4 |
Output: W: Weight Parameters of Neural Network Nodes in this Training Epoch. |
| 5 |
def AGGD(self, ,): |
| 6 |
# Initialization |
| 7 |
W =
|
| 8 |
optimizer = torch.optim.Adam(model.parameters(), lr = 0.0004)
|
| 9 |
yPred = model(x) #Predict output using previous generation weights |
| 10 |
l = torch.nn.MSE(yPred, yReal)
|
| 11 |
|
|
|
| 12 |
L = .append(l)
|
| 13 |
|
| 14 |
# Update network weights |
| 15 |
|
| 16 |
if flag: |
| 17 |
|
| 18 |
count = 0
|
| 19 |
L = []
|
| 20 |
else: |
| 21 |
optimizer.zero_grad()
|
| 22 |
loss.backward()
|
| 23 |
count += 1
|
| 24 |
valid()
|