29{
30 int numProcs = 0;
31 int myRank = 0;
32 size_t stage = 0;
33 ofstream myLog;
34
35 string suffix = "";
36 if (argc > 1)
37 {
38 stage = (size_t)atoi(argv[1]);
39 suffix =
strpr(
".stage-%zu", stage);
40 }
41
42 MPI_Init(&argc, &argv);
43 MPI_Comm_size(MPI_COMM_WORLD, &numProcs);
44 MPI_Comm_rank(MPI_COMM_WORLD, &myRank);
45
46
49
50 myLog.open((
strpr(
"nnp-train.log.%04d", myRank) + suffix).c_str());
56
57
59 "",
61 stage == 1
62 );
66
67
69
70
71
74
75
77
78
80 {
82 }
83
84
86
87
89
90
92
93
95
96 myLog.close();
97
98 MPI_Finalize();
99
100 return 0;
101}
int distributeStructures(bool randomize, bool excludeRank0=false, std::string const &fileName="input.data")
Read data file and distribute structures among processors.
void setupMPI()
Initialize MPI with MPI_COMM_WORLD.
void setupRandomNumberGenerator()
Initialize random number generator.
void toNormalizedUnits()
Switch all structures to normalized units.
void registerStreamPointer(std::ofstream *const &streamPointer)
Register new C++ ofstream pointer.
bool writeToStdout
Turn on/off output to stdout.
void initialize()
Write welcome message with version information.
void setupGeneric(std::string const &nnpDir="", bool skipNormalize=false, bool initialHardness=false)
Combine multiple setup routines and provide a basic NNP setup.
bool useNormalization() const
Check if normalization is enabled.
virtual void setupSymmetryFunctionScaling(std::string const &fileName="scaling.data")
Set up symmetry function scaling from file.
bool settingsKeywordExists(std::string const &keyword) const
Check if keyword was found in settings file.
void setupSymmetryFunctionStatistics(bool collectStatistics, bool collectExtrapolationWarnings, bool writeExtrapolationWarnings, bool stopOnExtrapolationWarnings)
Set up symmetry function statistics collection.
void loadSettingsFile(std::string const &fileName="input.nn")
Open settings file and load all keywords into memory.
void setupTraining()
General training settings and setup of weight update routine.
void selectSets()
Randomly select training and test set structures.
void dataSetNormalization()
Apply normalization based on initial weights prediction.
void loop()
Execute main training loop.
void initializeWeights()
Initialize weights for all elements.
void calculateNeighborLists()
Calculate neighbor lists for all structures.
void writeSetsToFiles()
Write training and test set to separate files (train.data and test.data, same format as input....
void setStage(std::size_t stage)
Set training stage (if multiple stages are needed for NNP type).
string strpr(const char *format,...)
String version of printf function.