示例#1
0
文件: Neurone.cs 项目: Sorenly/neuron
        private void btn_Save_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.ShowDialog();
            sfd.Filter = "Neuron State Files (*.neuron)|*.neuron";
            if (sfd.FileName != null)
            {
                using (FormattedWriter fw = new FormattedWriter(sfd.FileName))
                {
                    ProgramStateFile psf = new ProgramStateFile();
                    psf.version = 0;
                    psf.nodes   = inputs.Concat(hiddens).Concat(outputs).Select(x => new Node()
                    {
                        x    = x.MainControl.Location.X,
                        y    = x.MainControl.Location.Y,
                        size = x.Data.size,
                        name = new StringData()
                        {
                            Contents = x.Data.name
                        },
                        type     = x.Data.fvt,
                        numlinks = x.Edges.Count,
                        links    = x.Edges.Select(edge => new Link()
                        {
                            matrix   = new MatrixFormat(edge.Value.Data.weights.CopyToArray()),
                            nodename = new StringData()
                            {
                                Contents = edge.Key.Data.name
                            }
                        }).ToArray()
                    }).ToArray();
                    psf.numNodes = psf.nodes.Length;

                    psf.configurations = new StringData[data_configurations.Rows.Count];
                    for (int i = 0; i < psf.configurations.Length; i++)
                    {
                        psf.configurations[i].Contents = data_configurations.Rows[i].Cells[2].Value.ToString();
                    }
                    psf.numConfigurations = psf.configurations.Length;

                    psf.trainings = new StringData[data_training.Rows.Count];
                    for (int i = 0; i < psf.trainings.Length; i++)
                    {
                        psf.trainings[i].Contents = data_training.Rows[i].Cells[2].Value.ToString();
                    }
                    psf.numTrainings = psf.trainings.Length;

                    psf.crossValidations = new StringData[data_crossValidationData.Rows.Count];
                    for (int i = 0; i < psf.crossValidations.Length; i++)
                    {
                        psf.crossValidations[i].Contents = data_crossValidationData.Rows[i].Cells[2].Value.ToString();
                    }
                    psf.numCrossValidations = psf.crossValidations.Length;

                    fw.Write(psf);
                }
            }
        }
示例#2
0
        private void btn_Save_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();
            sfd.ShowDialog();
            sfd.Filter = "Neuron State Files (*.neuron)|*.neuron";
            if (sfd.FileName != null)
            {
                using (FormattedWriter fw = new FormattedWriter(sfd.FileName))
                {
                    ProgramStateFile psf = new ProgramStateFile();
                    psf.version = 0;
                    psf.nodes = inputs.Concat(hiddens).Concat(outputs).Select(x => new Node()
                    {
                        x = x.MainControl.Location.X,
                        y = x.MainControl.Location.Y,
                        size = x.Data.size,
                        name = new StringData() { Contents = x.Data.name },
                        type = x.Data.fvt,
                        numlinks = x.Edges.Count,
                        links = x.Edges.Select(edge => new Link()
                        {
                            matrix = new MatrixFormat(edge.Value.Data.weights.CopyToArray()),
                            nodename = new StringData() { Contents = edge.Key.Data.name }
                        }).ToArray()
                    }).ToArray();
                    psf.numNodes = psf.nodes.Length;

                    psf.configurations = new StringData[data_configurations.Rows.Count];
                    for (int i = 0; i < psf.configurations.Length; i++)
                    {
                        psf.configurations[i].Contents = data_configurations.Rows[i].Cells[2].Value.ToString();
                    }
                    psf.numConfigurations = psf.configurations.Length;

                    psf.trainings = new StringData[data_training.Rows.Count];
                    for (int i = 0; i < psf.trainings.Length; i++)
                    {
                        psf.trainings[i].Contents = data_training.Rows[i].Cells[2].Value.ToString();
                    }
                    psf.numTrainings = psf.trainings.Length;

                    psf.crossValidations = new StringData[data_crossValidationData.Rows.Count];
                    for (int i = 0; i < psf.crossValidations.Length; i++)
                    {
                        psf.crossValidations[i].Contents = data_crossValidationData.Rows[i].Cells[2].Value.ToString();
                    }
                    psf.numCrossValidations = psf.crossValidations.Length;

                    fw.Write(psf);
                }
            }
        }