How txie-93/cgcnn works
Main Components
• Core Library (cgcnn):
– Contains the primary modules:
• data.py: defines data loading, parsing of CIF files, CSV property mapping, and possibly dataset construction.
• model.py: implements the CGCNN neural network architecture.
– Role: encapsulate the core architecture/design (i.e., graph convolution on crystal structures).
• Command-Line Utilities:
– main.py: orchestrates the training pipeline. It handles reading a customized dataset (as described in the README), invoking the data loader, training the CGCNN model, and producing output files such as the best model checkpoint, final checkpoint, and test results.
– predict.py: loads a pre-trained model (from the pre-trained folder) and maps new crystal structure data (via CIF files and associated CSV/JSON files) to predictions.
• Data & Pre-Trained Models:
– The “data” directory holds example datasets to illustrate both classification and regression tasks.
– The “pre-trained” directory contains compressed model files (.pth.tar) which are used by predict.py.
• External Dependencies:
– Libraries such as PyTorch, scikit-learn, and pymatgen are critical to the functioning of the CGCNN modules and should be noted as part of the technical stack.
Relationships and Interactions Between Components
• Data Flow:
– User provides a “customized dataset” (with CIF files, id_prop.csv, and atom_init.json).
– The data is processed by the routines in cgcnn/data.py.
– The processed data is fed into the model architecture defined in cgcnn/model.py.
– main.py uses this pipeline to train a model and outputs checkpoint files (model_best.pth.tar and checkpoint.pth.tar) as well as test_results.csv.
– predict.py uses one of the pre-trained models (located in pre-trained) to process a new dataset and generate predictions (again outputting test_results.csv).
• Command-Line Invocation:
– Both main.py and predict.py serve as entry points: the former for training and the latter for inference.
Architectural Patterns & Design Principles
• Layered and modular design:
– Separation of concerns: Data input/processing, model definition, training/prediction logic, and evaluation/reporting.
• Pipeline Architecture:
– A clear “data → model → output” flow, reflecting a typical machine learning pipeline.
• Extensibility:
– The use of customizable datasets and the suggested possibility (in the advanced section) for writing custom PyTorch Dataset classes indicates an architecture designed for flexibility.