Skip to content

Commit 6f769b4

Browse files
committed
Update GNN
1 parent f1e4ce2 commit 6f769b4

File tree

14 files changed

+107
-29
lines changed

14 files changed

+107
-29
lines changed

examples/gnn/ParallelReverseAutoDiff.GnnExample/GraphAttentionPaths/AttentionMessagePassing/AttentionMessagePassingNeuralNetwork.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,14 @@ public async Task<DeepMatrix> AutomaticBackwardPropagate(DeepMatrix gradient)
190190
await opVisitor.TraverseAsync();
191191
if (opVisitor.AggregateException != null)
192192
{
193-
throw opVisitor.AggregateException;
193+
if (opVisitor.AggregateException.InnerExceptions.Count > 1)
194+
{
195+
throw opVisitor.AggregateException;
196+
}
197+
else
198+
{
199+
Console.WriteLine(opVisitor.AggregateException.InnerExceptions[0].Message);
200+
}
194201
}
195202

196203
opVisitor.Reset();

examples/gnn/ParallelReverseAutoDiff.GnnExample/GraphAttentionPaths/EdgeAttention/Architecture/EdgeAttention.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,15 @@
121121
"inputs": [ "reduce", "RB" ],
122122
"gradientResultTo": [ null, "DRB" ]
123123
},
124+
{
125+
"id": "reduce_add_skip",
126+
"type": "BatchMatrixAddThreeOperation",
127+
"inputs": [ "reduce_add", "keys_edgeFeatures", "values_edgeFeatures" ]
128+
},
124129
{
125130
"id": "layernorm_reduce",
126131
"type": "BatchLayerNormalizationOperation",
127-
"inputs": [ "reduce_add" ]
132+
"inputs": [ "reduce_add_skip" ]
128133
},
129134
{
130135
"id": "output_act",

examples/gnn/ParallelReverseAutoDiff.GnnExample/GraphAttentionPaths/EdgeAttention/EdgeAttentionNeuralNetwork.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,14 @@ public async Task<DeepMatrix> AutomaticBackwardPropagate(DeepMatrix gradient)
237237
await opVisitor.TraverseAsync();
238238
if (opVisitor.AggregateException != null)
239239
{
240-
throw opVisitor.AggregateException;
240+
if (opVisitor.AggregateException.InnerExceptions.Count > 1)
241+
{
242+
throw opVisitor.AggregateException;
243+
}
244+
else
245+
{
246+
Console.WriteLine(opVisitor.AggregateException.InnerExceptions[0].Message);
247+
}
241248
}
242249

243250
opVisitor.Reset();

examples/gnn/ParallelReverseAutoDiff.GnnExample/GraphAttentionPaths/Embedding/EmbeddingNeuralNetwork.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,14 @@ public async Task<DeepMatrix> AutomaticBackwardPropagate(DeepMatrix gradient)
178178
await opVisitor.TraverseAsync();
179179
if (opVisitor.AggregateException != null)
180180
{
181-
throw opVisitor.AggregateException;
181+
if (opVisitor.AggregateException.InnerExceptions.Count > 1)
182+
{
183+
throw opVisitor.AggregateException;
184+
}
185+
else
186+
{
187+
Console.WriteLine(opVisitor.AggregateException.InnerExceptions[0].Message);
188+
}
182189
}
183190

184191
opVisitor.Reset();

examples/gnn/ParallelReverseAutoDiff.GnnExample/GraphAttentionPaths/GCN/Architecture/MessagePassing.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@
5252
{
5353
"id": "ah_w_act",
5454
"type": "BatchLeakyReLUOperation",
55-
"inputs": [ "ah_w_broadcasting" ],
55+
"inputs": [ "ah_w_broadcasting" ]
56+
},
57+
{
58+
"id": "ah_w_act_softmax",
59+
"type": "BatchSineSoftmaxOperation",
60+
"inputs": [ "ah_w_act" ],
5661
"setResultTo": "Output"
5762
}
5863
]

examples/gnn/ParallelReverseAutoDiff.GnnExample/GraphAttentionPaths/GCN/GcnNeuralNetwork.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,14 @@ public async Task<DeepMatrix[]> AutomaticBackwardPropagate(DeepMatrix gradient)
168168
await opVisitor.TraverseAsync();
169169
if (opVisitor.AggregateException != null)
170170
{
171-
throw opVisitor.AggregateException;
171+
if (opVisitor.AggregateException.InnerExceptions.Count > 1)
172+
{
173+
throw opVisitor.AggregateException;
174+
}
175+
else
176+
{
177+
Console.WriteLine(opVisitor.AggregateException.InnerExceptions[0].Message);
178+
}
172179
}
173180

174181
opVisitor.Reset();

examples/gnn/ParallelReverseAutoDiff.GnnExample/GraphAttentionPaths/GraphAttentionPathsNeuralNetwork.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void Reinitialize(List<GapGraph> graphs)
143143
/// <returns>The task.</returns>
144144
public async Task Initialize()
145145
{
146-
var initialAdamIteration = 317;
146+
var initialAdamIteration = 414;
147147
for (int i = 0; i < 7; ++i)
148148
{
149149
var model = new EmbeddingNeuralNetwork(this.numIndices, this.alphabetSize, this.embeddingSize, this.learningRate, this.clipValue);
@@ -213,9 +213,9 @@ public void SaveWeights()
213213
/// </summary>
214214
public void ApplyWeights()
215215
{
216-
var guid = "98420e29-64cc-4b3a-bbfa-ce6ccb89758b_317";
216+
var guid = "dfda8f41-44ca-42ce-8249-d86fff2429bb_414";
217217
var dir = $"E:\\store\\{guid}";
218-
for (int i = 0; i < this.modelLayers.Count; ++i)
218+
for (int i = 0; i < 7; ++i)
219219
{
220220
var modelLayer = this.modelLayers[i];
221221
var file = new FileInfo($"{dir}\\layer{i}");

examples/gnn/ParallelReverseAutoDiff.GnnExample/GraphAttentionPaths/LSTM/LstmNeuralNetwork.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,14 @@ public async Task<FourDimensionalMatrix> AutomaticBackwardPropagate(DeepMatrix g
200200
await opVisitor.TraverseAsync();
201201
if (opVisitor.AggregateException != null)
202202
{
203-
throw opVisitor.AggregateException;
203+
if (opVisitor.AggregateException.InnerExceptions.Count > 1)
204+
{
205+
throw opVisitor.AggregateException;
206+
}
207+
else
208+
{
209+
Console.WriteLine(opVisitor.AggregateException.InnerExceptions[0].Message);
210+
}
204211
}
205212

206213
opVisitor.Reset();

examples/gnn/ParallelReverseAutoDiff.GnnExample/GraphAttentionPaths/Readout/Architecture/Readout.json

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,15 @@
204204
"inputs": [ "reduce", "RB" ],
205205
"gradientResultTo": [ null, "DRB" ]
206206
},
207+
{
208+
"id": "reduce_add_skip",
209+
"type": "BatchMatrixAddThreeOperation",
210+
"inputs": [ "reduce_add", "keys_pathFeatures", "values_pathFeatures" ]
211+
},
207212
{
208213
"id": "layernorm_reduce",
209214
"type": "BatchLayerNormalizationOperation",
210-
"inputs": [ "reduce_add" ]
215+
"inputs": [ "reduce_add_skip" ]
211216
},
212217
{
213218
"id": "output_act",
@@ -226,7 +231,22 @@
226231
{
227232
"id": "output_avg",
228233
"type": "BatchMatrixAverageOperation",
229-
"inputs": [ "pre_output" ],
234+
"inputs": [ "pre_output" ]
235+
},
236+
{
237+
"id": "output_avg_trans",
238+
"type": "BatchMatrixTransposeOperation",
239+
"inputs": [ "output_avg" ]
240+
},
241+
{
242+
"id": "output_avg_softmax",
243+
"type": "BatchSineSoftmaxOperation",
244+
"inputs": [ "output_avg_trans" ]
245+
},
246+
{
247+
"id": "output_avg_softmax_trans",
248+
"type": "BatchMatrixTransposeOperation",
249+
"inputs": [ "output_avg_softmax" ],
230250
"setResultTo": "Output"
231251
}
232252
]

examples/gnn/ParallelReverseAutoDiff.GnnExample/GraphAttentionPaths/Readout/ReadoutNeuralNetwork.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,14 @@ public async Task<DeepMatrix> AutomaticBackwardPropagate(DeepMatrix gradient)
222222
await opVisitor.TraverseAsync();
223223
if (opVisitor.AggregateException != null)
224224
{
225-
throw opVisitor.AggregateException;
225+
if (opVisitor.AggregateException.InnerExceptions.Count > 1)
226+
{
227+
throw opVisitor.AggregateException;
228+
}
229+
else
230+
{
231+
Console.WriteLine(opVisitor.AggregateException.InnerExceptions[0].Message);
232+
}
226233
}
227234

228235
opVisitor.Reset();

0 commit comments

Comments
 (0)