AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

Save the network in an excel file

Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.

Save the network in an excel file

Postby Arms_deir » Sat Aug 29, 2015 3:38 pm

Hello,


I want to save my entire trained network to an excel file using below code.is it possible to save it in another way or? I see in docs that I can save the net to a bin file, however, I need to save in an excel file to process it further.


Code: Select all
string Output = @"Data\Output.xlsx";

Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();

if (xlApp == null)
{
    MessageBox.Show("Excel is not properly installed!!");
}
else
{
    Excel.Workbook excelWorkBook;
    Excel.Worksheet xlWorkSheet;

    excelWorkBook = xlApp.Workbooks.Add();
    xlWorkSheet = (Excel.Worksheet)excelWorkBook.Worksheets.get_Item(1);//Add sheet

    for (int rowIndex = 1; rowIndex < neuronsInHiddenLayer; rowIndex++)
    {
        xlWorkSheet.Cells[rowIndex, 1] = network.Layers[0].Neurons[1].Weights[rowIndex];
    }

    //Save excel file and close it
    string fileName = Path.GetFullPath(Output);//Make full path file address

    excelWorkBook.SaveAs(fileName);
    excelWorkBook.Close(true);
    xlApp.Quit();

    //Free up memory
    GC.Collect();

    MessageBox.Show("Output is Saved Successfully!", "Successful");
}


regards
AM
Arms_deir
 
Posts: 13
Joined: Mon Jul 13, 2015 2:47 pm



Return to AForge.NET Framework