@@ -80,7 +80,7 @@ public void AdjustLearningRate(double learningRate)
8080 /// <returns>The task.</returns>
8181 public async Task Initialize ( )
8282 {
83- var initialAdamIteration = 509 ;
83+ var initialAdamIteration = 138 ;
8484 var model = new GlyphNetwork . GlyphNetwork ( this . numLayers , this . numNodes , this . numFeatures , this . learningRate , this . clipValue , "glyphnet" ) ;
8585 model . Parameters . AdamIteration = initialAdamIteration ;
8686 this . GlyphNetwork = model ;
@@ -121,7 +121,7 @@ public void SaveWeights()
121121 /// </summary>
122122 public void ApplyWeights ( )
123123 {
124- var guid = "glyph_be1b3edd-d423-4714-ae20-3552bdc5cc9f_509 " ;
124+ var guid = "glyph_c83acea3-57af-4909-adab-0c75768549de_138 " ;
125125 var dir = $ "E:\\ vnnstore\\ { guid } ";
126126 for ( int i = 0 ; i < this . modelLayers . Count ; ++ i )
127127 {
@@ -160,16 +160,35 @@ public void ApplyGradients()
160160 var targetedSum0 = gatNet . TargetedSum0 ;
161161 var targetedSum1 = gatNet . TargetedSum1 ;
162162
163- SquaredArclengthEuclideanLossOperation arclengthLoss0 = SquaredArclengthEuclideanLossOperation . Instantiate ( gatNet ) ;
164- var loss0 = arclengthLoss0 . Forward ( targetedSum0 , ( 3 * Math . PI ) / 4d ) ;
163+ int maxMag0 = 0 ;
164+ int maxMag1 = 0 ;
165+ for ( int i = 0 ; i < 15 ; i ++ )
166+ {
167+ for ( int j = 0 ; j < 15 ; j ++ )
168+ {
169+ if ( rotationTargets [ i , j ] == 1 )
170+ {
171+ maxMag1 ++ ;
172+ }
173+ else
174+ {
175+ maxMag0 ++ ;
176+ }
177+ }
178+ }
179+
180+ Console . WriteLine ( $ "Max Mag 0: { maxMag0 } , Max Mag 1: { maxMag1 } ") ;
181+
182+ SquaredArclengthEuclideanMagnitudeLossOperation arclengthLoss0 = SquaredArclengthEuclideanMagnitudeLossOperation . Instantiate ( gatNet ) ;
183+ var loss0 = arclengthLoss0 . Forward ( targetedSum0 , ( 3 * Math . PI ) / 4d , maxMag0 ) ;
165184 var gradient0 = arclengthLoss0 . Backward ( ) ;
166185
167- SquaredArclengthEuclideanLossOperation arclengthLoss1 = SquaredArclengthEuclideanLossOperation . Instantiate ( gatNet ) ;
168- var loss1 = arclengthLoss1 . Forward ( targetedSum1 , ( 1 * Math . PI ) / 4d ) ;
186+ SquaredArclengthEuclideanMagnitudeLossOperation arclengthLoss1 = SquaredArclengthEuclideanMagnitudeLossOperation . Instantiate ( gatNet ) ;
187+ var loss1 = arclengthLoss1 . Forward ( targetedSum1 , ( 1 * Math . PI ) / 4d , maxMag1 ) ;
169188 var gradient1 = arclengthLoss1 . Backward ( ) ;
170189
171- SquaredArclengthEuclideanLossOperation arclengthLoss = SquaredArclengthEuclideanLossOperation . Instantiate ( gatNet ) ;
172- var loss = arclengthLoss . Forward ( output , targetAngle ) ;
190+ SquaredArclengthEuclideanMagnitudeLossOperation arclengthLoss = SquaredArclengthEuclideanMagnitudeLossOperation . Instantiate ( gatNet ) ;
191+ var loss = arclengthLoss . Forward ( output , targetAngle , 225 ) ;
173192 var gradient = arclengthLoss . Backward ( ) ;
174193
175194 return ( gradient , gradient0 , gradient1 , output , targetedSum0 , targetedSum1 , glyph , loss , loss0 , loss1 ) ;
0 commit comments