Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/input.nn.recommended
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ memorize_symfunc_results # Keep symmetry function results
test_fraction 0.1 # Fraction of structures kept for testing.
force_weight 10.0 # Weight of force updates relative to energy updates.
short_energy_fraction 1.000 # Fraction of energy updates per epoch.
short_force_fraction 0.02315 # Fraction of force updates per epoch.
#short_force_fraction 0.02315 # Fraction of force updates per epoch (not necessary if force_energy_ratio given).
force_energy_ratio 10.0 # Specifies ratio between force and energy updates (ratio = updates_force / updates_energy).
short_energy_error_threshold 0.00 # RMSE threshold for energy update candidates.
short_force_error_threshold 1.00 # RMSE threshold for force update candidates.
rmse_threshold_trials 3 # Maximum number of RMSE threshold trials.
Expand Down
1 change: 1 addition & 0 deletions src/libnnp/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ map<string, shared_ptr<Settings::Key>> const createKnownKeywordsMap()
m["rmse_threshold_trials_charge" ] = "";
m["energy_fraction" ] = "";
m["force_fraction" ] = "";
m["force_energy_ratio" ] = "";
m["charge_fraction" ] = "";
m["use_old_weights_short" ] = "";
m["use_old_weights_charge" ] = "";
Expand Down
2 changes: 1 addition & 1 deletion src/libnnp/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ version:
@sed -i.bak -E "s/(N2P2_GIT_VERSION) .*/\1 \"$(GIT_VERSION)\"/" version.h
@$(eval GIT_REV = $(shell git rev-parse HEAD))
@sed -i.bak -E "s/(N2P2_GIT_REV) .*/\1 \"$(GIT_REV)\"/" version.h
@$(eval GIT_BRANCH = $(shell git rev-parse --abbrev-ref HEAD))
@$(eval GIT_BRANCH = $(subst /,_,$(shell git rev-parse --abbrev-ref HEAD)))
@sed -i.bak -E "s/(N2P2_GIT_BRANCH) .*/\1 \"$(GIT_BRANCH)\"/" version.h
@rm version.h.bak

Expand Down
31 changes: 29 additions & 2 deletions src/libnnptrain/Training.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2874,7 +2874,30 @@ void Training::setupUpdatePlan(string const& property)
// Actual property modified here.
Property& pa = p[property];
string keyword = property + "_fraction";
pa.epochFraction = atof(settings[keyword].c_str());

// Override force fraction if keyword "energy_force_ratio" is provided.
if (property == "force" &&
p.exists("energy") &&
settings.keywordExists("force_energy_ratio"))
{
double const ratio = atof(settings["force_energy_ratio"].c_str());
if (settings.keywordExists(keyword))
{
log << "WARNING: Given force fraction is ignored because "
"force/energy ratio is provided.\n";
}
log << strpr("Desired force/energy update ratio : %.6f\n",
ratio);
log << "----------------------------------------------\n";
pa.epochFraction = (p["energy"].numTrainPatterns * ratio)
/ p["force"].numTrainPatterns;
}
// Default action = read "<property>_fraction" keyword.
else
{
pa.epochFraction = atof(settings[keyword].c_str());
}

keyword = "task_batch_size_" + property;
pa.taskBatchSize = (size_t)atoi(settings[keyword].c_str());
if (pa.taskBatchSize == 0)
Expand Down Expand Up @@ -2933,8 +2956,12 @@ void Training::setupUpdatePlan(string const& property)
log << "Update plan for property \"" + property + "\":\n";
log << strpr("- Per-task batch size : %zu\n",
pa.taskBatchSize);
log << strpr("- Fraction of patterns used per epoch : %.4f\n",
log << strpr("- Fraction of patterns used per epoch : %.6f\n",
pa.epochFraction);
if (pa.numUpdates == 0)
{
log << "WARNING: No updates are planned for this property.";
}
log << strpr("- Updates per epoch : %zu\n",
pa.numUpdates);
log << strpr("- Patterns used per update (rank %3d / global) : "
Expand Down