From 9528a5a7e7ae8919c9f888f59c71928a97ea1d59 Mon Sep 17 00:00:00 2001 From: denghuilu Date: Mon, 12 Oct 2020 21:46:09 +0800 Subject: [PATCH 1/3] fix bug of std:: string incompatible with TensorFlow 2.3 --- source/lib/include/common.h | 8 ++++++++ source/lib/src/DataModifier.cc | 2 +- source/lib/src/DeepTensor.cc | 2 +- source/lib/src/NNPInter.cc | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/source/lib/include/common.h b/source/lib/include/common.h index 3912f21f7f..620c88eb6f 100644 --- a/source/lib/include/common.h +++ b/source/lib/include/common.h @@ -1,14 +1,22 @@ #pragma once #include "tensorflow/core/public/session.h" +#include "tensorflow/core/public/version.h" #include "tensorflow/core/platform/env.h" #include "tensorflow/core/framework/op.h" #include "tensorflow/core/framework/op_kernel.h" #include "tensorflow/core/framework/shape_inference.h" +#include using namespace tensorflow; using namespace std; +#if TF_MAJOR_VERSION >= 2 && TF_MINOR_VERSION >= 2 +typedef tensorflow::tstring STRINGTYPE; +#else +typedef std::string STRINGTYPE; +#endif + #include "NNPAtomMap.h" #include #include "version.h" diff --git a/source/lib/src/DataModifier.cc b/source/lib/src/DataModifier.cc index 65b3f85dd4..03fcd43a07 100644 --- a/source/lib/src/DataModifier.cc +++ b/source/lib/src/DataModifier.cc @@ -37,7 +37,7 @@ init (const string & model, rcut = get_scalar("descrpt_attr/rcut"); cell_size = rcut; ntypes = get_scalar("descrpt_attr/ntypes"); - model_type = get_scalar("model_attr/model_type"); + model_type = get_scalar("model_attr/model_type"); get_vector(sel_type, "model_attr/sel_type"); sort(sel_type.begin(), sel_type.end()); inited = true; diff --git a/source/lib/src/DeepTensor.cc b/source/lib/src/DeepTensor.cc index bd3a0ea138..9b9715fd0d 100644 --- a/source/lib/src/DeepTensor.cc +++ b/source/lib/src/DeepTensor.cc @@ -33,7 +33,7 @@ init (const string & model, rcut = get_scalar("descrpt_attr/rcut"); cell_size = rcut; ntypes = get_scalar("descrpt_attr/ntypes"); - model_type = get_scalar("model_attr/model_type"); + model_type = get_scalar("model_attr/model_type"); odim = get_scalar("model_attr/output_dim"); get_vector(sel_type, "model_attr/sel_type"); inited = true; diff --git a/source/lib/src/NNPInter.cc b/source/lib/src/NNPInter.cc index aea9d48c9b..c1347504bb 100644 --- a/source/lib/src/NNPInter.cc +++ b/source/lib/src/NNPInter.cc @@ -639,7 +639,7 @@ compute (ENERGYTYPE & dener, void NNPInter:: get_type_map(std::string & type_map){ - type_map = get_scalar("model_attr/tmap"); + type_map = get_scalar("model_attr/tmap"); } From 4300687deb1c498ce8c230c81d16f69f22209e25 Mon Sep 17 00:00:00 2001 From: bwang-ecnu <66714922+bwang-ecnu@users.noreply.github.com> Date: Mon, 9 Nov 2020 14:21:04 +0800 Subject: [PATCH 2/3] Update Data.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When condition “if coeff_atom_ener==1:” is established and one would like to ignore the energy_file, it seems to need to replace "coeff_atom_ener=1" with "coeff_ener=0". --- source/train/Data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/train/Data.py b/source/train/Data.py index 149c76bbe8..80b508e97d 100644 --- a/source/train/Data.py +++ b/source/train/Data.py @@ -476,7 +476,7 @@ def load_energy(self, # ignore energy_file if coeff_atom_ener == 1: ener = np.sum(atom_ener, axis = 1) - coeff_atom_ener = 1 + coeff_ener = 0 # load energy_file else: coeff_ener, ener = self.load_data(set_name, energy_file, [nframes], False) From bec05d71f032bcea83cd8c4293679fc9685c9665 Mon Sep 17 00:00:00 2001 From: bwang-ecnu <66714922+bwang-ecnu@users.noreply.github.com> Date: Fri, 13 Nov 2020 17:18:09 +0800 Subject: [PATCH 3/3] change "coeff_ener=1" to "coeff" --- source/train/Data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/train/Data.py b/source/train/Data.py index 80b508e97d..b38839a546 100644 --- a/source/train/Data.py +++ b/source/train/Data.py @@ -476,7 +476,7 @@ def load_energy(self, # ignore energy_file if coeff_atom_ener == 1: ener = np.sum(atom_ener, axis = 1) - coeff_ener = 0 + coeff_ener = 1 # load energy_file else: coeff_ener, ener = self.load_data(set_name, energy_file, [nframes], False)