private static int VerifyNetwork(Network network)
        {
            int errors = 0;

            var edges = network.GetEdges();

            for (int layer = 0; layer < network.Layers; layer++)
            {
                var nodes = network.GetNodes(layer);

                foreach (var node in nodes)
                {
                    foreach (var iedge in node.In)
                    {
                        if (!edges.Any(a => a.ParentId == iedge.ParentId && a.ChildId == iedge.ChildId))
                            errors++;
                    }
                    foreach (var oedge in node.Out)
                    {
                        if (!edges.Any(a => a.ParentId == oedge.ParentId && a.ChildId == oedge.ChildId))
                            errors++;
                    }

                    if (layer == 0 && node.In.Count > 0) errors++;
                    if (layer == network.Layers - 1 && node.Out.Count > 0) errors++;
                }
            }

            network.Forward(Vector.Ones(network.In.Length - 1));

            if (network.Out.Any(a => double.IsNaN(a.Output) || double.IsInfinity(a.Output))) errors++;

            return errors;
        }