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

Function test_error

src/nn.rs:454–489  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

452
453 #[test]
454 fn test_error() {
455
456 // parameters
457 let params1 = mat![
458 0.1, 0.2, 0.4;
459 0.2, 0.1, 2.0
460 ];
461
462 let params2 = mat![
463 0.8, 1.2, 0.6;
464 0.4, 0.5, 0.8;
465 1.4, 1.5, 2.0
466 ];
467
468 let n = NeuralNetwork::new()
469 .add_layer(3)
470 .add_layer(2)
471 .add_layer(3)
472 .set_params(0, params1)
473 .set_params(1, params2);
474
475 let x = mat![
476 0.5, 1.2, 1.5;
477 1.0, 2.0, 1.0;
478 3.0, 1.4, 4.2
479 ];
480
481 let t = mat![
482 0.4, 1.0, 0.8;
483 1.2, 0.4, 0.2;
484 0.6, 0.3, 1.1
485 ];
486 let e = n.error(&x, &t);
487
488 assert!(num::abs(e - 0.26807) <= 0.0001);
489 }
490
491 #[test]
492 fn test_update_params() {

Callers

nothing calls this directly

Calls 3

set_paramsMethod · 0.80
add_layerMethod · 0.80
errorMethod · 0.45

Tested by

no test coverage detected