n2p2 - A neural network potential package
|
#include <Training.h>
Classes | |
struct | Property |
Specific training quantity (e.g. energies, forces, charges). More... | |
struct | PropertyMap |
Map of all training properties. More... | |
struct | SubCandidate |
Contains update candidate which is grouped with others to specific parent update candidate (e.g. More... | |
struct | UpdateCandidate |
Contains location of one update candidate (energy or force). More... | |
Public Types | |
enum | UpdaterType { UT_GD , UT_KF , UT_LM } |
Type of update routine. More... | |
enum | ParallelMode { PM_TRAIN_RK0 , PM_TRAIN_ALL } |
Training parallelization mode. More... | |
enum | JacobianMode { JM_SUM , JM_TASK , JM_FULL } |
Jacobian matrix preparation mode. More... | |
enum | UpdateStrategy { US_COMBINED , US_ELEMENT } |
Update strategies available for Training. More... | |
enum | SelectionMode { SM_RANDOM , SM_SORT , SM_THRESHOLD } |
How update candidates are selected during Training. More... | |
Public Types inherited from nnp::Mode | |
enum class | NNPType { HDNNP_2G = 2 , HDNNP_4G = 4 , HDNNP_Q = 10 } |
Public Member Functions | |
Training () | |
Constructor. More... | |
~Training () | |
Destructor, updater vector needs to be cleaned. More... | |
void | selectSets () |
Randomly select training and test set structures. More... | |
void | writeSetsToFiles () |
Write training and test set to separate files (train.data and test.data, same format as input.data). More... | |
void | initializeWeights () |
Initialize weights for all elements. More... | |
void | initializeWeightsMemory (UpdateStrategy updateStrategy=US_COMBINED) |
Initialize weights vector according to update strategy. More... | |
void | setStage (std::size_t stage) |
Set training stage (if multiple stages are needed for NNP type). More... | |
void | dataSetNormalization () |
Apply normalization based on initial weights prediction. More... | |
void | setupTraining () |
General training settings and setup of weight update routine. More... | |
std::vector< std::string > | setupNumericDerivCheck () |
Set up numeric weight derivatives check. More... | |
void | calculateNeighborLists () |
Calculate neighbor lists for all structures. More... | |
void | calculateError (std::map< std::string, std::pair< std::string, std::string > > const fileNames) |
Calculate error metrics for all structures. More... | |
void | calculateErrorEpoch () |
Calculate error metrics per epoch for all structures with file names used in training loop. More... | |
void | calculateChargeErrorVec (Structure const &s, Eigen::VectorXd &cVec, double &cNorm) |
Calculate vector of charge errors in one structure. More... | |
void | printHeader () |
Print training loop header on screen. More... | |
void | printEpoch () |
Print preferred error metric and timing information on screen. More... | |
void | writeWeights (std::string const &nnName, std::string const &fileNameFormat) const |
Write weights to files (one file for each element). More... | |
void | writeWeightsEpoch () const |
Write weights to files during training loop. More... | |
void | writeHardness (std::string const &fileNameFormat) const |
Write hardness to files (one file for each element). More... | |
void | writeHardnessEpoch () const |
Write hardness to files during training loop. More... | |
void | writeLearningCurve (bool append, std::string const fileName="learning-curve.out") const |
Write current RMSEs and epoch information to file. More... | |
void | writeNeuronStatistics (std::string const &nnName, std::string const &fileName) const |
Write neuron statistics collected since last invocation. More... | |
void | writeNeuronStatisticsEpoch () const |
Write neuron statistics during training loop. More... | |
void | resetNeuronStatistics () |
Reset neuron statistics for all elements. More... | |
void | writeUpdaterStatus (bool append, std::string const fileNameFormat="updater.%03zu.out") const |
Write updater information to file. More... | |
void | sortUpdateCandidates (std::string const &property) |
Sort update candidates with descending RMSE. More... | |
void | shuffleUpdateCandidates (std::string const &property) |
Shuffle update candidates. More... | |
void | checkSelectionMode () |
Check if selection mode should be changed. More... | |
void | loop () |
Execute main training loop. More... | |
void | setEpochSchedule () |
Select energies/forces schedule for one epoch. More... | |
void | update (std::string const &property) |
Perform one update. More... | |
double | getSingleWeight (std::size_t element, std::size_t index) |
Get a single weight value. More... | |
void | setSingleWeight (std::size_t element, std::size_t index, double value) |
Set a single weight value. More... | |
std::vector< std::vector< double > > | calculateWeightDerivatives (Structure *structure) |
Calculate derivatives of energy with respect to weights. More... | |
std::vector< std::vector< double > > | calculateWeightDerivatives (Structure *structure, std::size_t atom, std::size_t component) |
Calculate derivatives of force with respect to weights. More... | |
void | setTrainingLogFileName (std::string fileName) |
Set training log file name. More... | |
std::size_t | getNumConnections (std::string id="short") const |
Get total number of NN connections. More... | |
std::vector< std::size_t > | getNumConnectionsPerElement (std::string id="short") const |
Get number of NN connections for each element. More... | |
std::vector< std::size_t > | getConnectionOffsets (std::string id="short") const |
Get offsets of NN connections for each element. More... | |
void | dPdc (std::string property, Structure &structure, std::vector< std::vector< double > > &dEdc) |
Compute derivatives of property with respect to weights. More... | |
void | dPdcN (std::string property, Structure &structure, std::vector< std::vector< double > > &dEdc, double delta=1.0E-4) |
Compute numeric derivatives of property with respect to weights. More... | |
Public Member Functions inherited from nnp::Dataset | |
Dataset () | |
Constructor, initialize members. More... | |
~Dataset () | |
Destructor. More... | |
void | setupMPI () |
Initialize MPI with MPI_COMM_WORLD. More... | |
void | setupMPI (MPI_Comm *communicator) |
Initialize MPI with given communicator. More... | |
void | setupRandomNumberGenerator () |
Initialize random number generator. More... | |
std::size_t | getNumStructures (std::ifstream &dataFile) |
Get number of structures in data file. More... | |
int | calculateBufferSize (Structure const &structure) const |
Calculate buffer size required to communicate structure via MPI. More... | |
int | sendStructure (Structure const &structure, int dest) const |
Send one structure to destination process. More... | |
int | recvStructure (Structure *structure, int src) |
Receive one structure from source process. More... | |
int | distributeStructures (bool randomize, bool excludeRank0=false, std::string const &fileName="input.data") |
Read data file and distribute structures among processors. More... | |
std::size_t | prepareNumericForces (Structure &original, double delta) |
Prepare numeric force check for a single structure. More... | |
void | toNormalizedUnits () |
Switch all structures to normalized units. More... | |
void | toPhysicalUnits () |
Switch all structures to physical units. More... | |
void | collectSymmetryFunctionStatistics () |
Collect symmetry function statistics from all processors. More... | |
void | writeSymmetryFunctionScaling (std::string const &fileName="scaling.data") |
Write symmetry function scaling values to file. More... | |
void | writeSymmetryFunctionHistograms (std::size_t numBins, std::string fileNameFormat="sf.%03zu.%04zu.histo") |
Calculate and write symmetry function histograms. More... | |
void | writeSymmetryFunctionFile (std::string fileName="function.data") |
Write symmetry function legacy file ("function.data"). More... | |
std::size_t | writeNeighborHistogram (std::string const &fileNameHisto="neighbors.histo", std::string const &fileNameStructure="neighbors.out") |
Calculate and write neighbor histogram and per-structure statistics. More... | |
void | sortNeighborLists () |
Sort all neighbor lists according to element and distance. More... | |
void | writeNeighborLists (std::string const &fileName="neighbor-list.data") |
Write neighbor list file. More... | |
void | writeAtomicEnvironmentFile (std::vector< std::vector< std::size_t > > neighCutoff, bool derivatives, std::string const &fileNamePrefix="atomic-env") |
Write atomic environment file. More... | |
void | collectError (std::string const &property, std::map< std::string, double > &error, std::size_t &count) const |
Collect error metrics of a property over all MPI procs. More... | |
void | combineFiles (std::string filePrefix) const |
Combine individual MPI proc files to one. More... | |
Public Member Functions inherited from nnp::Mode | |
Mode () | |
void | initialize () |
Write welcome message with version information. More... | |
void | loadSettingsFile (std::string const &fileName="input.nn") |
Open settings file and load all keywords into memory. More... | |
void | setupGeneric (std::string const &nnpDir="", bool skipNormalize=false, bool initialHardness=false) |
Combine multiple setup routines and provide a basic NNP setup. More... | |
void | setupNormalization (bool standalone=true) |
Set up normalization. More... | |
virtual void | setupElementMap () |
Set up the element map. More... | |
virtual void | setupElements () |
Set up all Element instances. More... | |
void | setupCutoff () |
Set up cutoff function for all symmetry functions. More... | |
virtual void | setupSymmetryFunctions () |
Set up all symmetry functions. More... | |
void | setupSymmetryFunctionScalingNone () |
Set up "empy" symmetry function scaling. More... | |
virtual void | setupSymmetryFunctionScaling (std::string const &fileName="scaling.data") |
Set up symmetry function scaling from file. More... | |
virtual void | setupSymmetryFunctionGroups () |
Set up symmetry function groups. More... | |
virtual void | setupSymmetryFunctionCache (bool verbose=false) |
Set up symmetry function cache. More... | |
void | setupSymmetryFunctionMemory (bool verbose=false) |
Extract required memory dimensions for symmetry function derivatives. More... | |
void | setupSymmetryFunctionStatistics (bool collectStatistics, bool collectExtrapolationWarnings, bool writeExtrapolationWarnings, bool stopOnExtrapolationWarnings) |
Set up symmetry function statistics collection. More... | |
void | setupCutoffMatrix () |
Setup matrix storing all symmetry function cut-offs for each element. More... | |
virtual void | setupNeuralNetwork () |
Set up neural networks for all elements. More... | |
virtual void | setupNeuralNetworkWeights (std::map< std::string, std::string > fileNameFormats=std::map< std::string, std::string >()) |
Set up neural network weights from files with given name format. More... | |
virtual void | setupNeuralNetworkWeights (std::string directoryPrefix, std::map< std::string, std::string > fileNameFormats=std::map< std::string, std::string >()) |
Set up neural network weights from files with given name format. More... | |
virtual void | setupElectrostatics (bool initialHardness=false, std::string directoryPrefix="", std::string fileNameFormat="hardness.%03zu.data") |
Set up electrostatics related stuff (hardness, screening, ...). More... | |
void | calculateSymmetryFunctions (Structure &structure, bool const derivatives) |
Calculate all symmetry functions for all atoms in given structure. More... | |
void | calculateSymmetryFunctionGroups (Structure &structure, bool const derivatives) |
Calculate all symmetry function groups for all atoms in given structure. More... | |
void | calculateAtomicNeuralNetworks (Structure &structure, bool const derivatives, std::string id="") |
Calculate atomic neural networks for all atoms in given structure. More... | |
void | chargeEquilibration (Structure &structure, bool const derivativesElec) |
Perform global charge equilibration method. More... | |
void | calculateEnergy (Structure &structure) const |
Calculate potential energy for a given structure. More... | |
void | calculateCharge (Structure &structure) const |
Calculate total charge for a given structure. More... | |
void | calculateForces (Structure &structure) const |
Calculate forces for all atoms in given structure. More... | |
void | evaluateNNP (Structure &structure, bool useForces=true, bool useDEdG=true) |
Evaluate neural network potential (includes total energy, optionally forces and in some cases charges. More... | |
void | addEnergyOffset (Structure &structure, bool ref=true) |
Add atomic energy offsets to reference energy. More... | |
void | removeEnergyOffset (Structure &structure, bool ref=true) |
Remove atomic energy offsets from reference energy. More... | |
double | getEnergyOffset (Structure const &structure) const |
Get atomic energy offset for given structure. More... | |
double | getEnergyWithOffset (Structure const &structure, bool ref=true) const |
Add atomic energy offsets and return energy. More... | |
double | normalized (std::string const &property, double value) const |
Apply normalization to given property. More... | |
double | normalizedEnergy (Structure const &structure, bool ref=true) const |
Apply normalization to given energy of structure. More... | |
double | physical (std::string const &property, double value) const |
Undo normalization for a given property. More... | |
double | physicalEnergy (Structure const &structure, bool ref=true) const |
Undo normalization for a given energy of structure. More... | |
void | convertToNormalizedUnits (Structure &structure) const |
Convert one structure to normalized units. More... | |
void | convertToPhysicalUnits (Structure &structure) const |
Convert one structure to physical units. More... | |
void | logEwaldCutoffs () |
Logs Ewald params whenever they change. More... | |
std::size_t | getNumExtrapolationWarnings () const |
Count total number of extrapolation warnings encountered for all elements and symmetry functions. More... | |
void | resetExtrapolationWarnings () |
Erase all extrapolation warnings and reset counters. More... | |
NNPType | getNnpType () const |
Getter for Mode::nnpType. More... | |
double | getMeanEnergy () const |
Getter for Mode::meanEnergy. More... | |
double | getConvEnergy () const |
Getter for Mode::convEnergy. More... | |
double | getConvLength () const |
Getter for Mode::convLength. More... | |
double | getConvCharge () const |
Getter for Mode::convCharge. More... | |
double | getMaxCutoffRadius () const |
Getter for Mode::maxCutoffRadius. More... | |
std::size_t | getNumElements () const |
Getter for Mode::numElements. More... | |
std::vector< std::size_t > | getNumSymmetryFunctions () const |
Get number of symmetry functions per element. More... | |
bool | useNormalization () const |
Check if normalization is enabled. More... | |
bool | settingsKeywordExists (std::string const &keyword) const |
Check if keyword was found in settings file. More... | |
std::string | settingsGetValue (std::string const &keyword) const |
Get value for given keyword in Settings instance. More... | |
std::vector< std::size_t > | pruneSymmetryFunctionsRange (double threshold) |
Prune symmetry functions according to their range and write settings file. More... | |
std::vector< std::size_t > | pruneSymmetryFunctionsSensitivity (double threshold, std::vector< std::vector< double > > sensitivity) |
Prune symmetry functions with sensitivity analysis data. More... | |
void | writePrunedSettingsFile (std::vector< std::size_t > prune, std::string fileName="output.nn") const |
Copy settings file but comment out lines provided. More... | |
void | writeSettingsFile (std::ofstream *const &file) const |
Write complete settings file. More... | |
Private Member Functions | |
bool | advance () const |
Check if training loop should be continued. More... | |
void | getWeights () |
Get weights from neural network class. More... | |
void | setWeights () |
Set weights in neural network class. More... | |
void | addTrainingLogEntry (int proc, std::size_t il, double f, std::size_t isg, std::size_t is) |
Write energy update data to training log file. More... | |
void | addTrainingLogEntry (int proc, std::size_t il, double f, std::size_t isg, std::size_t is, std::size_t ia, std::size_t ic) |
Write force update data to training log file. More... | |
void | addTrainingLogEntry (int proc, std::size_t il, double f, std::size_t isg, std::size_t is, std::size_t ia) |
Write charge update data to training log file. More... | |
void | collectDGdxia (Atom const &atom, std::size_t indexAtom, std::size_t indexComponent) |
Collect derivative of symmetry functions with respect to one atom's coordinate. More... | |
void | randomizeNeuralNetworkWeights (std::string const &id) |
Randomly initialize specificy neural network weights. More... | |
void | setupSelectionMode (std::string const &property) |
Set selection mode for specific training property. More... | |
void | setupFileOutput (std::string const &type) |
Set file output intervals for properties and other quantities. More... | |
void | setupUpdatePlan (std::string const &property) |
Set up how often properties are updated. More... | |
void | allocateArrays (std::string const &property) |
Allocate error and Jacobian arrays for given property. More... | |
void | writeTimingData (bool append, std::string const fileName="timing.out") |
Write timing data for all clocks. More... | |
Private Attributes | |
UpdaterType | updaterType |
Updater type used. More... | |
ParallelMode | parallelMode |
Parallelization mode used. More... | |
JacobianMode | jacobianMode |
Jacobian mode used. More... | |
UpdateStrategy | updateStrategy |
Update strategy used. More... | |
bool | hasUpdaters |
If this rank performs weight updates. More... | |
bool | hasStructures |
If this rank holds structure information. More... | |
bool | useForces |
Use forces for training. More... | |
bool | repeatedEnergyUpdates |
After force update perform energy update for corresponding structure. More... | |
bool | freeMemory |
Free symmetry function memory after calculation. More... | |
bool | writeTrainingLog |
Whether training log file is written. More... | |
std::size_t | stage |
Training stage. More... | |
std::size_t | numUpdaters |
Number of updaters (depends on update strategy). More... | |
std::size_t | numEpochs |
Number of epochs requested. More... | |
std::size_t | epoch |
Current epoch. More... | |
std::size_t | writeWeightsEvery |
Write weights every this many epochs. More... | |
std::size_t | writeWeightsAlways |
Up to this epoch weights are written every epoch. More... | |
std::size_t | writeNeuronStatisticsEvery |
Write neuron statistics every this many epochs. More... | |
std::size_t | writeNeuronStatisticsAlways |
Up to this epoch neuron statistics are written every epoch. More... | |
std::size_t | countUpdates |
Update counter (for all training quantities together). More... | |
std::size_t | numWeights |
Total number of weights. More... | |
double | forceWeight |
Force update weight. More... | |
std::string | trainingLogFileName |
File name for training log. More... | |
std::string | nnId |
ID of neural network the training is working on. More... | |
std::ofstream | trainingLog |
Training log file. More... | |
std::vector< int > | epochSchedule |
Update schedule epoch (stage 1: 0 = charge update; stage 2: 0 = energy update, 1 = force update (optional)). More... | |
std::vector< std::size_t > | numWeightsPerUpdater |
Number of weights per updater. More... | |
std::vector< std::size_t > | weightsOffset |
Offset of each element's weights in combined array. More... | |
std::vector< std::string > | pk |
Vector of actually used training properties. More... | |
std::vector< double > | dGdxia |
Derivative of symmetry functions with respect to one specific atom coordinate. More... | |
std::vector< std::vector< double > > | weights |
Neural network weights and biases for each element. More... | |
std::vector< Updater * > | updaters |
Weight updater (combined or for each element). More... | |
std::map< std::string, Stopwatch > | sw |
Stopwatches for timing overview. More... | |
std::mt19937_64 | rngNew |
Per-task random number generator. More... | |
std::mt19937_64 | rngGlobalNew |
Global random number generator. More... | |
PropertyMap | p |
Actual training properties. More... | |
Additional Inherited Members | |
Public Attributes inherited from nnp::Dataset | |
std::vector< Structure > | structures |
All structures in this dataset. More... | |
Public Attributes inherited from nnp::Mode | |
ElementMap | elementMap |
Global element map, populated by setupElementMap(). More... | |
Log | log |
Global log file. More... | |
Protected Member Functions inherited from nnp::Mode | |
void | readNeuralNetworkWeights (std::string const &id, std::string const &fileName) |
Read in weights for a specific type of neural network. More... | |
Protected Attributes inherited from nnp::Dataset | |
int | myRank |
My process ID. More... | |
int | numProcs |
Total number of MPI processors. More... | |
std::size_t | numStructures |
Total number of structures in dataset. More... | |
std::string | myName |
My processor name. More... | |
MPI_Comm | comm |
Global MPI communicator. More... | |
gsl_rng * | rng |
GSL random number generator (different seed for each MPI process). More... | |
gsl_rng * | rngGlobal |
Global GSL random number generator (equal seed for each MPI process). More... | |
Protected Attributes inherited from nnp::Mode | |
NNPType | nnpType |
bool | normalize |
bool | checkExtrapolationWarnings |
std::size_t | numElements |
std::vector< std::size_t > | minNeighbors |
std::vector< double > | minCutoffRadius |
double | maxCutoffRadius |
double | cutoffAlpha |
double | meanEnergy |
double | convEnergy |
double | convLength |
double | convCharge |
double | fourPiEps |
EwaldSetup | ewaldSetup |
settings::Settings | settings |
SymFnc::ScalingType | scalingType |
CutoffFunction::CutoffType | cutoffType |
ScreeningFunction | screeningFunction |
std::vector< Element > | elements |
std::vector< std::string > | nnk |
std::map< std::string, NNSetup > | nns |
std::vector< std::vector< double > > | cutoffs |
Matrix storing all symmetry function cut-offs for all elements. More... | |
ErfcBuf | erfcBuf |
Training methods.
Definition at line 35 of file Training.h.
Type of update routine.
Enumerator | |
---|---|
UT_GD | Simple gradient descent methods. |
UT_KF | Kalman filter-based methods. |
UT_LM | Levenberg-Marquardt algorithm. |
Definition at line 39 of file Training.h.
Training parallelization mode.
This mode determines if and how individual MPI tasks contribute to parallel training. Note that in all cases the data set gets distributed among the MPI processes and RMSE computation is always parallelized.
Definition at line 55 of file Training.h.
Jacobian matrix preparation mode.
Enumerator | |
---|---|
JM_SUM | No Jacobian, sum up contributions from update candidates. |
JM_TASK | Prepare one Jacobian entry for each task, sum up within tasks. |
JM_FULL | Prepare full Jacobian matrix. |
Definition at line 84 of file Training.h.
Update strategies available for Training.
Enumerator | |
---|---|
US_COMBINED | One combined updater for all elements. |
US_ELEMENT | Separate updaters for individual elements. |
Definition at line 95 of file Training.h.
How update candidates are selected during Training.
Enumerator | |
---|---|
SM_RANDOM | Select candidates randomly. |
SM_SORT | Sort candidates according to their RMSE and pick worst first. |
SM_THRESHOLD | Select candidates randomly with RMSE above threshold. |
Definition at line 104 of file Training.h.
Training::Training | ( | ) |
Constructor.
Definition at line 38 of file Training.cpp.
References sw.
Training::~Training | ( | ) |
Destructor, updater vector needs to be cleaned.
Definition at line 64 of file Training.cpp.
References trainingLog, updaters, updaterType, UT_GD, and UT_KF.
void Training::selectSets | ( | ) |
Randomly select training and test set structures.
Also fills training candidates lists.
Definition at line 82 of file Training.cpp.
References nnp::Structure::atoms, nnp::Dataset::comm, nnp::Mode::elementMap, nnp::Training::PropertyMap::exists(), hasStructures, nnp::Mode::HDNNP_4G, nnp::Structure::index, nnp::Mode::log, MPI_SIZE_T, nnp::Dataset::myRank, nnp::Mode::nnpType, nnp::Structure::numAtoms, nnp::Structure::numAtomsPerElement, nnp::Mode::numElements, p, pk, nnp::Dataset::rng, nnp::Structure::sampleType, nnp::Mode::settings, nnp::Structure::ST_TEST, nnp::Structure::ST_TRAINING, nnp::Structure::ST_UNKNOWN, nnp::strpr(), and nnp::Dataset::structures.
Referenced by main().
void Training::writeSetsToFiles | ( | ) |
Write training and test set to separate files (train.data and test.data, same format as input.data).
Definition at line 230 of file Training.cpp.
References nnp::Mode::addEnergyOffset(), nnp::Dataset::combineFiles(), nnp::Dataset::comm, nnp::Mode::log, nnp::Dataset::myRank, nnp::Mode::removeEnergyOffset(), nnp::Structure::ST_TEST, nnp::Structure::ST_TRAINING, nnp::strpr(), and nnp::Dataset::structures.
Referenced by main().
void Training::initializeWeights | ( | ) |
Initialize weights for all elements.
Definition at line 292 of file Training.cpp.
References nnp::Mode::HDNNP_4G, nnp::Mode::HDNNP_Q, nnp::settings::Settings::keywordExists(), nnp::Mode::NNSetup::keywordSuffix2, nnp::Mode::log, nnp::Mode::NNSetup::name, nnId, nnp::Mode::nnpType, nnp::Mode::nns, randomizeNeuralNetworkWeights(), nnp::Mode::readNeuralNetworkWeights(), nnp::Mode::settings, stage, and nnp::Mode::NNSetup::weightFileFormat.
Referenced by main().
void Training::initializeWeightsMemory | ( | UpdateStrategy | updateStrategy = US_COMBINED | ) |
Initialize weights vector according to update strategy.
[in] | updateStrategy | Determines the shape of the weights array. |
Definition at line 330 of file Training.cpp.
References nnp::Mode::elements, nnp::Mode::HDNNP_4G, nnp::Mode::log, nnId, nnp::Mode::nnpType, nnp::Mode::numElements, numUpdaters, numWeights, numWeightsPerUpdater, stage, nnp::strpr(), updateStrategy, US_COMBINED, US_ELEMENT, weights, and weightsOffset.
Referenced by setupNumericDerivCheck(), and setupTraining().
void Training::setStage | ( | std::size_t | stage | ) |
Set training stage (if multiple stages are needed for NNP type).
[in] | stage | Training stage to set. |
Definition at line 379 of file Training.cpp.
References nnp::Mode::HDNNP_2G, nnp::Mode::HDNNP_4G, nnp::Mode::HDNNP_Q, nnp::settings::Settings::keywordExists(), nnId, nnp::Mode::nnpType, p, pk, nnp::Mode::settings, stage, and nnp::strpr().
Referenced by main().
void Training::dataSetNormalization | ( | ) |
Apply normalization based on initial weights prediction.
Definition at line 429 of file Training.cpp.
References nnp::appendLinesToFile(), nnp::Mode::calculateAtomicNeuralNetworks(), nnp::Mode::calculateEnergy(), nnp::Mode::calculateForces(), nnp::Mode::calculateSymmetryFunctionGroups(), nnp::Mode::calculateSymmetryFunctions(), nnp::Dataset::combineFiles(), nnp::Mode::convEnergy, nnp::Mode::convLength, nnp::createFileHeader(), nnp::Mode::elements, nnp::Mode::getEnergyWithOffset(), nnp::settings::Settings::getSettingsLines(), nnp::Mode::HDNNP_4G, nnp::Mode::HDNNP_Q, nnp::settings::Settings::keywordExists(), nnp::Mode::log, nnp::Mode::maxCutoffRadius, nnp::Mode::meanEnergy, MPI_SIZE_T, nnp::Dataset::myRank, nnp::Mode::nnpType, nnp::Mode::normalize, nnp::Dataset::numStructures, nnp::Mode::settings, nnp::Mode::setupNormalization(), nnp::Mode::setupSymmetryFunctionCache(), nnp::Mode::setupSymmetryFunctionGroups(), nnp::Mode::setupSymmetryFunctionMemory(), nnp::Mode::setupSymmetryFunctions(), nnp::Mode::setupSymmetryFunctionScaling(), nnp::Mode::setupSymmetryFunctionStatistics(), nnp::Log::silent, nnp::split(), stage, nnp::strpr(), nnp::Dataset::structures, nnp::Mode::writeSettingsFile(), nnp::settings::Settings::writeSettingsFile(), and writeWeights().
Referenced by main().
void Training::setupTraining | ( | ) |
General training settings and setup of weight update routine.
Definition at line 737 of file Training.cpp.
References allocateArrays(), nnp::appendLinesToFile(), nnp::createFileHeader(), nnp::GradientDescent::DT_ADAM, nnp::GradientDescent::DT_FIXED, nnp::Mode::elements, nnp::Training::PropertyMap::exists(), forceWeight, freeMemory, getWeights(), hasUpdaters, nnp::Mode::HDNNP_2G, nnp::Mode::HDNNP_4G, nnp::Mode::HDNNP_Q, initializeWeightsMemory(), jacobianMode, JM_FULL, JM_SUM, JM_TASK, nnp::settings::Settings::keywordExists(), nnp::KalmanFilter::KT_FADINGMEMORY, nnp::KalmanFilter::KT_STANDARD, nnp::Mode::log, nnp::Dataset::myRank, nnId, nnp::Mode::nnpType, nnp::Mode::nns, numEpochs, numUpdaters, nnp::Training::Property::numUpdates, numWeightsPerUpdater, p, parallelMode, nnp::Training::Property::patternsPerUpdateGlobal, pk, PM_TRAIN_ALL, PM_TRAIN_RK0, repeatedEnergyUpdates, nnp::Dataset::rng, nnp::Dataset::rngGlobal, rngGlobalNew, rngNew, nnp::GradientDescent::setParametersAdam(), nnp::KalmanFilter::setParametersFadingMemory(), nnp::GradientDescent::setParametersFixed(), nnp::KalmanFilter::setParametersStandard(), nnp::Mode::settings, setupFileOutput(), setupSelectionMode(), setupUpdatePlan(), stage, nnp::strpr(), sw, trainingLog, trainingLogFileName, updaters, updaterType, updateStrategy, US_COMBINED, US_ELEMENT, useForces, UT_GD, UT_KF, UT_LM, weights, and writeTrainingLog.
Referenced by main().
vector< string > Training::setupNumericDerivCheck | ( | ) |
Set up numeric weight derivatives check.
Definition at line 1209 of file Training.cpp.
References getWeights(), nnp::Mode::HDNNP_2G, nnp::Mode::HDNNP_4G, nnp::Mode::HDNNP_Q, initializeWeightsMemory(), nnp::Mode::log, nnId, nnp::Mode::nnpType, p, pk, nnp::Mode::readNeuralNetworkWeights(), and stage.
Referenced by main().
void Training::calculateNeighborLists | ( | ) |
Calculate neighbor lists for all structures.
Definition at line 1247 of file Training.cpp.
References nnp::Mode::convLength, nnp::Mode::cutoffs, nnp::Mode::ewaldSetup, nnp::ScreeningFunction::getOuter(), nnp::Mode::HDNNP_4G, nnp::Mode::log, nnp::Mode::maxCutoffRadius, nnp::Mode::nnpType, nnp::Mode::normalize, nnp::Mode::screeningFunction, nnp::strpr(), nnp::Dataset::structures, and sw.
Referenced by main().
void Training::calculateError | ( | std::map< std::string, std::pair< std::string, std::string > > const | fileNames | ) |
Calculate error metrics for all structures.
[in] | fileNames | Map of properties to file names for training/test comparison files. |
If fileNames map is empty, no files will be written.
Definition at line 1310 of file Training.cpp.
References nnp::appendLinesToFile(), nnp::Mode::calculateAtomicNeuralNetworks(), nnp::Mode::calculateEnergy(), nnp::Mode::calculateForces(), nnp::Mode::calculateSymmetryFunctionGroups(), nnp::Mode::calculateSymmetryFunctions(), nnp::Mode::chargeEquilibration(), nnp::Dataset::collectError(), nnp::Dataset::combineFiles(), nnp::Dataset::comm, nnp::createFileHeader(), freeMemory, nnp::Mode::HDNNP_4G, nnp::Mode::maxCutoffRadius, nnp::Dataset::myRank, nnId, nnp::Mode::nnpType, p, pk, nnp::Structure::ST_TEST, nnp::Structure::ST_TRAINING, stage, nnp::strpr(), nnp::Dataset::structures, and useForces.
Referenced by calculateErrorEpoch().
void Training::calculateErrorEpoch | ( | ) |
Calculate error metrics per epoch for all structures with file names used in training loop.
Also write training curve to file.
Definition at line 1515 of file Training.cpp.
References calculateError(), d, epoch, p, and nnp::strpr().
Referenced by loop().
void Training::calculateChargeErrorVec | ( | Structure const & | s, |
Eigen::VectorXd & | cVec, | ||
double & | cNorm | ||
) |
Calculate vector of charge errors in one structure.
[in] | s | Structure of interest. |
[in] | cVec | Vector to store result of charge errors. |
[in] | cNorm | Euclidean norm of the error vector. |
Definition at line 1545 of file Training.cpp.
References nnp::Structure::atoms, and nnp::Structure::numAtoms.
Referenced by update().
void Training::printHeader | ( | ) |
Print training loop header on screen.
Definition at line 1558 of file Training.cpp.
References nnp::Mode::log, p, pk, and nnp::strpr().
Referenced by loop().
void Training::printEpoch | ( | ) |
Print preferred error metric and timing information on screen.
Definition at line 1616 of file Training.cpp.
References countUpdates, epoch, nnp::Mode::log, nnp::Mode::normalize, p, nnp::Mode::physical(), pk, nnp::strpr(), and sw.
Referenced by loop().
void Training::writeWeights | ( | std::string const & | nnName, |
std::string const & | fileNameFormat | ||
) | const |
Write weights to files (one file for each element).
[in] | nnName | Identifier for neural network. |
[in] | fileNameFormat | String with file name format. |
Definition at line 1662 of file Training.cpp.
References nnp::Mode::elements, nnp::Mode::numElements, and nnp::strpr().
Referenced by dataSetNormalization(), main(), and writeWeightsEpoch().
void Training::writeWeightsEpoch | ( | ) | const |
Write weights to files during training loop.
Definition at line 1679 of file Training.cpp.
References epoch, nnp::Mode::HDNNP_2G, nnp::Mode::HDNNP_4G, nnp::Mode::HDNNP_Q, nnId, nnp::Mode::nnpType, stage, nnp::strpr(), writeWeights(), writeWeightsAlways, and writeWeightsEvery.
Referenced by loop().
void Training::writeHardness | ( | std::string const & | fileNameFormat | ) | const |
Write hardness to files (one file for each element).
[in] | fileNameFormat | String with file name format. |
Definition at line 1702 of file Training.cpp.
References nnp::Mode::elements, nnp::Mode::normalize, nnp::Mode::numElements, nnp::Mode::physical(), and nnp::strpr().
Referenced by writeHardnessEpoch().
void Training::writeHardnessEpoch | ( | ) | const |
Write hardness to files during training loop.
Definition at line 1720 of file Training.cpp.
References epoch, nnp::Mode::HDNNP_4G, nnp::Mode::nnpType, stage, nnp::strpr(), writeHardness(), writeWeightsAlways, and writeWeightsEvery.
Referenced by loop().
void Training::writeLearningCurve | ( | bool | append, |
std::string const | fileName = "learning-curve.out" |
||
) | const |
Write current RMSEs and epoch information to file.
[in] | append | If true, append to file, otherwise create new file. |
[in] | fileName | File name for learning curve file. |
Definition at line 1734 of file Training.cpp.
References nnp::appendLinesToFile(), nnp::createFileHeader(), epoch, nnp::Mode::HDNNP_4G, nnp::Mode::HDNNP_Q, nnp::Mode::nnpType, nnp::Mode::normalize, p, nnp::Mode::physical(), pk, stage, and nnp::strpr().
Referenced by loop().
void Training::writeNeuronStatistics | ( | std::string const & | nnName, |
std::string const & | fileName | ||
) | const |
Write neuron statistics collected since last invocation.
[in] | nnName | Identifier of neural network to process. |
[in] | fileName | File name for statistics file. |
Definition at line 1844 of file Training.cpp.
References nnp::appendLinesToFile(), nnp::Dataset::comm, nnp::createFileHeader(), nnp::Mode::elements, nnp::Dataset::myRank, nnp::Mode::numElements, and nnp::strpr().
Referenced by writeNeuronStatisticsEpoch().
void Training::writeNeuronStatisticsEpoch | ( | ) | const |
Write neuron statistics during training loop.
Definition at line 1943 of file Training.cpp.
References epoch, nnp::Mode::HDNNP_4G, nnp::Mode::HDNNP_Q, nnId, nnp::Mode::nnpType, stage, nnp::strpr(), writeNeuronStatistics(), writeNeuronStatisticsAlways, and writeNeuronStatisticsEvery.
Referenced by loop().
void Training::resetNeuronStatistics | ( | ) |
Reset neuron statistics for all elements.
Definition at line 1962 of file Training.cpp.
References nnp::Mode::elements.
Referenced by loop().
void Training::writeUpdaterStatus | ( | bool | append, |
std::string const | fileNameFormat = "updater.%03zu.out" |
||
) | const |
Write updater information to file.
[in] | append | If true, append to file, otherwise create new file. |
[in] | fileNameFormat | String with file name format. |
Definition at line 1972 of file Training.cpp.
References nnp::appendLinesToFile(), nnp::ElementMap::atomicNumber(), nnp::Mode::elementMap, epoch, nnp::Mode::HDNNP_4G, nnp::Mode::HDNNP_Q, nnp::Mode::nnpType, numUpdaters, stage, nnp::strpr(), updaters, updateStrategy, US_COMBINED, and US_ELEMENT.
Referenced by loop().
void Training::sortUpdateCandidates | ( | std::string const & | property | ) |
Sort update candidates with descending RMSE.
[in] | property | Training property. |
Definition at line 2008 of file Training.cpp.
References nnp::Structure::atoms, nnp::Structure::energy, nnp::Structure::energyRef, nnp::Atom::f, nnp::Atom::fRef, nnp::Structure::numAtoms, p, and nnp::Dataset::structures.
Referenced by loop().
void Training::shuffleUpdateCandidates | ( | std::string const & | property | ) |
Shuffle update candidates.
[in] | property | Training property. |
Definition at line 2062 of file Training.cpp.
Referenced by loop().
void Training::checkSelectionMode | ( | ) |
Check if selection mode should be changed.
Definition at line 2114 of file Training.cpp.
References epoch, nnp::Mode::log, p, pk, SM_RANDOM, SM_SORT, SM_THRESHOLD, and nnp::strpr().
Referenced by loop().
void Training::loop | ( | ) |
Execute main training loop.
Definition at line 2147 of file Training.cpp.
References advance(), calculateErrorEpoch(), checkSelectionMode(), epoch, epochSchedule, nnp::Mode::log, nnp::Dataset::myRank, p, pk, printEpoch(), printHeader(), resetNeuronStatistics(), setEpochSchedule(), shuffleUpdateCandidates(), SM_SORT, sortUpdateCandidates(), nnp::strpr(), sw, update(), writeHardnessEpoch(), writeLearningCurve(), writeNeuronStatisticsEpoch(), writeTimingData(), writeUpdaterStatus(), and writeWeightsEpoch().
Referenced by main().
void Training::setEpochSchedule | ( | ) |
Select energies/forces schedule for one epoch.
Definition at line 2086 of file Training.cpp.
References epochSchedule, p, pk, and rngGlobalNew.
Referenced by loop().
void Training::update | ( | std::string const & | property | ) |
Perform one update.
[in] | property | Training property to use for update. |
Definition at line 2256 of file Training.cpp.
References nnp::Training::SubCandidate::a, addTrainingLogEntry(), nnp::Structure::atoms, nnp::Training::SubCandidate::c, nnp::Mode::calculateAtomicNeuralNetworks(), calculateChargeErrorVec(), nnp::NeuralNetwork::calculateDEdc(), nnp::NeuralNetwork::calculateDEdG(), nnp::NeuralNetwork::calculateDFdc(), nnp::Structure::calculateDQdChi(), nnp::Structure::calculateDQdJ(), nnp::Structure::calculateDQdr(), nnp::Mode::calculateEnergy(), nnp::Mode::calculateForces(), nnp::Mode::calculateSymmetryFunctionGroups(), nnp::Mode::calculateSymmetryFunctions(), nnp::Atom::charge, nnp::Mode::chargeEquilibration(), nnp::Atom::chargeRef, nnp::Atom::chi, nnp::Structure::clearElectrostatics(), collectDGdxia(), nnp::Dataset::comm, nnp::Training::Property::countGroupedSubCand, nnp::Training::Property::countUpdates, countUpdates, nnp::Atom::dChidG, dGdxia, nnp::Atom::element, nnp::Mode::elements, nnp::Structure::energy, nnp::Structure::energyRef, nnp::Training::Property::epochFraction, nnp::Training::Property::error, nnp::Training::Property::errorsPerTask, nnp::Training::Property::errorTrain, nnp::Atom::f, forceWeight, nnp::Structure::freeAtoms(), freeMemory, nnp::Atom::fRef, nnp::Atom::G, nnp::NeuralNetwork::getOutput(), nnp::Structure::hasAMatrix, nnp::Structure::hasCharges, nnp::Mode::HDNNP_2G, nnp::Mode::HDNNP_4G, nnp::Mode::HDNNP_Q, nnp::Training::Property::jacobian, jacobianMode, JM_FULL, JM_SUM, JM_TASK, nnp::Mode::maxCutoffRadius, MPI_SIZE_T, nnp::Dataset::myRank, nnId, nnp::Mode::nnpType, nnp::Mode::normalize, nnp::Mode::normalized(), nnp::Structure::numAtoms, nnp::Structure::numAtomsPerElement, nnp::Mode::numElements, nnp::Training::Property::numGroupedSubCand, nnp::Atom::numNeighbors, nnp::Atom::numNeighborsPerElement, nnp::Dataset::numProcs, numUpdaters, numWeightsPerUpdater, nnp::Training::Property::offsetJacobian, nnp::Training::Property::offsetPerTask, p, parallelMode, nnp::Training::Property::patternsPerUpdate, PM_TRAIN_ALL, PM_TRAIN_RK0, nnp::Training::UpdateCandidate::posSubCandidates, nnp::Training::Property::posUpdateCandidates, nnp::NeuralNetwork::propagate(), nnp::Training::Property::rmseThreshold, nnp::Training::Property::rmseThresholdTrials, nnp::Training::UpdateCandidate::s, nnp::Training::Property::selectionMode, nnp::NeuralNetwork::setInput(), nnp::KalmanFilter::setSizeObservation(), setWeights(), SM_RANDOM, SM_SORT, SM_THRESHOLD, nnp::Dataset::structures, nnp::Training::UpdateCandidate::subCandidates, sw, nnp::Training::Property::taskBatchSize, nnp::Training::Property::updateCandidates, updaters, updaterType, updateStrategy, US_COMBINED, US_ELEMENT, UT_KF, weights, weightsOffset, nnp::Training::Property::weightsPerTask, and writeTrainingLog.
Referenced by loop().
double Training::getSingleWeight | ( | std::size_t | element, |
std::size_t | index | ||
) |
Get a single weight value.
[in] | element | Element index of weight. |
[in] | index | Weight index. |
Note: This function is implemented for testing purposes and works correctly only with update strategy US_ELEMENT.
Definition at line 3158 of file Training.cpp.
References getWeights(), and weights.
void Training::setSingleWeight | ( | std::size_t | element, |
std::size_t | index, | ||
double | value | ||
) |
Set a single weight value.
[in] | element | Element index of weight. |
[in] | index | Weight index. |
[in] | value | Weight value. |
Note: This function is implemented for testing purposes and works correctly only with update strategy US_ELEMENT.
Definition at line 3165 of file Training.cpp.
References setWeights(), and weights.
vector< vector< double > > Training::calculateWeightDerivatives | ( | Structure * | structure | ) |
Calculate derivatives of energy with respect to weights.
[in,out] | structure | Structure to process. |
Definition at line 3174 of file Training.cpp.
References nnp::Structure::atoms, nnp::NeuralNetwork::calculateDEdc(), nnp::Mode::calculateSymmetryFunctionGroups(), nnp::Mode::calculateSymmetryFunctions(), nnp::Mode::elements, nnp::NeuralNetwork::getOutput(), nnp::Mode::numElements, nnp::NeuralNetwork::propagate(), and nnp::NeuralNetwork::setInput().
vector< vector< double > > Training::calculateWeightDerivatives | ( | Structure * | structure, |
std::size_t | atom, | ||
std::size_t | component | ||
) |
Calculate derivatives of force with respect to weights.
[in,out] | structure | Structure to process. |
[in] | atom | Atom index. |
[in] | component | x, y or z-component of force (0, 1, 2). |
Definition at line 3214 of file Training.cpp.
References nnp::Structure::atoms, nnp::NeuralNetwork::calculateDFdc(), nnp::Mode::calculateSymmetryFunctionGroups(), nnp::Mode::calculateSymmetryFunctions(), collectDGdxia(), dGdxia, nnp::Mode::elements, nnp::NeuralNetwork::getOutput(), nnp::Mode::maxCutoffRadius, nnp::Mode::numElements, nnp::NeuralNetwork::propagate(), and nnp::NeuralNetwork::setInput().
void Training::setTrainingLogFileName | ( | std::string | fileName | ) |
Set training log file name.
[in] | fileName | File name for training log. |
Definition at line 3265 of file Training.cpp.
References trainingLogFileName.
size_t Training::getNumConnections | ( | std::string | id = "short" | ) | const |
Get total number of NN connections.
[in] | id | NN ID to use (e.g. "short"). |
Definition at line 3272 of file Training.cpp.
References nnp::Mode::elements.
Referenced by dPdc().
vector< size_t > Training::getNumConnectionsPerElement | ( | std::string | id = "short" | ) | const |
Get number of NN connections for each element.
[in] | id | NN ID to use (e.g. "short"). |
Definition at line 3283 of file Training.cpp.
References nnp::Mode::elements.
Referenced by dPdc(), and dPdcN().
vector< size_t > Training::getConnectionOffsets | ( | std::string | id = "short" | ) | const |
Get offsets of NN connections for each element.
[in] | id | NN ID to use (e.g. "short"). |
Definition at line 3294 of file Training.cpp.
References nnp::Mode::elements.
Referenced by dPdc(), and dPdcN().
void Training::dPdc | ( | std::string | property, |
Structure & | structure, | ||
std::vector< std::vector< double > > & | dEdc | ||
) |
Compute derivatives of property with respect to weights.
[in] | property | Training property for which derivatives should be computed. |
[in] | structure | The structure under investigation. |
[in,out] | dEdc | Weight derivative array (first index = property, second index = weight). |
Definition at line 3307 of file Training.cpp.
References nnp::Structure::atoms, nnp::NeuralNetwork::calculateDEdc(), nnp::NeuralNetwork::calculateDEdG(), nnp::NeuralNetwork::calculateDFdc(), collectDGdxia(), dGdxia, dPdc(), nnp::Mode::elements, getConnectionOffsets(), getNumConnections(), getNumConnectionsPerElement(), nnp::NeuralNetwork::getOutput(), nnId, nnp::Structure::numAtoms, nnp::NeuralNetwork::propagate(), and nnp::NeuralNetwork::setInput().
Referenced by dPdc(), dPdcN(), and main().
void Training::dPdcN | ( | std::string | property, |
Structure & | structure, | ||
std::vector< std::vector< double > > & | dEdc, | ||
double | delta = 1.0E-4 |
||
) |
Compute numeric derivatives of property with respect to weights.
[in] | property | Training property for which derivatives should be computed. |
[in] | structure | The structure under investigation. |
[in,out] | dEdc | Weight derivative array (first index = property, second index = weight). |
[in] | delta | Delta for central difference. |
Definition at line 3379 of file Training.cpp.
References nnp::Structure::atoms, nnp::Mode::calculateAtomicNeuralNetworks(), nnp::Mode::calculateEnergy(), nnp::Mode::calculateForces(), dPdc(), nnp::Structure::energy, getConnectionOffsets(), getNumConnectionsPerElement(), nnp::Structure::numAtoms, nnp::Mode::numElements, setWeights(), and weights.
Referenced by main().
|
private |
Check if training loop should be continued.
Definition at line 3461 of file Training.cpp.
References epoch, and numEpochs.
Referenced by loop().
|
private |
Get weights from neural network class.
Definition at line 3467 of file Training.cpp.
References nnp::Mode::elements, nnp::NeuralNetwork::getConnections(), nnp::NeuralNetwork::getNumConnections(), nnp::Mode::HDNNP_4G, nnId, nnp::Mode::nnpType, nnp::Mode::numElements, stage, updateStrategy, US_COMBINED, US_ELEMENT, and weights.
Referenced by getSingleWeight(), setupNumericDerivCheck(), and setupTraining().
|
private |
Set weights in neural network class.
Definition at line 3498 of file Training.cpp.
References nnp::Mode::elements, nnp::NeuralNetwork::getNumConnections(), nnp::Mode::HDNNP_4G, nnId, nnp::Mode::nnpType, nnp::Mode::numElements, nnp::NeuralNetwork::setConnections(), stage, updateStrategy, US_COMBINED, US_ELEMENT, and weights.
Referenced by dPdcN(), setSingleWeight(), and update().
|
private |
Write energy update data to training log file.
[in] | proc | Processor which provided update candidate. |
[in] | il | Loop index of threshold loop. |
[in] | f | RMSE fraction of update candidate. |
[in] | is | Local structure index. |
[in] | isg | Global structure index. |
Definition at line 3529 of file Training.cpp.
References countUpdates, epoch, nnp::strpr(), and trainingLog.
Referenced by update().
|
private |
Write force update data to training log file.
[in] | proc | Processor which provided update candidate. |
[in] | il | Loop index of threshold loop. |
[in] | f | RMSE fraction of update candidate. |
[in] | is | Local structure index. |
[in] | isg | Global structure index. |
[in] | ia | Atom index. |
[in] | ic | Component index. |
Definition at line 3543 of file Training.cpp.
References countUpdates, epoch, nnp::strpr(), and trainingLog.
|
private |
Write charge update data to training log file.
[in] | proc | Processor which provided update candidate. |
[in] | il | Loop index of threshold loop. |
[in] | f | RMSE fraction of update candidate. |
[in] | is | Local structure index. |
[in] | isg | Global structure index. |
[in] | ia | Atom index. |
Definition at line 3559 of file Training.cpp.
References countUpdates, epoch, nnp::strpr(), and trainingLog.
|
private |
Collect derivative of symmetry functions with respect to one atom's coordinate.
[in] | atom | The atom which owns the symmetry functions. |
[in] | indexAtom | The index \(i\) of the atom requested. |
[in] | indexComponent | The component \(\alpha\) of the atom requested. |
This calculates an array of derivatives
\[ \left(\frac{\partial G_1}{\partial x_{i,\alpha}}, \ldots, \frac{\partial G_n}{\partial x_{i,\alpha}}\right), \]
where \(\{G_j\}_{j=1,\ldots,n}\) are the symmetry functions for this atom and \(x_{i,\alpha}\) is the \(\alpha\)-component of the position of atom \(i\). The result is stored in dGdxia.
Definition at line 3574 of file Training.cpp.
References nnp::Atom::Neighbor::dGdr, nnp::Atom::dGdr, dGdxia, nnp::Atom::Neighbor::element, nnp::Atom::element, nnp::Mode::elements, nnp::Mode::HDNNP_4G, nnp::Atom::index, nnp::Atom::neighbors, nnp::Mode::nnpType, nnp::Atom::numNeighbors, and nnp::Atom::numSymmetryFunctions.
Referenced by calculateWeightDerivatives(), dPdc(), and update().
|
private |
Randomly initialize specificy neural network weights.
[in] | id | Actual network type to initialize ("short" or "elec"). |
Definition at line 3616 of file Training.cpp.
References nnp::Mode::elements, nnp::NeuralNetwork::getNumConnections(), nnp::settings::Settings::keywordExists(), nnp::Mode::log, nnp::NeuralNetwork::modifyConnections(), nnp::NeuralNetwork::MS_GLOROTBENGIO, nnp::NeuralNetwork::MS_NGUYENWIDROW, nnp::NeuralNetwork::MS_ZEROBIAS, nnp::Mode::nns, nnp::Mode::numElements, nnp::Dataset::rngGlobal, nnp::NeuralNetwork::setConnections(), nnp::Mode::settings, and nnp::strpr().
Referenced by initializeWeights().
|
private |
Set selection mode for specific training property.
[in] | property | Training property (uses corresponding keyword). |
Definition at line 3669 of file Training.cpp.
References nnp::settings::Settings::keywordExists(), nnp::Mode::log, p, pk, nnp::Mode::settings, SM_RANDOM, SM_SORT, SM_THRESHOLD, nnp::split(), and nnp::strpr().
Referenced by setupTraining().
|
private |
Set file output intervals for properties and other quantities.
[in] | type | Training property or weights or neuron-stats . |
Definition at line 3777 of file Training.cpp.
References nnp::settings::Settings::keywordExists(), nnp::Mode::log, p, pk, nnp::reduce(), nnp::Mode::settings, nnp::split(), nnp::strpr(), writeNeuronStatisticsAlways, writeNeuronStatisticsEvery, writeWeightsAlways, and writeWeightsEvery.
Referenced by setupTraining().
|
private |
Set up how often properties are updated.
[in] | property | Training property (uses corresponding keyword). |
Definition at line 3839 of file Training.cpp.
References nnp::Dataset::comm, nnp::Training::Property::epochFraction, nnp::Training::Property::errorsPerTask, nnp::Training::PropertyMap::exists(), jacobianMode, JM_FULL, nnp::settings::Settings::keywordExists(), nnp::Mode::log, MPI_SIZE_T, nnp::Dataset::myRank, nnp::Training::Property::numErrorsGlobal, nnp::Dataset::numProcs, nnp::Training::Property::numTrainPatterns, numUpdaters, nnp::Training::Property::numUpdates, numWeightsPerUpdater, nnp::Training::Property::offsetJacobian, nnp::Training::Property::offsetPerTask, p, nnp::Training::Property::patternsPerUpdate, nnp::Training::Property::patternsPerUpdateGlobal, pk, nnp::Mode::settings, nnp::strpr(), nnp::Training::Property::taskBatchSize, nnp::Training::Property::updateCandidates, and nnp::Training::Property::weightsPerTask.
Referenced by setupTraining().
|
private |
Allocate error and Jacobian arrays for given property.
[in] | property | Training property. |
Definition at line 3949 of file Training.cpp.
References nnp::Training::Property::error, nnp::Training::Property::errorsPerTask, nnp::Training::Property::jacobian, jacobianMode, JM_SUM, nnp::Mode::log, nnp::Dataset::myRank, nnp::Training::Property::numErrorsGlobal, numUpdaters, numWeightsPerUpdater, p, parallelMode, pk, PM_TRAIN_ALL, PM_TRAIN_RK0, and nnp::strpr().
Referenced by setupTraining().
|
private |
Write timing data for all clocks.
[in] | append | If true, append to file, otherwise create new file. |
[in] | fileName | File name for timing data file. |
Definition at line 3987 of file Training.cpp.
References nnp::appendLinesToFile(), nnp::createFileHeader(), epoch, nnp::Mode::HDNNP_4G, nnp::Mode::HDNNP_Q, nnp::Mode::nnpType, p, pk, stage, nnp::strpr(), and sw.
Referenced by loop().
|
private |
Updater type used.
Definition at line 503 of file Training.h.
Referenced by setupTraining(), update(), and ~Training().
|
private |
Parallelization mode used.
Definition at line 505 of file Training.h.
Referenced by allocateArrays(), setupTraining(), and update().
|
private |
Jacobian mode used.
Definition at line 507 of file Training.h.
Referenced by allocateArrays(), setupTraining(), setupUpdatePlan(), and update().
|
private |
Update strategy used.
Definition at line 509 of file Training.h.
Referenced by getWeights(), initializeWeightsMemory(), setupTraining(), setWeights(), update(), and writeUpdaterStatus().
|
private |
If this rank performs weight updates.
Definition at line 511 of file Training.h.
Referenced by setupTraining().
|
private |
If this rank holds structure information.
Definition at line 513 of file Training.h.
Referenced by selectSets().
|
private |
Use forces for training.
Definition at line 515 of file Training.h.
Referenced by calculateError(), and setupTraining().
|
private |
After force update perform energy update for corresponding structure.
Definition at line 517 of file Training.h.
Referenced by setupTraining().
|
private |
Free symmetry function memory after calculation.
Definition at line 519 of file Training.h.
Referenced by calculateError(), setupTraining(), and update().
|
private |
Whether training log file is written.
Definition at line 521 of file Training.h.
Referenced by setupTraining(), and update().
|
private |
Training stage.
Definition at line 523 of file Training.h.
Referenced by calculateError(), dataSetNormalization(), getWeights(), initializeWeights(), initializeWeightsMemory(), setStage(), setupNumericDerivCheck(), setupTraining(), setWeights(), writeHardnessEpoch(), writeLearningCurve(), writeNeuronStatisticsEpoch(), writeTimingData(), writeUpdaterStatus(), and writeWeightsEpoch().
|
private |
Number of updaters (depends on update strategy).
Definition at line 525 of file Training.h.
Referenced by allocateArrays(), initializeWeightsMemory(), setupTraining(), setupUpdatePlan(), update(), and writeUpdaterStatus().
|
private |
Number of epochs requested.
Definition at line 527 of file Training.h.
Referenced by advance(), and setupTraining().
|
private |
Current epoch.
Definition at line 529 of file Training.h.
Referenced by addTrainingLogEntry(), advance(), calculateErrorEpoch(), checkSelectionMode(), loop(), printEpoch(), writeHardnessEpoch(), writeLearningCurve(), writeNeuronStatisticsEpoch(), writeTimingData(), writeUpdaterStatus(), and writeWeightsEpoch().
|
private |
Write weights every this many epochs.
Definition at line 531 of file Training.h.
Referenced by setupFileOutput(), writeHardnessEpoch(), and writeWeightsEpoch().
|
private |
Up to this epoch weights are written every epoch.
Definition at line 533 of file Training.h.
Referenced by setupFileOutput(), writeHardnessEpoch(), and writeWeightsEpoch().
|
private |
Write neuron statistics every this many epochs.
Definition at line 535 of file Training.h.
Referenced by setupFileOutput(), and writeNeuronStatisticsEpoch().
|
private |
Up to this epoch neuron statistics are written every epoch.
Definition at line 537 of file Training.h.
Referenced by setupFileOutput(), and writeNeuronStatisticsEpoch().
|
private |
Update counter (for all training quantities together).
Definition at line 539 of file Training.h.
Referenced by addTrainingLogEntry(), printEpoch(), and update().
|
private |
Total number of weights.
If nnpType 4G also h = sqrt(J) (hardness) is counted.
Definition at line 542 of file Training.h.
Referenced by initializeWeightsMemory().
|
private |
Force update weight.
Definition at line 544 of file Training.h.
Referenced by setupTraining(), and update().
|
private |
File name for training log.
Definition at line 546 of file Training.h.
Referenced by setTrainingLogFileName(), and setupTraining().
|
private |
ID of neural network the training is working on.
Definition at line 548 of file Training.h.
Referenced by calculateError(), dPdc(), getWeights(), initializeWeights(), initializeWeightsMemory(), setStage(), setupNumericDerivCheck(), setupTraining(), setWeights(), update(), writeNeuronStatisticsEpoch(), and writeWeightsEpoch().
|
private |
Training log file.
Definition at line 550 of file Training.h.
Referenced by addTrainingLogEntry(), setupTraining(), and ~Training().
|
private |
Update schedule epoch (stage 1: 0 = charge update; stage 2: 0 = energy update, 1 = force update (optional)).
Definition at line 553 of file Training.h.
Referenced by loop(), and setEpochSchedule().
|
private |
Number of weights per updater.
If nnpType 4G also h = sqrt(J) is counted during stage 1 training.
Definition at line 556 of file Training.h.
Referenced by allocateArrays(), initializeWeightsMemory(), setupTraining(), setupUpdatePlan(), and update().
|
private |
Offset of each element's weights in combined array.
If nnpType 4G also h = sqrt(J) is counted.
Definition at line 559 of file Training.h.
Referenced by initializeWeightsMemory(), and update().
|
private |
Vector of actually used training properties.
Definition at line 561 of file Training.h.
Referenced by allocateArrays(), calculateError(), checkSelectionMode(), loop(), printEpoch(), printHeader(), selectSets(), setEpochSchedule(), setStage(), setupFileOutput(), setupNumericDerivCheck(), setupSelectionMode(), setupTraining(), setupUpdatePlan(), writeLearningCurve(), and writeTimingData().
|
private |
Derivative of symmetry functions with respect to one specific atom coordinate.
Definition at line 565 of file Training.h.
Referenced by calculateWeightDerivatives(), collectDGdxia(), dPdc(), and update().
|
private |
Neural network weights and biases for each element.
If nnpType 4G also h = sqrt(J) included.
Definition at line 570 of file Training.h.
Referenced by dPdcN(), getSingleWeight(), getWeights(), initializeWeightsMemory(), setSingleWeight(), setupTraining(), setWeights(), and update().
|
private |
Weight updater (combined or for each element).
Definition at line 572 of file Training.h.
Referenced by setupTraining(), update(), writeUpdaterStatus(), and ~Training().
|
private |
Stopwatches for timing overview.
Definition at line 575 of file Training.h.
Referenced by calculateNeighborLists(), loop(), printEpoch(), setupTraining(), Training(), update(), and writeTimingData().
|
private |
Per-task random number generator.
Definition at line 577 of file Training.h.
Referenced by setupTraining(), and shuffleUpdateCandidates().
|
private |
Global random number generator.
Definition at line 579 of file Training.h.
Referenced by setEpochSchedule(), and setupTraining().
|
private |
Actual training properties.
Definition at line 581 of file Training.h.
Referenced by allocateArrays(), calculateError(), calculateErrorEpoch(), checkSelectionMode(), loop(), printEpoch(), printHeader(), selectSets(), setEpochSchedule(), setStage(), setupFileOutput(), setupNumericDerivCheck(), setupSelectionMode(), setupTraining(), setupUpdatePlan(), shuffleUpdateCandidates(), sortUpdateCandidates(), update(), writeLearningCurve(), and writeTimingData().