MCPcopy Create free account
hub / github.com/daniel-e/rustml / test_update

Function test_update

src/nn.rs:413–451  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

411
412 #[test]
413 fn test_update() {
414
415 let m1 = mat![
416 0.0, 0.0, 0.0;
417 0.0, 0.0, 0.0
418 ];
419
420 let m2 = mat![
421 0.0, 0.0, 0.0;
422 0.0, 0.0, 0.0;
423 0.0, 0.0, 0.0;
424 0.0, 0.0, 0.0
425 ];
426
427 let a1 = vec![0.4, 0.2, 0.3];
428 let a2 = vec![0.7, 0.8, 0.2];
429
430 let d3 = vec![0.6, 0.2, 0.5, 0.3];
431 let d2 = vec![0.4, 0.1];
432
433 let mut m = vec![m1, m2];
434 let d = vec![d3, d2];
435 let a = vec![a1, a2];
436
437 let n = NeuralNetwork::new();
438 n.update(&mut m, &d, &a);
439
440 assert!(m[0].similar(&mat![
441 0.16, 0.08, 0.12;
442 0.04, 0.02, 0.03
443 ], 0.01));
444
445 assert!(m[1].similar(&mat![
446 0.42, 0.48, 0.12;
447 0.14, 0.16, 0.04;
448 0.35, 0.40, 0.10;
449 0.21, 0.24, 0.06
450 ], 0.01));
451 }
452
453 #[test]
454 fn test_error() {

Callers

nothing calls this directly

Calls 1

updateMethod · 0.80

Tested by

no test coverage detected