Exemplo n.º 1
0
            /*************************************************************************
            Serializer: serialization

              -- ALGLIB --
                 Copyright 14.03.2011 by Bochkanov Sergey
            *************************************************************************/
            public static void mlpserialize(alglib.serializer s,
                multilayerperceptron network)
            {
                int i = 0;
                int j = 0;
                int k = 0;
                int fkind = 0;
                double threshold = 0;
                double v0 = 0;
                double v1 = 0;
                int nin = 0;
                int nout = 0;

                nin = network.hllayersizes[0];
                nout = network.hllayersizes[alglib.ap.len(network.hllayersizes) - 1];
                s.serialize_int(scodes.getmlpserializationcode());
                s.serialize_int(mlpfirstversion);
                s.serialize_bool(mlpissoftmax(network));
                apserv.serializeintegerarray(s, network.hllayersizes, -1);
                for (i = 1; i <= alglib.ap.len(network.hllayersizes) - 1; i++)
                {
                    for (j = 0; j <= network.hllayersizes[i] - 1; j++)
                    {
                        mlpgetneuroninfo(network, i, j, ref fkind, ref threshold);
                        s.serialize_int(fkind);
                        s.serialize_double(threshold);
                        for (k = 0; k <= network.hllayersizes[i - 1] - 1; k++)
                        {
                            s.serialize_double(mlpgetweight(network, i - 1, k, i, j));
                        }
                    }
                }
                for (j = 0; j <= nin - 1; j++)
                {
                    mlpgetinputscaling(network, j, ref v0, ref v1);
                    s.serialize_double(v0);
                    s.serialize_double(v1);
                }
                for (j = 0; j <= nout - 1; j++)
                {
                    mlpgetoutputscaling(network, j, ref v0, ref v1);
                    s.serialize_double(v0);
                    s.serialize_double(v1);
                }
            }