int VGGNet::savenet(constchar* szTrainSetStateFilePath) { // Save the net state to xxxx.pt and save the labels to xxxx.pt.label char szLabel[MAX_LABEL_NAME]={0}; try { torch::serialize::OutputArchive archive; // Add nested archive here c10::List<std::string> label_list; for(size_t i =0; i < m_image_labels.size(); i++) { memset(szLabel,0,sizeof(szLabel)); WideCharToMultiByte(CP_UTF8,0, m_image_labels[i].c_str(),-1, szLabel, MAX_LABEL_NAME,NULL,NULL); label_list.emplace_back((constchar*)szLabel); } torch::IValue value(label_list); archive.write("VGG_labels", label_list); // also save the current network configuration torch::IValue valNumClass(m_num_classes); archive.write("VGG_num_of_class", valNumClass); torch::IValue valNetConfig((int64_t)m_VGG_config); archive.write("VGG_config", valNetConfig); torch::IValue valUseSmallSize(m_use_32x32_input); archive.write("VGG_use_32x32_input", valUseSmallSize); save(archive); archive.save_to(szTrainSetStateFilePath); } catch(...) { printf("Failed to save the trained VGG net state.\n"); return-1; } printf("Save the training result to %s.\n", szTrainSetStateFilePath); return0; }