Git Product home page Git Product logo

xiaohang007 / slices Goto Github PK

View Code? Open in Web Editor NEW
36.0 1.0 4.0 229.81 MB

SLICES: An Invertible, Invariant, and String-based Crystal Representation (Text2Crystal)

Home Page: https://xiaohang007.github.io/SLICES/

License: GNU Lesser General Public License v2.1

Python 85.66% Shell 2.93% C 2.28% Jupyter Notebook 9.12%
crystallography deep-learning machine-learning materials-informatics materials-science smiles crystal representation

slices's Introduction

Simplified Line-Input Crystal-Encoding System

This software implementes Simplified Line-Input Crystal-Encoding System (SLICES), the first invertible and invariant crystal representation.

It has several main functionalities:

  • Encode crystal structures into SLICES strings
  • Reconstruct original crystal structures from their SLICES strings (Text2Crystal)
  • Generate crystals with desired properties using conditional RNN (Inverse Design)

Developed by Hang Xiao 2023.04 [email protected]

Nature Communications [Paper] [SLICES晶体语言视频介绍][SLICES101] [Data/Results][Source code]

We also provide a codeocean capsule (a modular container for the software environment along with code and data, that runs in a browser), allowing one-click access to guaranteed computational reproducibility of SLICES's benchmark. [Codeocean Capsule] Optional Text

Table of Contents

Installation

conda create --name slices python=3.9
conda activate slices
pip install tensorflow==2.15.0
pip install slices
#If you're in China, use this command instead: "pip install tensorflow==2.15.0 -i https://pypi.tuna.tsinghua.edu.cn/simple".
#If you're in China, use this command instead: "pip install slices -i https://pypi.tuna.tsinghua.edu.cn/simple".

Please note that this installtion method is intended for Linux operating systems like Ubuntu and CentOS. Unfortunately, SLICES is not directly compatible with Windows or MacOS due to the modified XTB binary was compiled on Linux. To run SLICES on Windows or MacOS, one can run SLICES with docker, referring to Jupyter backend setup.

If "TypeError: bases must be types" occurs when you use SLICES library, then do this:

pip install protobuf==3.20.0

If errors still occur, then you can run SLICES with docker, referring to Jupyter backend setup.

Examples

Crystal to SLICES and SLICES to crystal

Converting a crystal structure to its SLICES string and converting this SLICES string back to its original crystal structure. Suppose we wish to convert the crystal structure of NdSiRu (mp-5239,https://next-gen.materialsproject.org/materials/mp-5239?material_ids=mp-5239) to its SLICES string and converting this SLICES string back to its original crystal structure. The python code below accomplishes this:

from invcryrep.invcryrep import InvCryRep
from pymatgen.core.structure import Structure
# obtaining the pymatgen Structure instance of NdSiRu
original_structure = Structure.from_file(filename='NdSiRu.cif')
# creating an instance of the InvCryRep Class (initialization)
backend=InvCryRep()
# converting a crystal structure to its SLICES string
slices_NdSiRu=backend.structure2SLICES(original_structure) 
# converting a SLICES string back to its original crystal structure and obtaining its M3GNet_IAP-predicted energy_per_atom
reconstructed_structure,final_energy_per_atom_IAP = backend.SLICES2structure(slices_NdSiRu)
print('SLICES string of NdSiRu is: ',slices_NdSiRu)
print('\nReconstructed_structure is: ',reconstructed_structure)
print('\nfinal_energy_per_atom_IAP is: ',final_energy_per_atom_IAP,' eV/atom')
# if final_energy_per_atom_IAP is 0, it means the M3GNet_IAP refinement failed, and the reconstructed_structure is the ZL*-optimized structure.

Augment SLICES and canonicalize SLICES

Converting a crystal structure to its SLICES string and perform data augmentation (2000x), then reduce these 2000 SLICES to 1 canonical SLICES with get_canonical_SLICES.

from invcryrep.invcryrep import InvCryRep
from pymatgen.core.structure import Structure
from pymatgen.analysis.structure_matcher import StructureMatcher, ElementComparator
# obtaining the pymatgen Structure instance of Sr3Ru2O7
original_structure = Structure.from_file(filename='Sr3Ru2O7.cif')
# creating an instance of the InvCryRep Class (initialization)
backend=InvCryRep(graph_method='econnn')
# converting a crystal structure to its SLICES string and perform data augmentation (2000x)
slices_list=backend.structure2SLICESAug(structure=original_structure,num=2000) 
slices_list_unique=list(set(slices_list))
cannon_slices_list=[]
for i in slices_list_unique:
    cannon_slices_list.append(backend.get_canonical_SLICES(i))
# test get_canonical_SLICES
print(len(slices_list),len(set(cannon_slices_list)))
# 2000 SLICES generated by data augmentation has been reduced to 1 canonical SLICES

Tutorials

Jupyter backend setup

(1) Download this repo and unzipped it.

(2) Put Materials Project's new API key in "APIKEY.ini".

(3) Edit "CPUs" in "slurm.conf" to set up the number of CPU threads available for the docker container.

(4) Run following commands in terminal (Linux or WSL2 Ubuntu on Win11)

# Download SLICES_docker with pre-installed SLICES and other relevant packages. 
docker pull xiaohang07/slices:v8   
# Make entrypoint_set_cpus.sh executable 
sudo chmod +x entrypoint_set_cpus_jupyter.sh
# Repalce "[]" with the absolute path of this repo's unzipped folder to setup share folder for the docker container.
docker run -it -p 8888:8888 -h workq --shm-size=0.5gb --gpus all -v /[]:/crystal xiaohang07/slices:v8 /crystal/entrypoint_set_cpus_jupyter.sh

(5) Press CTRL (or Command on Mac) and click the link that starts with http://127.0.0.1 in your terminal (highlighted in yellow in the image below). This will open the Jupyter notebook in your web browser. Click on the Tutorial_*.ipynb file to load the relevant tutorial notebook. Optional Text

Documentation

The SLICES documentation is hosted at read-the-docs.

Reproduction of benchmarks

Reproduction of benchmarks and inverse design case study using a docker image [as an example]. One can run these calculaitons without the docker environment but one need to edit the *.pbs files to make sure the job management system on your PC/HPC work.

General setup

Download this repo and unzipped it.

Put Materials Project's new API key in "APIKEY.ini".

Edit "CPUs" in "slurm.conf" to set up the number of CPU threads available for the docker container.

docker pull xiaohang07/slices:v8   # Download SLICES_docker with pre-installed SLICES and other relevant packages. 
# Make entrypoint_set_cpus.sh executable 
sudo chmod +x entrypoint_set_cpus.sh
# Repalce "[]" with the absolute path of this repo's unzipped folder to setup share folder for the docker container.
docker run  -it --privileged=true -h workq --shm-size=0.1gb  -v /[]:/crystal -w /crystal xiaohang07/slices:v8 /crystal/entrypoint_set_cpus.sh

Reconstruction benchmark for MP-20

Convert MP-20 dataset to json (cdvae/data/mp_20 at main · txie-93/cdvae. GitHub. https://github.com/txie-93/cdvae (accessed 2023-03-12))

cd /crystal/benchmark/Match_rate_MP-20/get_json/0_get_mp20_json
python 0_mp20.py

Rule out unsupported elements

cd /crystal/benchmark/Match_rate_MP-20/get_json/1_element_filter
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect.py
#After the computation are finished, running python 2_collect.py to get results.

Convert to primitive cell

cd /crystal/benchmark/Match_rate_MP-20/get_json/2_primitive_cell_conversion
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect.py
#After the computation are finished, running python 2_collect.py to get results.

Rule out crystals with low-dimensional units (e.g. molecular crystals or layered crystals)

cd /crystal/benchmark/Match_rate_MP-20/get_json/3_3d_filter
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect.py
#After the computation are finished, running python 2_collect.py to get results.

Calculate reconstruction rate of IAP-refined structures, ZL*-optimized structures, rescaled structures under strict and coarse setting.

cd /crystal/benchmark/Match_rate_MP-20/matchcheck3
python 1_ini.py
#After running python 1_ini.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect_grid_new.py
#After the computation are finished, running python 2_collect_grid_new.py to get "results_collection_matchcheck3.csv"

Calculate reconstruction rate of IAP-refined structures, ZL*-optimized structures, IAP-refined rescaled structures, rescaled structures under strict and coarse setting.

cd /crystal/benchmark/Match_rate_MP-20/matchcheck4
python 1_ini.py
#After running python 1_ini.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect_grid_new.py
#After the computation are finished, running python 2_collect_grid_new.py to get "results_collection_matchcheck4.csv"

Reproduction of Table 1: the table below illustrates the correspondence between the data in "results_collection_matchcheck4.csv" and the match rates of SLI2Cry for the filtered MP-20 dataset (40,330 crystals) presented in Table 1.

Setting Rescaled Structure 𝑍𝐿∗-Optimized Structure IAP-Refined Structure IAP-Refined Rescaled Structure
Strict std_match_sum opt_match_sum opt2_match_sum std2_match_sum
Loose std_match2_sum opt_match2_sum opt2_match2_sum std2_match2_sum

Reproduction of Table 2: the match rate of SLI2Cry for the MP-20 dataset (45,229 crystals) = opt2_match2_sum*40330/45229.

Reconstruction benchmark for MP-21-40

Download entries to build the filtered MP-21-40 dataset

cd /crystal/benchmark/Match_rate_MP-21-40/0_get_json_mp_api
python 0_mp21-40_dataset.py
!!! If “mp_api.client.core.client.MPRestError: REST query returned with error status code” occurs. The solution is:
pip install -U mp-api

Rule out crystals with low-dimensional units (e.g. molecular crystals or layered crystals) in general dataset

cd /crystal/benchmark/Match_rate_MP-21-40/0_get_json_mp_api/1_filter_prior_3d
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect.py
#After the computation are finished, running python 2_collect.py to get results.

Calculate reconstruction rate of IAP-refined structures, ZL*-optimized structures, rescaled structures under strict and coarse setting.

cd /crystal/benchmark/Match_rate_MP-21-40/matchcheck3
python 1_ini.py
#After running python 1_ini.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect_grid_new.py
#After the computation are finished, running python 2_collect_grid_new.py to get results.

Reproduction of Table S1: the table below illustrates the correspondence between the data in "results_collection_matchcheck3.csv" and the match rates of SLI2Cry for the filtered MP-21-40 dataset (23,560 crystals) presented in Table S1.

Setting Filtered MP-21-40
Strict opt2_match_sum
Loose opt2_match2_sum

Reconstruction benchmark for QMOF-21-40

Extract MOFs with 21-40 atoms per unit cells in QMOF database to build the QMOF-21-40 dataset ( Figshare: https://figshare.com/articles/dataset/QMOF_Database/13147324 Version 14)

cd /crystal/benchmark/Match_rate_QMOF-21-40/get_json/0_get_mof_json
python get_json.py

Rule out unsupported elements

cd /crystal/benchmark/Match_rate_QMOF-21-40/get_json/1_element_filter
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect.py
#After the computation are finished, running python 2_collect.py to get results.

Convert to primitive cell

cd /crystal/benchmark/Match_rate_QMOF-21-40/get_json/2_primitive_cell_conversion
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect.py
#After the computation are finished, running python 2_collect.py to get results.

Rule out crystals with low-dimensional units (e.g. molecular crystals or layered crystals)

cd /crystal/benchmark/Match_rate_QMOF-21-40/get_json/3_3d_filter
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect.py
#After the computation are finished, running python 2_collect.py to get results.

Calculate reconstruction rate of IAP-refined structures, ZL*-optimized structures, rescaled structures under strict and coarse setting.

cd /crystal/benchmark/Match_rate_QMOF-21-40/matchcheck3
python 1_ini.py
#After running python 1_ini.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect_grid_new.py
#After the computation are finished, running python 2_collect_grid_new.py to get results.

Reproduction of Table S1: the table below illustrates the correspondence between the data in "results_collection_matchcheck3.csv" and the match rates of SLI2Cry for the filtered QMOF-21-40 dataset (339 MOFs) presented in Table S1.

Setting Filtered QMOF-21-40
Strict opt2_match_sum
Loose opt2_match2_sum

Material generation benchmark

Convert MP-20 dataset to json (cdvae/data/mp_20 at main · txie-93/cdvae. GitHub. https://github.com/txie-93/cdvae (accessed 2023-03-12))

cd /crystal/benchmark/Validity_rate_ucRNN__Success_rate_cRNN/0_get_json/0_get_mp20_json
python 0_mp20.py

Rule out unsupported elements

cd /crystal/benchmark/Validity_rate_ucRNN__Success_rate_cRNN/0_get_json/1_element_filter
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect.py
#After the computation are finished, running python 2_collect.py to get results.

Convert to primitive cell

cd /crystal/benchmark/Validity_rate_ucRNN__Success_rate_cRNN/0_get_json/2_primitive_cell_conversion
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect.py
#After the computation are finished, running python 2_collect.py to get results.

Rule out crystals with low-dimensional units (e.g. molecular crystals or layered crystals)

cd /crystal/benchmark/Validity_rate_ucRNN__Success_rate_cRNN/0_get_json/3_3d_filter
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect.py
#After the computation are finished, running python 2_collect.py to get results.

Convert crystal structures in datasets to SLICES strings and conduct data augmentation

cd /crystal/benchmark/Validity_rate_ucRNN__Success_rate_cRNN/1_unconditioned_RNN/1_augmentation
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect.py
#After the computation are finished, running python 2_collect.py to get results.

Train unconditional RNN; sample 10000 SLICES strings

cd /crystal/benchmark/Validity_rate_ucRNN__Success_rate_cRNN/1_unconditioned_RNN/2_train_sample
sh 0_train_prior_model.sh

Modify ./workflow/2_sample_HTL_model_100x.py to define the number of SLICES to be sampled

sh 1_sample_in_parallel.sh
#After running sh 1_sample_in_parallel.sh, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect_clean_glob_details.py
#After the computation are finished, running python 2_collect_clean_glob_details.py to get results.

Removing duplicate edges in SLICES strings to fix the syntax error

cd /crystal/benchmark/Validity_rate_ucRNN__Success_rate_cRNN/1_unconditioned_RNN/3_fix_syntax_check
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect_clean_glob_details.py
#After the computation are finished, running python 2_collect_clean_glob_details.py to get results.

Reconstruct crystal structures from SLICES strings and calculate the number of reconstructed crystals (num_reconstructed)

cd /crystal/benchmark/Validity_rate_ucRNN__Success_rate_cRNN/1_unconditioned_RNN/4_inverse
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect_clean_glob_details.py
#After the computation are finished, running python 2_collect_clean_glob_details.py to get results.
!!! In order to address the potential memory leaks associated with M3GNet, we implemented a strategy of 
restarting the Python script at regular intervals, with a batch size of 30.
python count.py #calculate the number of reconstructed crystals (num_reconstructed)

Evaluate the compositional validity of the reconstructed crystals and calculate the number of compositionally valid reconstructed crystals (num_comp_valid)

cd /crystal/benchmark/Validity_rate_ucRNN__Success_rate_cRNN/1_unconditioned_RNN/5_check_comp_valid
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect_clean_glob_details.py
#After the computation are finished, running python 2_collect_clean_glob_details.py to get results.
python count.py # calculate the number of compositionally valid reconstructed crystals (num_comp_valid)

Evaluate the structural validity of the reconstructed crystals and calculate the number of structurally valid reconstructed crystals (num_struc_valid)

cd /crystal/benchmark/Validity_rate_ucRNN__Success_rate_cRNN/1_unconditioned_RNN/6_check_struc_validity
python 1_splitRun.py
#After running python 1_splitRun.py, the computation is only submitted to the queue, 
# not completed. To monitor the progress of the computation, use the qstat command. 
#If all tasks are marked with a status of "C", it indicates that the computation has finished.
python 2_collect_clean_glob_details.py
#After the computation are finished, running python 2_collect_clean_glob_details.py to get results.
python count.py # calculate the number of compositionally valid reconstructed crystals (num_struc_valid)

Reproduction of Table 3: Structural validity (%) = num_struc_valid/num_reconstructed*100 Compositional validity (%) = num_comp_valid/num_reconstructed*100

Citation

Please consider citing the following paper if you find our code & data useful.

@article{xiao2023invertible,
  title={An invertible, invariant crystal representation for inverse design of solid-state materials using generative deep learning},
  author={Xiao, Hang and Li, Rong and Shi, Xiaoyang and Chen, Yan and Zhu, Liangliang and Chen, Xi and Wang, Lei},
  journal={Nature Communications},
  volume={14},
  number={1},
  pages={7027},
  year={2023},
  publisher={Nature Publishing Group UK London}
}

Contact and Support

Start a new discussion thread in [Discussion], or reach out to Hang Xiao (https://www.researchgate.net/profile/Hang-Xiao-8) [email protected] if you have any questions.

slices's People

Contributors

xiaohang007 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

slices's Issues

Output "ERROR - could not deal with graph with rank H1(X,Z) < 3"

Hi,

Thanks for the interesting work. I'm trying to generate slices with pymatgen structure as input. I noticed that in line 527 of invcryrep.py, it will print "ERROR - could not deal with graph with rank H1(X,Z) < 3". But that's not an error actually and I can still generate the corresponding slices. So I'm wondering why it matters to determine whether the rank of the graph is smaller than 3; even though a 3D embedding cannot be generated, I don't find such embeddings useful for building the slices representation.

Looking forward to hearing from you!

Error when I run on mac

Hello,

This is really great work! Excited to use slices. When I try to run on mac, this line:

reconstructed_structure,final_energy_per_atom_IAP = backend.SLICES2structure(slices_NdSiRu)

Gives me the following error. Do you have any suggestions on what to do?


FileNotFoundError Traceback (most recent call last)
Cell In[6], line 1
----> 1 reconstructed_structure,final_energy_per_atom_IAP = backend.SLICES2structure(slices_NdSiRu)

File ~/anaconda3/envs/htejk/lib/python3.11/site-packages/invcryrep/invcryrep.py:1815, in InvCryRep.SLICES2structure(self, SLICES, strategy)
1805 """Convert a SLICES string back to its original crystal structure.
1806
1807 Args:
(...)
1812 float: Energy per atom predicted with M3GNet.
1813 """
1814 self.from_SLICES(SLICES,strategy)
-> 1815 structures,final_energy_per_atom = self.to_structures()
1816 return structures[-1],final_energy_per_atom

File ~/anaconda3/envs/htejk/lib/python3.11/site-packages/invcryrep/invcryrep.py:1711, in InvCryRep.to_structures(self, bond_scaling, delta_theta, delta_x, lattice_shrink, lattice_expand, angle_weight, vbond_param_ave_covered, vbond_param_ave, repul)
1709 inner_p_target, colattice_inds, colattice_weights = self.get_inner_p_target_debug(bond_scaling)
1710 else:
-> 1711 inner_p_target, colattice_inds, colattice_weights = self.get_inner_p_target(bond_scaling)
1712 uncovered_pair = self.get_uncovered_pair(net.graph)
1713 uncovered_pair_lj = self.get_uncovered_pair_lj(uncovered_pair)

File ~/anaconda3/envs/htejk/lib/python3.11/site-packages/invcryrep/invcryrep.py:1128, in InvCryRep.get_inner_p_target(self, bond_scaling)
1113 """ Get inner product matrix, colattice indices, colattice weights.
1114
1115 (1) Get inner_p_target(inner_p matrix obtained by gfnff).
(...)
1125 list: Colattice weights.
1126 """
1127 nbf, blist = self.get_nbf_blist()
-> 1128 temp_dir = tempfile.TemporaryDirectory(dir="/dev/shm")
1129 try:
1130 with open(temp_dir.name+'/testBonds_cut.top','w') as f:

File ~/anaconda3/envs/htejk/lib/python3.11/tempfile.py:854, in TemporaryDirectory.init(self, suffix, prefix, dir, ignore_cleanup_errors)
852 def init(self, suffix=None, prefix=None, dir=None,
853 ignore_cleanup_errors=False):
--> 854 self.name = mkdtemp(suffix, prefix, dir)
855 self._ignore_cleanup_errors = ignore_cleanup_errors
856 self._finalizer = _weakref.finalize(
857 self, self._cleanup, self.name,
858 warn_message="Implicitly cleaning up {!r}".format(self),
859 ignore_errors=self._ignore_cleanup_errors)

File ~/anaconda3/envs/htejk/lib/python3.11/tempfile.py:368, in mkdtemp(suffix, prefix, dir)
366 _sys.audit("tempfile.mkdtemp", file)
367 try:
--> 368 _os.mkdir(file, 0o700)
369 except FileExistsError:
370 continue # try again

FileNotFoundError: [Errno 2] No such file or directory: '/dev/shm/tmpp6dvrbq7'

fail to load the backend

Hi, xiaohang. This is an great research and we want to using that to do some machine learning project to follow up. When I try to using SLICES following the tutorial, the install is success. But when I try to follow the examples, an error occur. Here is the command I use and the error massage, It seems that in the folder of models, no acceptable files format for the weights could be found.
`from invcryrep.utils import temporaryWorkingDirectory

from invcryrep.invcryrep import InvCryRep

from pymatgen.core.structure import Structure

with temporaryWorkingDirectory("/home/zhudan/Desktop/chengxi/temp"):

# obtaining the pymatgen Structure instance of NdSiRu

original_structure = Structure.from_file(filename='/home/zhudan/Desktop/chengxi/test.cif')

# creating an instance of the InvCryRep Class (initialization)

backend=InvCryRep()

# converting a crystal structure to its SLICES string

slices_NdSiRu=backend.structure2SLICES(original_structure)

# converting a SLICES string back to its original crystal structure and obtaining its M3GNet_IAP-predicted energy_per_atom

reconstructed_structure,final_energy_per_atom_IAP = backend.SLICES2structure(slices_NdSiRu)

print('SLICES string of NdSiRu is: ',slices_NdSiRu)

print('\nOriginal_structure is: ',original_structure)

print('\nReconstructed_structure is: ',reconstructed_structure)

print('\nfinal_energy_per_atom_IAP is: ',final_energy_per_atom_IAP,' eV/atom')` 

`Traceback (most recent call last):
File "/home/zhudan/Desktop/chengxi_mace/pythonProject/main.py", line 9, in
backend=InvCryRep()

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/invcryrep/invcryrep.py", line 112, in init
self.relaxer = Relaxer(optimizer=optimizer)

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/m3gnet/models/_dynamics.py", line 122, in init
potential = Potential(M3GNet.load())

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/m3gnet/models/_m3gnet.py", line 363, in load
return cls.load(os.path.join(CWD, model_name))

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/m3gnet/models/_m3gnet.py", line 367, in load
return cls.from_dir(model_name)

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/m3gnet/models/_m3gnet.py", line 336, in from_dir
model.load_weights(model_name)

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler
raise e.with_traceback(filtered_tb) from None

File "/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/keras/src/saving/saving_api.py", line 237, in load_weights
raise ValueError(
ValueError: File format not supported: filepath=/home/zhudan/miniconda3/envs/slices/lib/python3.9/site-packages/m3gnet/models/MP-2021.2.8-EFS/m3gnet. Keras 3 only supports V3 .keras and .weights.h5 files, or legacy V1/V2 .h5 files.
`
would you please help me?

Tokenization of SLICES strings and confusion with SMILES

Hello authors, thanks for open-sourcing this interesting work. I am interested in learning how SMILES strings can be tokenized for various language models. I was looking under HTS to understand how the RNN was trained on SLICES strings. However, all the code seems to be referring to SMILES strings. To clarify, is the code designed to operate on SMILES or SLICES data? Appreciate your clarification.

The paper states that the RNN is trained on SLICES strings, so I assume the approach here applies to that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.