@@ -149,7 +149,7 @@ class OptimizerTests: XCTestCase {
149
149
) where Opt. Model == NumericalValues {
150
150
var optimizer = optimizer
151
151
var values = startingValues
152
- let gradient = NumericalValues . TangentVector ( value: [ - 0. 5, 0.1 , 3 ] )
152
+ let gradient = NumericalValues . TangentVector ( value: [ - 5 , 0.1 , 0.2 ] )
153
153
for _ in 0 ..< stepCount {
154
154
optimizer. update ( & values, along: gradient)
155
155
}
@@ -159,21 +159,17 @@ class OptimizerTests: XCTestCase {
159
159
func testSGDNumerical( ) {
160
160
let values = NumericalValues ( )
161
161
let optimizer = SGD ( for: values, learningRate: 1e-3 )
162
- // FIXME(TF-759): Investigate large differences with Python reference implementation results:
163
- // `[ 0.49999967, -0.00999999, -0.01999998]`.
164
162
testNumericalCorrectness (
165
163
optimizer: optimizer, startingValues: values,
166
- expectedValues: [ 0.49999535 , - 0.10000112 , - 3.000017 ] )
164
+ expectedValues: [ 5.0000668 , - 0.10000112 , - 0.20000224 ] )
167
165
}
168
166
169
167
func testRMSPropNumerical( ) {
170
168
let values = NumericalValues ( )
171
169
let optimizer = RMSProp ( for: values, learningRate: 1e-3 , epsilon: 1e-7 )
172
- // FIXME(TF-759): Investigate small differences with Python reference implementation results:
173
- // `[ 1.0091327, -1.0091326, -1.0091326]`.
174
170
testNumericalCorrectness (
175
171
optimizer: optimizer, startingValues: values,
176
- expectedValues: [ 1.0091327 , - 1.0091326 , - 1.0091327 ] )
172
+ expectedValues: [ 1.0091327 , - 1.0091326 , - 1.0091326 ] )
177
173
}
178
174
179
175
func testAdamNumerical( ) {
@@ -183,17 +179,17 @@ class OptimizerTests: XCTestCase {
183
179
// `[ 0.9999907, -0.9999898, -0.9999904]`.
184
180
testNumericalCorrectness (
185
181
optimizer: optimizer, startingValues: values,
186
- expectedValues: [ 0.9999906 , - 0.9999898 , - 0.99999064 ] )
182
+ expectedValues: [ 0.99999064 , - 0.9999898 , - 0.9999905 ] )
187
183
}
188
184
189
185
func testAdaDeltaNumerical( ) {
190
186
let values = NumericalValues ( )
191
187
let optimizer = AdaDelta ( for: values, learningRate: 1e-3 , epsilon: 1e-7 )
192
188
// FIXME(TF-759): Investigate small differences with Python reference implementation results:
193
- // `[ 0.00215183 , -0.00215151 , -0.00215175 ]`.
189
+ // `[ 0.0021518278 , -0.0021515056 , -0.0021517489 ]`.
194
190
testNumericalCorrectness (
195
191
optimizer: optimizer, startingValues: values,
196
- expectedValues: [ 0.0021518078 , - 0.002151505 , - 0.0021518408 ] )
192
+ expectedValues: [ 0.0021518273 , - 0.002151505 , - 0.0021517489 ] )
197
193
}
198
194
199
195
func testAMSGradNumerical( ) {
@@ -203,7 +199,7 @@ class OptimizerTests: XCTestCase {
203
199
// `[ 0.9999907, -0.9999898, -0.9999904]`.
204
200
testNumericalCorrectness (
205
201
optimizer: optimizer, startingValues: values,
206
- expectedValues: [ 0.9999906 , - 0.9999898 , - 0.99999064 ] )
202
+ expectedValues: [ 0.99999064 , - 0.9999898 , - 0.9999905 ] )
207
203
}
208
204
209
205
func testAdaMaxNumerical( ) {
@@ -213,27 +209,27 @@ class OptimizerTests: XCTestCase {
213
209
// `[ 0.99999076, -0.99999064, -0.99999064]`.
214
210
testNumericalCorrectness (
215
211
optimizer: optimizer, startingValues: values,
216
- expectedValues: [ 0.9999907 , - 0.99999064 , - 0.9999907 ] )
212
+ expectedValues: [ 0.9999907 , - 0.99999064 , - 0.99999064 ] )
217
213
}
218
214
219
215
func testAdaGradNumerical( ) {
220
216
let values = NumericalValues ( )
221
217
let optimizer = AdaGrad ( for: values, learningRate: 1e-3 , epsilon: 1e-7 )
222
- // FIXME(TF-759): Investigate large differences with Python reference implementation results:
223
- // `[ 0.06179592 , -0.05709525 , -0.05987222 ]`.
218
+ // FIXME(TF-759): Investigate small differences with Python reference implementation results:
219
+ // `[ 0.061795924 , -0.057095252 , -0.059872225 ]`.
224
220
testNumericalCorrectness (
225
221
optimizer: optimizer, startingValues: values,
226
- expectedValues: [ 0.061354622 , - 0.057095252 , - 0.061786927 ] )
222
+ expectedValues: [ 0.06179592 , - 0.057095252 , - 0.059872225 ] )
227
223
}
228
224
229
225
func testRAdamNumerical( ) {
230
226
let values = NumericalValues ( )
231
227
let optimizer = RAdam ( for: values, learningRate: 1e-3 , epsilon: 1e-7 )
232
- // FIXME(TF-759): Investigate large differences with Python reference implementation results:
228
+ // FIXME(TF-759): Investigate small differences with Python reference implementation results:
233
229
// `[ 0.46914074, -0.44463935, -0.44513944]`.
234
230
testNumericalCorrectness (
235
231
optimizer: optimizer, startingValues: values,
236
- expectedValues: [ 0.44664007 , - 0.44463903 , - 0.45914108 ] )
232
+ expectedValues: [ 0.46914074 , - 0.44463903 , - 0.44513932 ] )
237
233
}
238
234
239
235
static var allTests = [
0 commit comments