1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
bool CSOINN::SaveNetworkData(void)
{
HANDLE hFile;
DWORD dwWriteSize;
int i, nodeNum, edgeNum;
hFile = CreateFile(TEXT("C:\fileName.TXT"), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE)
{
cout <<"Error:Could not create hfile!" <<endl;
CloseHandle(hFile);
return false;
}
// SOINN data
WriteFile(hFile, &(this->m_dimension), sizeof(int), &dwWriteSize, NULL);// m_dimension
WriteFile(hFile, &(this->m_lambda), sizeof(int), &dwWriteSize, NULL); // m_lambda
WriteFile(hFile, &(this->m_ageMax), sizeof(int), &dwWriteSize, NULL); // m_ageMax
WriteFile(hFile, &(this->m_classNum), sizeof(int), &dwWriteSize, NULL); // m_classNum
WriteFile(hFile, &(this->m_inputNum), sizeof(int), &dwWriteSize, NULL); // m_inputNum
WriteFile(hFile, &(this->QuantizeError), sizeof(double), &dwWriteSize, NULL); //Quantization Error
cout <<"SOINN data saved!" <<endl;
// Node data
nodeNum = (int)m_nodeInfo.size();
WriteFile(hFile, &nodeNum, sizeof(int), &dwWriteSize, NULL);// nodeNum
for (i=0; i<nodeNum; i++)
{
WriteFile(hFile, this->m_nodeInfo[i].m_signal, sizeof(double)*m_dimension, &dwWriteSize, NULL); // m_signal
WriteFile(hFile, this->m_nodeInfo[i].m_neighbor, sizeof(int)*CNode::MAX_NEIGHBOR, &dwWriteSize, NULL); // m_neighbor
WriteFile(hFile, &(this->m_nodeInfo[i].m_neighborNum), sizeof(int), &dwWriteSize, NULL); // m_neighborNum
WriteFile(hFile, &(this->m_nodeInfo[i].m_learningTime), sizeof(int), &dwWriteSize, NULL); // m_learningTime
WriteFile(hFile, &(this->m_nodeInfo[i].m_classID), sizeof(int), &dwWriteSize, NULL); // m_classID
cout <<"Node data saved!" <<endl;
//WriteFile(hFile, &(this->m_nodeInfo[i].m_dimension), sizeof(int), &dwWriteSize, NULL); // m_dimension
}
|