// Checks that the dimensions are all correct when the network is initialized
Checks that the dimensions are all correct when the network is initialized
Checks that the dimensions are all correct when the network is initialized
fn network_initializes_correctly() {
        let layer_sizes = vec![784, 30, 10];
        let network = Network::new(layer_sizes.clone());
        assert_eq!(network.layer_sizes, layer_sizes);
        for (layer_biases, layer_size) in network
            .biases
            .iter()
            .zip(network.layer_sizes.iter().skip(1))
        {
            assert_eq!(layer_biases.raw_dim(), Dim([*layer_size as usize, 1]));
        }
        for (i, layer_weights) in network
            .weights
            .iter()
            .take(layer_sizes.len() - 1)
            .enumerate()
        {
            assert_eq!(
                layer_weights.raw_dim(),
                Dim([layer_sizes[i + 1] as usize, layer_sizes[i] as usize])
            );
        }
    }
fn network_initializes_correctly ( ) { let layer_sizes = vec ! [ 784 30 10 ] ; let network = Network :: new ( layer_sizes . clone ( ) ) ; assert_eq ! ( network layer_sizes layer_sizes ) ; for ( layer_biases , layer_size ) in network . biases . iter ( ) . zip ( network . layer_sizes . iter ( ) . skip ( 1 ) ) { assert_eq ! ( layer_biases raw_dim ( ) Dim ( [ layer_size as usize 1 ] ) ) ; } for ( i , layer_weights ) in network . weights . iter ( ) . take ( layer_sizes . len ( ) - 1 ) . enumerate ( ) { assert_eq ! ( layer_weights raw_dim ( ) Dim ( [ layer_sizes [ i 1 ] as usize layer_sizes [ i ] as usize ] ) ) ; } }
Checks that the dimensions are all correct when the network is initialized
Checks that the dimensions are all correct when the network is initialized