diff --git a/docs/source/auto_examples/auto_examples_jupyter.zip b/docs/source/auto_examples/auto_examples_jupyter.zip
index 30369468..09b47500 100644
Binary files a/docs/source/auto_examples/auto_examples_jupyter.zip and b/docs/source/auto_examples/auto_examples_jupyter.zip differ
diff --git a/docs/source/auto_examples/auto_examples_python.zip b/docs/source/auto_examples/auto_examples_python.zip
index 048d87a1..17222e57 100644
Binary files a/docs/source/auto_examples/auto_examples_python.zip and b/docs/source/auto_examples/auto_examples_python.zip differ
diff --git a/docs/source/auto_examples/example_nn_Si.ipynb b/docs/source/auto_examples/example_nn_Si.ipynb
index b569df60..27752f77 100644
--- a/docs/source/auto_examples/example_nn_Si.ipynb
+++ b/docs/source/auto_examples/example_nn_Si.ipynb
@@ -125,6 +125,13 @@
"source": [
"model.save(\"./final_model.pkl\")\nloss.save_optimizer_stat(\"./optimizer_stat.pkl\")\n\nmodel.write_kim_model()"
]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "
Note
Now we have trained an NN for a single specie Si. If you have multiple species in\n your system and want to use different parameters for different species,\n take a look at the SiC_ example.
\n\n\n"
+ ]
}
],
"metadata": {
diff --git a/docs/source/auto_examples/example_nn_Si.py b/docs/source/auto_examples/example_nn_Si.py
index 864c8054..d169845e 100644
--- a/docs/source/auto_examples/example_nn_Si.py
+++ b/docs/source/auto_examples/example_nn_Si.py
@@ -141,3 +141,12 @@
loss.save_optimizer_stat("./optimizer_stat.pkl")
model.write_kim_model()
+
+
+##########################################################################################
+# .. note::
+# Now we have trained an NN for a single specie Si. If you have multiple species in
+# your system and want to use different parameters for different species,
+# take a look at the SiC_ example.
+#
+# .. _SiC: https://github.com/mjwen/kliff/blob/master/examples/eg_nn_SiC.py
diff --git a/docs/source/auto_examples/example_nn_Si.py.md5 b/docs/source/auto_examples/example_nn_Si.py.md5
index 702d4469..9b2a8f25 100644
--- a/docs/source/auto_examples/example_nn_Si.py.md5
+++ b/docs/source/auto_examples/example_nn_Si.py.md5
@@ -1 +1 @@
-99c760f443633dcf0ce755d5995447f7
\ No newline at end of file
+6baccb59d251b6e52d886f0ec66aa7ae
\ No newline at end of file
diff --git a/docs/source/auto_examples/example_nn_Si.rst b/docs/source/auto_examples/example_nn_Si.rst
index 929a71c0..c2871501 100644
--- a/docs/source/auto_examples/example_nn_Si.rst
+++ b/docs/source/auto_examples/example_nn_Si.rst
@@ -242,6 +242,8 @@ codes such as LAMMPS via the KIM API.
+
+
.. rst-class:: sphx-glr-script-out
Out:
@@ -253,10 +255,17 @@ codes such as LAMMPS via the KIM API.
+.. note::
+ Now we have trained an NN for a single specie Si. If you have multiple species in
+ your system and want to use different parameters for different species,
+ take a look at the SiC_ example.
+
+.. _SiC: https://github.com/mjwen/kliff/blob/master/examples/eg_nn_SiC.py
+
.. rst-class:: sphx-glr-timing
- **Total running time of the script:** ( 0 minutes 16.523 seconds)
+ **Total running time of the script:** ( 0 minutes 16.575 seconds)
.. _sphx_glr_download_auto_examples_example_nn_Si.py:
diff --git a/docs/source/auto_examples/example_nn_Si_codeobj.pickle b/docs/source/auto_examples/example_nn_Si_codeobj.pickle
index c31fa6ea..a3c6b2c0 100644
Binary files a/docs/source/auto_examples/example_nn_Si_codeobj.pickle and b/docs/source/auto_examples/example_nn_Si_codeobj.pickle differ
diff --git a/docs/source/auto_examples/sg_execution_times.rst b/docs/source/auto_examples/sg_execution_times.rst
index 1c8042bb..4d48b35c 100644
--- a/docs/source/auto_examples/sg_execution_times.rst
+++ b/docs/source/auto_examples/sg_execution_times.rst
@@ -5,12 +5,12 @@
Computation times
=================
-**01:57.516** total execution time for **auto_examples** files:
+**00:16.575** total execution time for **auto_examples** files:
+-----------------------------------------------------------------------------------------------+-----------+--------+
-| :ref:`sphx_glr_auto_examples_example_kim_SW_Si.py` (``example_kim_SW_Si.py``) | 01:40.195 | 0.0 MB |
+| :ref:`sphx_glr_auto_examples_example_nn_Si.py` (``example_nn_Si.py``) | 00:16.575 | 0.0 MB |
+-----------------------------------------------------------------------------------------------+-----------+--------+
-| :ref:`sphx_glr_auto_examples_example_nn_Si.py` (``example_nn_Si.py``) | 00:16.523 | 0.0 MB |
+| :ref:`sphx_glr_auto_examples_example_kim_SW_Si.py` (``example_kim_SW_Si.py``) | 00:00.000 | 0.0 MB |
+-----------------------------------------------------------------------------------------------+-----------+--------+
-| :ref:`sphx_glr_auto_examples_example_linear_regression.py` (``example_linear_regression.py``) | 00:00.798 | 0.0 MB |
+| :ref:`sphx_glr_auto_examples_example_linear_regression.py` (``example_linear_regression.py``) | 00:00.000 | 0.0 MB |
+-----------------------------------------------------------------------------------------------+-----------+--------+
diff --git a/examples/eg_nn_SiC.py b/examples/eg_nn_SiC.py
index 66906cc3..cc6b05c4 100644
--- a/examples/eg_nn_SiC.py
+++ b/examples/eg_nn_SiC.py
@@ -1,10 +1,10 @@
"""
-.. _tut_nn:
+.. _tut_nn_multi_spec:
Train a neural network potential
================================
-In this tutorial, we train a neural network (NN) potential for silicon
+In this tutorial, we train a neural network (NN) potential for SiC
"""
diff --git a/examples/example_nn_Si.py b/examples/example_nn_Si.py
index 864c8054..d169845e 100644
--- a/examples/example_nn_Si.py
+++ b/examples/example_nn_Si.py
@@ -141,3 +141,12 @@
loss.save_optimizer_stat("./optimizer_stat.pkl")
model.write_kim_model()
+
+
+##########################################################################################
+# .. note::
+# Now we have trained an NN for a single specie Si. If you have multiple species in
+# your system and want to use different parameters for different species,
+# take a look at the SiC_ example.
+#
+# .. _SiC: https://github.com/mjwen/kliff/blob/master/examples/eg_nn_SiC.py
diff --git a/kliff/calculators/calculator_torch.py b/kliff/calculators/calculator_torch.py
index 2a198999..1a73d190 100644
--- a/kliff/calculators/calculator_torch.py
+++ b/kliff/calculators/calculator_torch.py
@@ -248,7 +248,7 @@ def compute(self, batch):
for s, zeta in zeta_by_species.items():
# have no species "s" in this batch of data
- if zeta is []:
+ if not zeta: # zeta == []
continue
z_tensor = torch.stack(zeta) # convert a list of tensor to tensor
diff --git a/kliff/nn.py b/kliff/nn.py
index d0b18053..c28c4dfd 100644
--- a/kliff/nn.py
+++ b/kliff/nn.py
@@ -31,12 +31,12 @@ def forward(self, input):
shape_4D = (1, *shape, 1)
elif dim == 3:
if shape[0] != 1:
- raise Exception('Shape[0] needs to be 1 for a 3D tensor.')
+ raise Exception("Shape[0] needs to be 1 for a 3D tensor.")
shape_4D = (*shape, 1)
else:
raise Exception(
- 'Input need to be 2D or 3D tensor, but got a ' '{}D tensor.'.format(dim)
+ "Input need to be 2D or 3D tensor, but got a " "{}D tensor.".format(dim)
)
x = torch.reshape(input, shape_4D)
x = torch.transpose(x, 1, 2)
diff --git a/kliff/wrapcalculator.py b/kliff/wrapcalculator.py
index a67620a4..7c422000 100644
--- a/kliff/wrapcalculator.py
+++ b/kliff/wrapcalculator.py
@@ -41,7 +41,7 @@ def _update_params(self):
"""Write parameters to file KIM_MODEL_PARAMS + modelname, and also give its path to the
enviroment variable that has the same name: KIM_MODEL_PARAMS + modelname.
"""
- name = 'KIM_MODEL_PARAMS_' + self.params._modelname
+ name = "KIM_MODEL_PARAMS_" + self.params._modelname
self.params.echo_params(name, print_size=True)
path = os.getcwd() + os.path.sep + name
os.environ[name] = path
@@ -59,13 +59,13 @@ def _parse_edn(self, fname, keys):
Keyword in the edn format(think it as a dictionary), whose value will be returned.
"""
- with open(fname, 'r') as fin:
+ with open(fname, "r") as fin:
lines = fin.read()
parsed = edn_format.loads(lines)
values = []
for k in keys:
try:
- v = parsed[k]['source-value']
+ v = parsed[k]["source-value"]
except KeyError:
raise KeyError('Keyword "{}" not found in {}.'.format(k, self.outname))
# make it a 1D array