Update Colvars library to version 2023-05-01
This update consists exclusively of bugfixes or maintenance-related changes. The following is a list of pull requests in the Colvars repository since the previous update to LAMMPS: - 532 Add XYZ trajectory reading feature https://github.com/Colvars/colvars/pull/532 (@jhenin, @giacomofiorin) - 531 Delete objects quietly, unless explicitly requested via script (including VMD) https://github.com/Colvars/colvars/pull/531 (@giacomofiorin) - 530 Append newline to log and error messages if not already present https://github.com/Colvars/colvars/pull/530 (@giacomofiorin) - 528 Forward-declare OpenMP lock https://github.com/Colvars/colvars/pull/528 (@giacomofiorin) - 527 Remove unneeded STL container https://github.com/Colvars/colvars/pull/527 (@giacomofiorin) - 526 Allow collecting configuration files and strings before setting up interface https://github.com/Colvars/colvars/pull/526 (@giacomofiorin, @jhenin) - 523 Fallback to linearCombination when customFunction is missing in customColvar https://github.com/Colvars/colvars/pull/523 (@HanatoK, @giacomofiorin) - 522 Use iostream::fail() to check for I/O error https://github.com/Colvars/colvars/pull/522 (@jhenin) - 520 Fix ref count https://github.com/Colvars/colvars/pull/520 (@giacomofiorin) - 513 Set target temperature through a common code path https://github.com/Colvars/colvars/pull/513 (@giacomofiorin, @jhenin) - 509 Safer detection of Windows with recent Microsoft Visual Studio versions https://github.com/Colvars/colvars/pull/509 (@akohlmey) - 508 Update LAMMPS patching method to reflect Lepton availability https://github.com/Colvars/colvars/pull/508 (@giacomofiorin) - 497 Increase the precision of write_multicol https://github.com/Colvars/colvars/pull/497 (@HanatoK) - 496 Only perform MTS automatic enable/disable for timeStepFactor > 1 https://github.com/Colvars/colvars/pull/496 (@giacomofiorin) - 493 Remove unused branch of quaternion input function https://github.com/Colvars/colvars/pull/493 (@giacomofiorin) - 489 Ensure there are spaces between the fields in the header https://github.com/Colvars/colvars/pull/489 (@HanatoK) - 487 Use map of output streams, and return references to its elements https://github.com/Colvars/colvars/pull/487 (@giacomofiorin, @jhenin) - 486 Remember first step of moving restraint https://github.com/Colvars/colvars/pull/486 (@jhenin) - 485 Add decoupling option for moving restraints https://github.com/Colvars/colvars/pull/485 (@jhenin) - 483 Update Lepton via patching procedure https://github.com/Colvars/colvars/pull/483 (@giacomofiorin) - 481 Make file-reading operations of input data abstractable https://github.com/Colvars/colvars/pull/481 (@giacomofiorin) Authors: @akohlmey, @giacomofiorin, @HanatoK, @jhenin
This commit is contained in:
@ -1,6 +1,19 @@
|
||||
// -*- Mode:c++; c-basic-offset: 4; -*-
|
||||
|
||||
// This file is part of the Collective Variables module (Colvars).
|
||||
// The original version of Colvars and its updates are located at:
|
||||
// https://github.com/Colvars/colvars
|
||||
// Please update all Colvars source files before making any changes.
|
||||
// If you wish to distribute your changes, please submit them to the
|
||||
// Colvars repository at GitHub.
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#if (__cplusplus >= 201103L)
|
||||
#include "colvar_neuralnetworkcompute.h"
|
||||
#include "colvarparse.h"
|
||||
#include "colvarproxy.h"
|
||||
|
||||
namespace neuralnetworkCV {
|
||||
std::map<std::string, std::pair<std::function<double(double)>, std::function<double(double)>>> activation_function_map
|
||||
@ -124,12 +137,10 @@ void denseLayer::readFromFile(const std::string& weights_file, const std::string
|
||||
m_weights.clear();
|
||||
m_biases.clear();
|
||||
std::string line;
|
||||
std::ifstream ifs_weights(weights_file.c_str());
|
||||
if (!ifs_weights) {
|
||||
throw std::runtime_error("Cannot open file " + weights_file);
|
||||
}
|
||||
colvarproxy *proxy = cvm::main()->proxy;
|
||||
auto &ifs_weights = proxy->input_stream(weights_file, "weights file");
|
||||
while (std::getline(ifs_weights, line)) {
|
||||
if (ifs_weights.bad()) {
|
||||
if (!ifs_weights) {
|
||||
throw std::runtime_error("I/O error while reading " + weights_file);
|
||||
}
|
||||
std::vector<std::string> splitted_data;
|
||||
@ -146,13 +157,12 @@ void denseLayer::readFromFile(const std::string& weights_file, const std::string
|
||||
m_weights.push_back(weights_tmp);
|
||||
}
|
||||
}
|
||||
proxy->close_input_stream(weights_file);
|
||||
|
||||
// parse biases file
|
||||
std::ifstream ifs_biases(biases_file.c_str());
|
||||
if (!ifs_biases) {
|
||||
throw std::runtime_error("Cannot open file " + biases_file);
|
||||
}
|
||||
auto &ifs_biases = proxy->input_stream(biases_file, "biases file");
|
||||
while (std::getline(ifs_biases, line)) {
|
||||
if (ifs_biases.bad()) {
|
||||
if (!ifs_biases) {
|
||||
throw std::runtime_error("I/O error while reading " + biases_file);
|
||||
}
|
||||
std::vector<std::string> splitted_data;
|
||||
@ -167,6 +177,8 @@ void denseLayer::readFromFile(const std::string& weights_file, const std::string
|
||||
m_biases.push_back(bias);
|
||||
}
|
||||
}
|
||||
proxy->close_input_stream(biases_file);
|
||||
|
||||
m_input_size = m_weights[0].size();
|
||||
m_output_size = m_weights.size();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user