Showing preview only (1,364K chars total). Download the full file or copy to clipboard to get everything.
Repository: chainer/chainer-chemistry
Branch: master
Commit: efe323aa21f6
Files: 374
Total size: 1.2 MB
Directory structure:
gitextract_w32vn7wx/
├── .codecov.yml
├── .flexci/
│ ├── config.pbtxt
│ ├── gen_config.py
│ └── pytest_script.sh
├── .gitignore
├── .readthedocs.yml
├── .travis.yml
├── LICENSE
├── README.md
├── chainer_chemistry/
│ ├── __init__.py
│ ├── _version.py
│ ├── config.py
│ ├── dataset/
│ │ ├── __init__.py
│ │ ├── converters/
│ │ │ ├── __init__.py
│ │ │ ├── cgcnn_converter.py
│ │ │ ├── concat_mols.py
│ │ │ └── megnet_converter.py
│ │ ├── graph_dataset/
│ │ │ ├── __init__.py
│ │ │ ├── base_graph_data.py
│ │ │ ├── base_graph_dataset.py
│ │ │ └── feature_converters.py
│ │ ├── indexer.py
│ │ ├── indexers/
│ │ │ ├── __init__.py
│ │ │ └── numpy_tuple_dataset_feature_indexer.py
│ │ ├── networkx_preprocessors/
│ │ │ ├── base_networkx.py
│ │ │ └── reddit_coo.py
│ │ ├── parsers/
│ │ │ ├── __init__.py
│ │ │ ├── base_parser.py
│ │ │ ├── csv_file_parser.py
│ │ │ ├── data_frame_parser.py
│ │ │ ├── sdf_file_parser.py
│ │ │ └── smiles_parser.py
│ │ ├── preprocessors/
│ │ │ ├── __init__.py
│ │ │ ├── atomic_number_preprocessor.py
│ │ │ ├── base_preprocessor.py
│ │ │ ├── cgcnn_preprocessor.py
│ │ │ ├── common.py
│ │ │ ├── ecfp_preprocessor.py
│ │ │ ├── ggnn_preprocessor.py
│ │ │ ├── gin_preprocessor.py
│ │ │ ├── gnnfilm_preprocessor.py
│ │ │ ├── gwm_preprocessor.py
│ │ │ ├── megnet_preprocessor.py
│ │ │ ├── mol_preprocessor.py
│ │ │ ├── nfp_preprocessor.py
│ │ │ ├── relgat_preprocessor.py
│ │ │ ├── relgcn_preprocessor.py
│ │ │ ├── rsgcn_preprocessor.py
│ │ │ ├── schnet_preprocessor.py
│ │ │ ├── weavenet_preprocessor.py
│ │ │ ├── wle.py
│ │ │ ├── wle_atom_array_update.py
│ │ │ ├── wle_io.py
│ │ │ └── wle_util.py
│ │ ├── splitters/
│ │ │ ├── __init__.py
│ │ │ ├── base_splitter.py
│ │ │ ├── deepchem_scaffold_splitter.py
│ │ │ ├── random_splitter.py
│ │ │ ├── scaffold_splitter.py
│ │ │ ├── stratified_splitter.py
│ │ │ └── time_splitter.py
│ │ └── utils.py
│ ├── datasets/
│ │ ├── __init__.py
│ │ ├── citation_network/
│ │ │ ├── citation.py
│ │ │ ├── citeseer.py
│ │ │ └── cora.py
│ │ ├── molnet/
│ │ │ ├── __init__.py
│ │ │ ├── chembl_tasks.py
│ │ │ ├── molnet.py
│ │ │ ├── molnet_config.py
│ │ │ ├── pdbbind_time.py
│ │ │ └── toxcast_tasks.py
│ │ ├── numpy_tuple_dataset.py
│ │ ├── qm9.py
│ │ ├── reddit/
│ │ │ └── reddit.py
│ │ ├── tox21.py
│ │ └── zinc.py
│ ├── functions/
│ │ ├── __init__.py
│ │ ├── activation/
│ │ │ ├── __init__.py
│ │ │ ├── megnet_softplus.py
│ │ │ ├── shifted_softplus.py
│ │ │ └── softmax.py
│ │ ├── evaluation/
│ │ │ ├── __init__.py
│ │ │ └── r2_score.py
│ │ ├── loss/
│ │ │ ├── __init__.py
│ │ │ ├── mean_absolute_error.py
│ │ │ └── mean_squared_error.py
│ │ └── math/
│ │ ├── __init__.py
│ │ └── matmul.py
│ ├── iterators/
│ │ ├── __init__.py
│ │ ├── balanced_serial_iterator.py
│ │ └── index_iterator.py
│ ├── link_hooks/
│ │ ├── __init__.py
│ │ └── variable_monitor_link_hook.py
│ ├── links/
│ │ ├── __init__.py
│ │ ├── array/
│ │ │ ├── __init__.py
│ │ │ └── shape_transformer_to_2d.py
│ │ ├── connection/
│ │ │ ├── __init__.py
│ │ │ ├── embed_atom_id.py
│ │ │ ├── graph_linear.py
│ │ │ └── graph_mlp.py
│ │ ├── normalization/
│ │ │ ├── __init__.py
│ │ │ └── graph_batch_normalization.py
│ │ ├── readout/
│ │ │ ├── __init__.py
│ │ │ ├── cgcnn_readout.py
│ │ │ ├── general_readout.py
│ │ │ ├── ggnn_readout.py
│ │ │ ├── megnet_readout.py
│ │ │ ├── mpnn_readout.py
│ │ │ ├── nfp_readout.py
│ │ │ ├── scatter_ggnn_readout.py
│ │ │ ├── schnet_readout.py
│ │ │ └── set2set.py
│ │ ├── scaler/
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── flow_scaler.py
│ │ │ ├── max_abs_scaler.py
│ │ │ ├── min_max_scaler.py
│ │ │ └── standard_scaler.py
│ │ └── update/
│ │ ├── __init__.py
│ │ ├── cgcnn_update.py
│ │ ├── ggnn_update.py
│ │ ├── gin_update.py
│ │ ├── gnn_film_update.py
│ │ ├── megnet_update.py
│ │ ├── mpnn_update.py
│ │ ├── nfp_update.py
│ │ ├── relgat_update.py
│ │ ├── relgcn_update.py
│ │ ├── rsgcn_update.py
│ │ └── schnet_update.py
│ ├── models/
│ │ ├── __init__.py
│ │ ├── cgcnn.py
│ │ ├── cwle/
│ │ │ ├── __init__.py
│ │ │ ├── cwle_graph_conv_model.py
│ │ │ └── cwle_net.py
│ │ ├── ggnn.py
│ │ ├── gin.py
│ │ ├── gnn_film.py
│ │ ├── gwle/
│ │ │ ├── __init__.py
│ │ │ ├── gwle_graph_conv_model.py
│ │ │ └── gwle_net.py
│ │ ├── gwm/
│ │ │ ├── __init__.py
│ │ │ ├── gwm.py
│ │ │ ├── gwm_graph_conv_model.py
│ │ │ └── gwm_net.py
│ │ ├── megnet.py
│ │ ├── mlp.py
│ │ ├── mpnn.py
│ │ ├── nfp.py
│ │ ├── prediction/
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── classifier.py
│ │ │ ├── graph_conv_predictor.py
│ │ │ ├── node_classifier.py
│ │ │ ├── regressor.py
│ │ │ └── set_up_predictor.py
│ │ ├── relgat.py
│ │ ├── relgcn.py
│ │ ├── rsgcn.py
│ │ ├── schnet.py
│ │ └── weavenet.py
│ ├── saliency/
│ │ ├── __init__.py
│ │ ├── calculator/
│ │ │ ├── __init__.py
│ │ │ ├── base_calculator.py
│ │ │ ├── calculator_utils.py
│ │ │ ├── gradient_calculator.py
│ │ │ ├── integrated_gradients_calculator.py
│ │ │ └── occlusion_calculator.py
│ │ └── visualizer/
│ │ ├── __init__.py
│ │ ├── base_visualizer.py
│ │ ├── image_visualizer.py
│ │ ├── mol_visualizer.py
│ │ ├── table_visualizer.py
│ │ └── visualizer_utils.py
│ ├── training/
│ │ ├── __init__.py
│ │ └── extensions/
│ │ ├── __init__.py
│ │ ├── auto_print_report.py
│ │ ├── batch_evaluator.py
│ │ ├── prc_auc_evaluator.py
│ │ ├── r2_score_evaluator.py
│ │ └── roc_auc_evaluator.py
│ └── utils/
│ ├── __init__.py
│ ├── extend.py
│ ├── json_utils.py
│ ├── permutation.py
│ ├── sparse_utils.py
│ └── train_utils.py
├── docker/
│ ├── conda/
│ │ ├── python36/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37-chainerx-cpu-base/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37-chainerx-cpu-latest/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37-chainerx-cpu-stable/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37-chainerx-gpu-base/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37-chainerx-gpu-latest/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ └── python37-chainerx-gpu-stable/
│ │ ├── Dockerfile
│ │ └── conda-entrypoint.sh
│ └── python3/
│ └── Dockerfile
├── docs/
│ ├── Makefile
│ └── source/
│ ├── _autosummary_check.py
│ ├── conf.py
│ ├── contribution.rst
│ ├── dataset.rst
│ ├── datasets.rst
│ ├── development.rst
│ ├── environment.yml
│ ├── functions.rst
│ ├── index.rst
│ ├── install.rst
│ ├── iterators.rst
│ ├── links.rst
│ ├── models.rst
│ ├── reference.rst
│ ├── requirements.txt
│ ├── training.rst
│ ├── tutorial.rst
│ └── utils.rst
├── examples/
│ ├── .gitignore
│ ├── README.md
│ ├── molnet/
│ │ ├── README.md
│ │ ├── evaluate_models_molnet.sh
│ │ ├── predict_molnet.py
│ │ ├── summary_eval_molnet.py
│ │ ├── test_molnet.sh
│ │ └── train_molnet.py
│ ├── molnet_wle/
│ │ ├── README.md
│ │ ├── predict_molnet_wle.py
│ │ └── train_molnet_wle.py
│ ├── network_graph/
│ │ ├── README.md
│ │ ├── citeseer/
│ │ │ └── .gitignore
│ │ ├── cora/
│ │ │ └── .gitignore
│ │ ├── padding_model_wrapper.py
│ │ ├── reddit/
│ │ │ └── .gitignore
│ │ └── train_network_graph.py
│ ├── own_dataset/
│ │ ├── README.md
│ │ ├── dataset_test.csv
│ │ ├── dataset_train.csv
│ │ ├── evaluate_own_dataset.sh
│ │ ├── plot.py
│ │ ├── predict_own_dataset.py
│ │ ├── test_own_dataset.sh
│ │ └── train_own_dataset.py
│ ├── qm9/
│ │ ├── README.md
│ │ ├── evaluate_models_qm9.sh
│ │ ├── plot.py
│ │ ├── predict_qm9.py
│ │ ├── qm9_dataset_exploration.ipynb
│ │ ├── test_qm9.sh
│ │ └── train_qm9.py
│ ├── test_examples.sh
│ └── tox21/
│ ├── .gitignore
│ ├── README.md
│ ├── data.py
│ ├── evaluate_models_tox21.sh
│ ├── plot.py
│ ├── predict_tox21_with_classifier.py
│ ├── test_tox21.sh
│ ├── tox21_dataset_exploration.ipynb
│ └── train_tox21.py
├── setup.py
└── tests/
├── dataset_tests/
│ ├── parsers_tests/
│ │ ├── test_csv_file_parser.py
│ │ ├── test_data_frame_parser.py
│ │ ├── test_sdf_file_parser.py
│ │ └── test_smiles_parser.py
│ ├── preprocessor_tests/
│ │ └── test_common.py
│ ├── preprocessors_tests/
│ │ ├── test_atomic_number_preprocessor.py
│ │ ├── test_cgcnn_preprocessor.py
│ │ ├── test_gat_preprocessor.py
│ │ ├── test_ggnn_preprocessor.py
│ │ ├── test_gwm_preprocessor.py
│ │ ├── test_mol_preprocessor.py
│ │ ├── test_nfp_preprocessor.py
│ │ ├── test_relgcn_preprocessor.py
│ │ ├── test_rsgcn_preprocessor.py
│ │ ├── test_schnet_preprocessor.py
│ │ ├── test_weavenet_preprocessor.py
│ │ ├── test_wle.py
│ │ ├── test_wle_atom_array_update.py
│ │ └── test_wle_util.py
│ ├── splitters_tests/
│ │ ├── test_deepchem_scaffold_splitter.py
│ │ ├── test_random_splitter.py
│ │ ├── test_scaffold_splitter.py
│ │ ├── test_stratified_splitter.py
│ │ └── test_time_splitter.py
│ ├── test_converters.py
│ └── test_numpy_tuple_feature_indexer.py
├── datasets_tests/
│ ├── molnet_tests/
│ │ ├── test_molnet.py
│ │ └── test_pdbbind_time.py
│ ├── test_numpy_tuple_dataset.py
│ ├── test_qm9.py
│ ├── test_tox21.py
│ └── test_zinc.py
├── functions_tests/
│ ├── activation/
│ │ ├── test_megnet_softplus.py
│ │ ├── test_shifted_softplus.py
│ │ └── test_softmax.py
│ ├── evaluation/
│ │ └── test_r2_score.py
│ └── loss/
│ ├── test_mean_absolute_error.py
│ └── test_mean_squared_error.py
├── iterators_tests/
│ ├── test_balanced_serial_iterator.py
│ └── test_index_iterator.py
├── link_hooks_tests/
│ └── test_variable_monitor_link_hook.py
├── links_tests/
│ ├── array_tests/
│ │ └── test_shape_transformer_to_2d.py
│ ├── connection_tests/
│ │ ├── test_embed_atom_id.py
│ │ ├── test_graph_linear.py
│ │ └── test_graph_mlp.py
│ ├── readout_tests/
│ │ ├── test_cgcnn_readout.py
│ │ ├── test_general_readout.py
│ │ ├── test_ggnn_readout.py
│ │ ├── test_megnet_readout.py
│ │ ├── test_mpnn_readout.py
│ │ ├── test_nfp_readout.py
│ │ ├── test_schnet_readout.py
│ │ └── test_set2set.py
│ ├── scaler_tests/
│ │ ├── test_flow_scaler.py
│ │ ├── test_max_abs_scaler.py
│ │ ├── test_min_max_scaler.py
│ │ └── test_standard_scaler.py
│ └── update_tests/
│ ├── test_cgcnn_update.py
│ ├── test_ggnn_update.py
│ ├── test_gin_update.py
│ ├── test_gnn_film_update.py
│ ├── test_megnet_update.py
│ ├── test_mpnn_update.py
│ ├── test_nfp_update.py
│ ├── test_relgat_update.py
│ ├── test_relgcn_update.py
│ ├── test_rsgcn_update.py
│ └── test_schnet_update.py
├── models_tests/
│ ├── gwm_tests/
│ │ ├── test_gwm.py
│ │ └── test_gwm_graph_conv_model.py
│ ├── prediction_tests/
│ │ ├── test_base.py
│ │ ├── test_classifier.py
│ │ ├── test_graph_conv_predictor.py
│ │ ├── test_regressor.py
│ │ └── test_set_up_predictor.py
│ ├── test_cgcnn.py
│ ├── test_ggnn.py
│ ├── test_gin.py
│ ├── test_gnn_film.py
│ ├── test_megnet.py
│ ├── test_mlp.py
│ ├── test_mpnn.py
│ ├── test_nfp.py
│ ├── test_relgat.py
│ ├── test_relgcn.py
│ ├── test_rsgcn.py
│ ├── test_schnet.py
│ └── test_weavenet.py
├── saliency_tests/
│ ├── calculator_tests/
│ │ ├── test_base_calculator.py
│ │ ├── test_calculator_utils.py
│ │ ├── test_gradient_calculator.py
│ │ ├── test_integrated_gradient_calculator.py
│ │ └── test_occlusion_calculator.py
│ └── visualizer_tests/
│ ├── test_image_visualizer.py
│ ├── test_mol_visualizer.py
│ ├── test_table_visualizer.py
│ └── test_visualizer_utils.py
├── test_init.py
├── training_tests/
│ └── extensions_tests/
│ ├── test_auto_print_report.py
│ ├── test_prc_auc_evaluator.py
│ ├── test_r2_score_evaluator.py
│ └── test_roc_auc_evaluator.py
└── utils_tests/
├── test_extend.py
├── test_json_utils.py
├── test_permutation.py
├── test_sparse_utils.py
└── test_train_utils.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .codecov.yml
================================================
coverage:
status:
# pull-requests only
# Allow to drop coverage
project:
default:
threshold: 5.0%
patch:
default:
threshold: 20.0%
comment:
layout: "header, diff"
require_changes: false
branches: null
behavior: default
flags: null
paths: null
================================================
FILE: .flexci/config.pbtxt
================================================
# DO NOT MODIFY THIS FILE MANUALLY.
# USE gen_config.py INSTEAD.
configs {
key: "chainerch.py37.stable.cpu.chx"
value {
requirement {
cpu: 4
memory: 16
disk: 10
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "stable"
}
environment_variables {
key: "CHAINERX"
value: "1"
}
environment_variables {
key: "GPU"
value: "0"
}
}
}
configs {
key: "chainerch.py37.stable.gpu.chx"
value {
requirement {
cpu: 4
memory: 16
disk: 10
gpu: 1
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "stable"
}
environment_variables {
key: "CHAINERX"
value: "1"
}
environment_variables {
key: "GPU"
value: "1"
}
}
}
configs {
key: "chainerch.py37.stable.cpu"
value {
requirement {
cpu: 4
memory: 16
disk: 10
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "stable"
}
environment_variables {
key: "CHAINERX"
value: "0"
}
environment_variables {
key: "GPU"
value: "0"
}
}
}
configs {
key: "chainerch.py37.stable.gpu"
value {
requirement {
cpu: 4
memory: 16
disk: 10
gpu: 1
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "stable"
}
environment_variables {
key: "CHAINERX"
value: "0"
}
environment_variables {
key: "GPU"
value: "1"
}
}
}
configs {
key: "chainerch.py37.latest.cpu.chx"
value {
requirement {
cpu: 4
memory: 16
disk: 10
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "latest"
}
environment_variables {
key: "CHAINERX"
value: "1"
}
environment_variables {
key: "GPU"
value: "0"
}
}
}
configs {
key: "chainerch.py37.latest.gpu.chx"
value {
requirement {
cpu: 4
memory: 16
disk: 10
gpu: 1
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "latest"
}
environment_variables {
key: "CHAINERX"
value: "1"
}
environment_variables {
key: "GPU"
value: "1"
}
}
}
configs {
key: "chainerch.py37.latest.cpu"
value {
requirement {
cpu: 4
memory: 16
disk: 10
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "latest"
}
environment_variables {
key: "CHAINERX"
value: "0"
}
environment_variables {
key: "GPU"
value: "0"
}
}
}
configs {
key: "chainerch.py37.latest.gpu"
value {
requirement {
cpu: 4
memory: 16
disk: 10
gpu: 1
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "latest"
}
environment_variables {
key: "CHAINERX"
value: "0"
}
environment_variables {
key: "GPU"
value: "1"
}
}
}
configs {
key: "chainerch.py37.base.cpu.chx"
value {
requirement {
cpu: 4
memory: 16
disk: 10
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "base"
}
environment_variables {
key: "CHAINERX"
value: "1"
}
environment_variables {
key: "GPU"
value: "0"
}
}
}
configs {
key: "chainerch.py37.base.gpu.chx"
value {
requirement {
cpu: 4
memory: 16
disk: 10
gpu: 1
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "base"
}
environment_variables {
key: "CHAINERX"
value: "1"
}
environment_variables {
key: "GPU"
value: "1"
}
}
}
configs {
key: "chainerch.py37.base.cpu"
value {
requirement {
cpu: 4
memory: 16
disk: 10
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "base"
}
environment_variables {
key: "CHAINERX"
value: "0"
}
environment_variables {
key: "GPU"
value: "0"
}
}
}
configs {
key: "chainerch.py37.base.gpu"
value {
requirement {
cpu: 4
memory: 16
disk: 10
gpu: 1
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "37"
}
environment_variables {
key: "CHAINER"
value: "base"
}
environment_variables {
key: "CHAINERX"
value: "0"
}
environment_variables {
key: "GPU"
value: "1"
}
}
}
configs {
key: "chainerch.py36.stable.gpu"
value {
requirement {
cpu: 4
memory: 16
disk: 10
gpu: 1
}
command: "bash .flexci/pytest_script.sh"
environment_variables {
key: "PYTHON"
value: "36"
}
environment_variables {
key: "CHAINER"
value: "stable"
}
environment_variables {
key: "CHAINERX"
value: "0"
}
environment_variables {
key: "GPU"
value: "1"
}
}
}
================================================
FILE: .flexci/gen_config.py
================================================
"""Config generator for Flex CI
Usage:
$ python gen_config.py > config.pbtxt
"""
from __future__ import print_function
from collections import OrderedDict
import itertools
def test_config(python, chainer, target, chainerx):
if chainerx:
s_chainerx = '.chx'
else:
s_chainerx = ''
key = 'chainerch.py{}.{}.{}{}'.format(python, chainer, target, s_chainerx)
value = OrderedDict((
('requirement', OrderedDict((
('cpu', 4),
('memory', 16),
('disk', 10),
))),
('command', 'bash .flexci/pytest_script.sh'),
('environment_variables', [
('PYTHON', str(python)),
('CHAINER', chainer),
('CHAINERX', '1' if chainerx else '0'),
('GPU', '1' if target == 'gpu' else '0'),
]),
))
if target == 'gpu':
value['requirement']['gpu'] = 1
return key, value
def main():
configs = []
for python, chainer in itertools.product(
(37,), ('stable', 'latest', 'base')):
for chainerx in (True, False):
configs.append(test_config(python, chainer, 'cpu', chainerx))
configs.append(test_config(python, chainer, 'gpu', chainerx))
# small test in python 36
configs.append(test_config(36, 'stable', 'gpu', False))
print('# DO NOT MODIFY THIS FILE MANUALLY.')
print('# USE gen_config.py INSTEAD.')
print()
dump_pbtxt('configs', configs)
def dump_pbtxt(key, value, level=0):
indent = ' ' * level
if isinstance(value, int):
print('{}{}: {}'.format(indent, key, value))
elif isinstance(value, str):
print('{}{}: "{}"'.format(indent, key, value))
elif isinstance(value, list):
for k, v in value:
print('{}{} {{'.format(indent, key))
dump_pbtxt('key', k, level + 1)
dump_pbtxt('value', v, level + 1)
print('{}}}'.format(indent))
elif isinstance(value, dict):
print('{}{} {{'.format(indent, key))
for k, v in value.items():
dump_pbtxt(k, v, level + 1)
print('{}}}'.format(indent))
if __name__ == '__main__':
main()
================================================
FILE: .flexci/pytest_script.sh
================================================
#!/bin/bash
set -eux
BASE=6.0.0
service docker stop
mount -t tmpfs -o size=100% tmpfs /var/lib/docker
service docker start
gcloud auth configure-docker
if [ ${CHAINERX} -gt 0 ]; then
if [ ${GPU} -gt 0 ]; then
case ${CHAINER} in
stable)
DOCKER_IMAGE=asia.gcr.io/pfn-public-ci/chainer-chem-py$PYTHON-chainerx-gpu-stable:latest
;;
latest)
DOCKER_IMAGE=asia.gcr.io/pfn-public-ci/chainer-chem-py$PYTHON-chainerx-gpu-latest:latest
;;
base)
DOCKER_IMAGE=asia.gcr.io/pfn-public-ci/chainer-chem-py$PYTHON-chainerx-gpu-base:latest
;;
esac
else
case ${CHAINER} in
stable)
DOCKER_IMAGE=asia.gcr.io/pfn-public-ci/chainer-chem-py$PYTHON-chainerx-cpu-stable:latest
;;
latest)
DOCKER_IMAGE=asia.gcr.io/pfn-public-ci/chainer-chem-py$PYTHON-chainerx-cpu-latest:latest
;;
base)
DOCKER_IMAGE=asia.gcr.io/pfn-public-ci/chainer-chem-py$PYTHON-chainerx-cpu-base:latest
;;
esac
fi
echo "Use installed chainer in Docker image"
else
DOCKER_IMAGE=asia.gcr.io/pfn-public-ci/chainer-chem-py$PYTHON:latest
case ${CHAINER} in
stable)
echo pip install chainer >> install.sh
;;
latest)
echo pip install --pre chainer >> install.sh
;;
base)
echo pip install chainer==${BASE} >> install.sh
;;
esac
if [ ${GPU} -gt 0 ]; then
case ${CHAINER} in
stable)
echo pip install cupy-cuda101 >> install.sh
;;
latest)
echo pip install --pre cupy-cuda101 >> install.sh
;;
base)
echo pip install cupy-cuda101==${BASE} >> install.sh
;;
esac
fi
fi
echo pip install pytest-cov pytest-xdist mock >> install.sh
echo pip install -e . >> install.sh
echo $DOCKER_IMAGE
cat install.sh
if [ ${GPU} -gt 0 ]; then
PYTEST_OPTION="not slow"
RUNTIME="--runtime=nvidia"
else
PYTEST_OPTION="not slow and not gpu"
RUNTIME=""
fi
docker run $RUNTIME --interactive --rm \
--volume $(pwd):/repo/ --workdir /repo/\
$DOCKER_IMAGE sh -ex << EOD
. ./install.sh
pytest -n 4 --cov=chainer_chemistry -m '${PYTEST_OPTION}' tests/
EOD
================================================
FILE: .gitignore
================================================
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
docs/source/generated
# PyBuilder
target/
# IPython Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# dotenv
.env
# virtualenv
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
# PyCharm project settings
.idea/
examples/tox21/input/
examples/qm9/input/
examples/molnet/input/
# Trained models and plots
examples/tox21/eval_*
examples/qm9/eval_*
examples/molnet/eval_*
examples/own_dataset/eval_*
# emacs
*~
# VSCode
.vscode/
# Visual Studio
.vs/
*.sln
*.pyproj
.pytest_cache
================================================
FILE: .readthedocs.yml
================================================
name: chainer-chemistry
type: sphinx
base: docs/source
conda:
file: docs/source/environment.yml
================================================
FILE: .travis.yml
================================================
sudo: false
language: python
os: linux
dist: trusty
python:
- 3.6
env:
env:
- CHAINER_VERSION="chainer==7.0.0"
- CHAINER_VERSION="chainer"
- CHAINER_VERSION="prerelease"
install:
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes
- conda update -q conda
- conda info -a
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION
- source activate test-environment
- pip install codecov
- pip install mock
- conda install pip pytest pytest-cov
- conda install -c rdkit rdkit==2019.03.2.0
- if [ "${CHAINER_VERSION}" = "prerelease" ]; then
pip install --pre chainer;
else
pip install "${CHAINER_VERSION}";
fi
- pip install --no-cache-dir -e .
script:
- if [ "${TRAVIS_EVENT_TYPE}" = "cron" ]; then
pytest --cov=./ -m "not gpu" tests;
(cd examples && bash -x test_examples.sh -1);
else
pytest --cov=./ -m "not (gpu or slow)" tests;
fi
after_success:
- codecov
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2017 Preferred Networks, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
# Chainer Chemistry: A Library for Deep Learning in Biology and Chemistry
[](https://pypi.python.org/pypi/chainer-chemistry)
[](https://github.com/pfnet-research/chainer-chemistry/blob/master/LICENSE)
[](https://travis-ci.org/pfnet-research/chainer-chemistry)
[](http://chainer-chemistry.readthedocs.io/en/latest/?badge=latest)
<p align="center">
<img src="assets/chainer-chemistry-overview.png" alt="Chainer Chemistry Overview" width="600" />
</p>
Chainer Chemistry is a deep learning framework (based on Chainer) with
applications in Biology and Chemistry. It supports various state-of-the-art
models (especially GCNN - Graph Convolutional Neural Network) for chemical property prediction.
For more information, please refer to the [documentation](http://chainer-chemistry.readthedocs.io/en/latest/index.html).
Also, a quick introduction to deep learning for molecules and Chainer Chemistry
is available [here](https://www.slideshare.net/KentaOono/deep-learning-for-molecules-introduction-to-chainer-chemistry-93288837).
## Dependencies
Chainer Chemistry depends on the following packages:
- [`chainer`](https://docs.chainer.org/en/stable/index.html)
- [`pandas`](https://pandas.pydata.org)
- [`scikit-learn`](http://scikit-learn.org/stable/)
- [`tqdm`](https://pypi.python.org/pypi/tqdm)
- [`h5py`](https://pypi.python.org/pypi/h5py)
These are automatically added to the system when installing the library via the
`pip` command (see _Installation_). However, the following needs to be
installed manually:
- [`rdkit (release 2019.03.2.0)`](https://github.com/rdkit/rdkit)
Please refer to the RDKit [documentation](http://www.rdkit.org/docs/Install.html)
for more information regarding the installation steps.
Note that only the following versions of Chainer Chemistry's dependencies are
currently supported:
| Chainer Chemistry | Chainer | RDKit | Python |
| ------------------: | --------------: | -------------: | ---------------: |
| v0.1.0 ~ v0.3.0 | v2.0 ~ v3.0 | 2017.09.3.0 | 2.7, 3.5, 3.6 |
| v0.4.0 | v3.0 ~ v4.0 *1 | 2017.09.3.0 | 2.7, 3.5, 3.6 |
| v0.5.0 | v3.0 ~ v5.0 *2 | 2017.09.3.0 | 2.7, 3.5, 3.6 |
| v0.6.0 | v6.0 ~ *3 | 2017.09.3.0 | 2.7, 3.5, 3.6 |
| v0.7.0 ~ v0.7.1 | v7.0 ~ | 2019.03.2.0 | 3.6, 3.7 *4 |
| master branch *5 | v7.0 ~ | 2019.03.2.0 | 3.6, 3.7 |
[Footnote]
*1: We used `FunctionNode` in [this PR](https://github.com/pfnet-research/chainer-chemistry/pull/190),
which is introduced after chainer v3. See [this issue](https://github.com/pfnet-research/chainer-chemistry/issues/192) for details.
*2: Saliency modules only work after chainer v5.
*3: Chainer v6 is released and [ChainerX](https://chainer.org/announcement/2018/12/03/chainerx.html) is newly introduced.
In order to support this new feature & API, we broke backward compatibility for chainer chemistry v0.6.0 release.
See [ChainerX Documentation](https://chainer.org/announcement/2018/12/03/chainerx.html) for details.
*4: python 2.x support is dropped, following the same policy with `chainer` and `rdkit`.
*5: As [announced in chainer blog](https://chainer.org/announcement/2019/12/05/released-v7.html),
further development will be limited to only serious bug-fixes and maintenance.
## Installation
Chainer Chemistry can be installed using the `pip` command, as follows:
```
pip install chainer-chemistry
```
Example to install rdkit with conda:
```bash
# newer conda version is necessary to install rdkit 2019.03.2.0
conda install -n base conda==4.6.14
conda install -c rdkit rdkit==2019.03.2.0
```
If you would like to use the latest sources, please checkout the master branch
and install with the following commands:
```
git clone https://github.com/pfnet-research/chainer-chemistry.git
pip install -e chainer-chemistry
```
## Sample Code
Sample code is provided with this repository. This includes, but is not limited
to, the following:
- Training a new model on a given dataset
- Performing inference on a given dataset, using a pretrained model
- Evaluating and reporting performance metrics of different models on a given
dataset
Please refer to the `examples` directory for more information.
## Supported Models
The following graph convolutional neural networks are currently supported:
- NFP: Neural Fingerprint [2, 3]
- GGNN: Gated Graph Neural Network [4, 3]
- WeaveNet [5, 3]
- SchNet [6]
- RSGCN: Renormalized Spectral Graph Convolutional Network [10]<br/>
\* The name is not from the original paper - see [PR #89](https://github.com/pfnet-research/chainer-chemistry/pull/89) for the naming convention.
- RelGCN: Relational Graph Convolutional Network [14]
- GAT: Graph Attention Networks [15]
- GIN: Graph Isomorphism Networks [17]
- MPNN: Message Passing Neural Networks [3]
- Set2Set [19]
- GNN-FiLM: Graph Neural Networks with Feature-wise Linear Modulation [20]
- MEGNet: MatErials Graph Network [24]
- CGCNN: Crystal Graph Convolutional Neural Networks [25]
We test supporting the brand-new Graph Warp Module (GWM) [18]-attached models for:
- NFP ('nfp_gwm')
- GGNN ('ggnn_gwm')
- RSGCN ('rsgcn_gwm')
- GIN ('gin_gwm')
In the directory `examples/molnet_wle`, we have implemented the new preprocessing ''Weisfeiler-Lehman Embedding for Molecular Graph Neural Networks'' [26] for several GNN architectures. Please find the Readme in that directory for the usage and the details.
## Supported Datasets
The following datasets are currently supported:
### Chemical
- QM9 [7, 8]
- Tox21 [9]
- MoleculeNet [11]
- ZINC (only 250k dataset) [12, 13]
- User (own) dataset
### Network
- cora [21]
- citeseer [22]
- reddit [23]
## Research Projects
If you use Chainer Chemistry in your research, feel free to submit a
pull request and add the name of your project to this list:
- BayesGrad: Explaining Predictions of Graph Convolutional Networks ([paper](https://arxiv.org/abs/1807.01985), [code](https://github.com/pfnet-research/bayesgrad))
- Graph Warp Module: an Auxiliary Module for Boosting the Power of Graph Neural Networks ([paper](https://arxiv.org/abs/1902.01020), [code](https://github.com/k-ishiguro/chainer-chemistry/tree/gwm_for_CC))
- GraphNVP: An Invertible Flow Model for Generating Molecular Graphs ([paper](https://arxiv.org/abs/1905.11600), [code](https://github.com/pfnet-research/graph-nvp))
- Graph Residual Flow for Molecular Graph Generation ([paper](https://arxiv.org/abs/1909.13521))
## Useful Links
Chainer Chemistry:
- [Documentation](https://chainer-chemistry.readthedocs.io)
- [Research Blog](https://preferredresearch.jp/2017/12/18/chainer-chemistry-beta-release/)
Other Chainer frameworks:
- [Chainer: A Flexible Framework of Neural Networks for Deep Learning](https://chainer.org/)
- [ChainerRL: Deep Reinforcement Learning Library Built on Top of Chainer](https://github.com/chainer/chainerrl)
- [ChainerCV: A Library for Deep Learning in Computer Vision](https://github.com/chainer/chainercv)
- [ChainerMN: Scalable Distributed Deep Learning with Chainer](https://github.com/chainer/chainermn)
- [ChainerUI: User Interface for Chainer](https://github.com/chainer/chainerui)
## License
This project is released under the MIT License. Please refer to the
[this page](https://github.com/pfnet-research/chainer-chemistry/blob/master/LICENSE)
for more information.
Please note that Chainer Chemistry is still in experimental development.
We continuously strive to improve its functionality and performance, but at
this stage we cannot guarantee the reproducibility of any results published in
papers. Use the library at your own risk.
## References
[1] Seiya Tokui, Kenta Oono, Shohei Hido, and Justin Clayton. Chainer: a next-generation open source framework for deep learning. In *Proceedings of Workshop on Machine Learning Systems (LearningSys) in Advances in Neural Information Processing System (NIPS) 28*, 2015.
[2] David K Duvenaud, Dougal Maclaurin, Jorge Iparraguirre, Rafael Bombarell, Timothy Hirzel, Alan Aspuru-Guzik, and Ryan P Adams. Convolutional networks on graphs for learning molecular fingerprints. In C. Cortes, N. D. Lawrence, D. D. Lee, M. Sugiyama, and R. Garnett, editors, *Advances in Neural Information Processing Systems (NIPS) 28*, pages 2224–2232. Curran Asso- ciates, Inc., 2015.
[3] Justin Gilmer, Samuel S Schoenholz, Patrick F Riley, Oriol Vinyals, and George E Dahl. Neural message passing for quantum chemistry. *arXiv preprint arXiv:1704.01212*, 2017.
[4] Yujia Li, Daniel Tarlow, Marc Brockschmidt, and Richard Zemel. Gated graph sequence neural networks. *arXiv preprint arXiv:1511.05493*, 2015.
[5] Steven Kearnes, Kevin McCloskey, Marc Berndl, Vijay Pande, and Patrick Riley. Molecular graph convolutions: moving beyond fingerprints. *Journal of computer-aided molecular design*, 30(8):595–608, 2016.
[6] Kristof Schütt, Pieter-Jan Kindermans, Huziel Enoc Sauceda Felix, Stefan Chmiela, Alexandre Tkatchenko, and Klaus-Rober Müller. Schnet: A continuous-filter convolutional neural network for modeling quantum interactions. In I. Guyon, U. V. Luxburg, S. Bengio, H. Wallach, R. Fergus, S. Vishwanathan, and R. Garnett, editors, *Advances in Neural Information Processing Systems (NIPS) 30*, pages 992–1002. Curran Associates, Inc., 2017.
[7] Lars Ruddigkeit, Ruud Van Deursen, Lorenz C Blum, and Jean-Louis Reymond. Enumeration of 166 billion organic small molecules in the chemical universe database gdb-17. *Journal of chemical information and modeling*, 52(11):2864–2875, 2012.
[8] Raghunathan Ramakrishnan, Pavlo O Dral, Matthias Rupp, and O Anatole Von Lilienfeld. Quantum chemistry structures and properties of 134 kilo molecules. *Scientific data*, 1:140022, 2014.
[9] Ruili Huang, Menghang Xia, Dac-Trung Nguyen, Tongan Zhao, Srilatha Sakamuru, Jinghua Zhao, Sampada A Shahane, Anna Rossoshek, and Anton Simeonov. Tox21challenge to build predictive models of nuclear receptor and stress response pathways as mediated by exposure to environmental chemicals and drugs. *Frontiers in Environmental Science*, 3:85, 2016.
[10] Kipf, Thomas N. and Welling, Max. Semi-Supervised Classification with Graph Convolutional Networks. *International Conference on Learning Representations (ICLR)*, 2017.
[11] Zhenqin Wu, Bharath Ramsundar, Evan N. Feinberg, Joseph Gomes, Caleb Geniesse, Aneesh S. Pappu, Karl Leswing, Vijay Pande, MoleculeNet: A Benchmark for Molecular Machine Learning, arXiv preprint, arXiv: 1703.00564, 2017.
[12] J. J. Irwin, T. Sterling, M. M. Mysinger, E. S. Bolstad, and R. G. Coleman. Zinc: a free tool to discover chemistry for biology. *Journal of chemical information and modeling*, 52(7):1757–1768, 2012.
[13] Preprocessed csv file downloaded from https://raw.githubusercontent.com/aspuru-guzik-group/chemical_vae/master/models/zinc_properties/250k_rndm_zinc_drugs_clean_3.csv
[14] Michael Schlichtkrull, Thomas N. Kipf, Peter Bloem, Rianne van den Berg, Ivan Titov, Max Welling. Modeling Relational Data with Graph Convolutional Networks. *Extended Semantic Web Conference (ESWC)*, 2018.
[15] Veličković, P., Cucurull, G., Casanova, A., Romero, A., Liò, P., & Bengio, Y. (2017). Graph Attention Networks. arXiv preprint arXiv:1710.10903.
[16] Dan Busbridge, Dane Sherburn, Pietro Cavallo and Nils Y. Hammerla. (2019). Relational Graph Attention Networks. https://openreview.net/forum?id=Bklzkh0qFm
[17] Keyulu Xu, Weihua Hu, Jure Leskovec, Stefanie Jegelka, ``How Powerful are Graph Neural Networks?'', arXiv:1810.00826 [cs.LG], 2018 (to appear at ICLR19).
[18] K. Ishiguro, S. Maeda, and M. Koyama, ``Graph Warp Module: an Auxiliary Module for Boosting the Power of Graph Neural Networks'', arXiv:1902.01020 [cs.LG], 2019.
[19] Oriol Vinyals, Samy Bengio, Manjunath Kudlur. Order Matters: Sequence to sequence for sets. *arXiv preprint arXiv:1511.06391*, 2015.
[20] Marc Brockschmidt, ``GNN-FiLM: Graph Neural Networks with Feature-wise Linear Modulation'', arXiv:1906.12192 [cs.ML], 2019.
[21] McCallum, Andrew Kachites and Nigam, Kamal and Rennie, Jason and Seymore, Kristie, Automating the Construction of Internet Portals with Machine Learning. *Information Retrieval*, 2000.
[22] C. Lee Giles and Kurt D. Bollacker and Steve Lawrence, CiteSeer: An Automatic Citation Indexing System. *Proceedings of the Third ACM Conference on Digital Libraries*, 1998.
[23] William L. Hamilton and Zhitao Ying and Jure Leskovec, Inductive Representation Learning on Large Graphs. *Advances in Neural Information Processing Systems 30: Annual Conference on Neural Information Processing Systems 2017, 4-9 December 2017*
[24] Chi Chen, Weike Ye, Yunxing Zuo, Chen Zheng, and Shyue Ping Ong. Graph networks as a universal machine learning framework for molecules and crystals. *Chemistry of Materials*, 31(9):3564–3572, 2019.
[25] Tian Xie and Jeffrey C Grossman. Crystal graph convolutional neural networks for an accurate and interpretable prediction of material properties. *Physical review letters*, 120(14):145301, 2018.
[26] Katsuhiko Ishiguro, Kenta Oono, and Kohei Hayashi, "Weisfeiler-Lehman Embedding for Molecular Graph Neural Networks", arXiv: 2006.06909, 2020. [paper link](https://arxiv.org/abs/2006.06909)
================================================
FILE: chainer_chemistry/__init__.py
================================================
import warnings
from chainer_chemistry import dataset # NOQA
try:
from chainer_chemistry import datasets # NOQA
except ImportError as e:
if 'rdkit' in e.msg:
warnings.warn(
'A module chainer_chemistry.datasets was not imported, '
'probably because RDKit is not installed. '
'To install RDKit, please follow instruction in '
'https://github.com/pfnet-research/chainer-chemistry#installation.', # NOQA
UserWarning)
else:
raise(e)
from chainer_chemistry import functions # NOQA
from chainer_chemistry import links # NOQA
from chainer_chemistry import models # NOQA
from chainer_chemistry import training # NOQA
# --- config variable definitions ---
from chainer_chemistry.config import * # NOQA
from chainer_chemistry import _version # NOQA
__version__ = _version.__version__
================================================
FILE: chainer_chemistry/_version.py
================================================
__version__ = '0.7.1'
================================================
FILE: chainer_chemistry/config.py
================================================
# --- Configuration ---
# --- Constant definitions ---
# The maximum atomic number in rdkit
MAX_ATOMIC_NUM = 117
WEAVE_DEFAULT_NUM_MAX_ATOMS = 20 # 60 # paper
================================================
FILE: chainer_chemistry/dataset/__init__.py
================================================
from chainer_chemistry.dataset.indexer import BaseFeatureIndexer # NOQA
from chainer_chemistry.dataset.indexer import BaseIndexer # NOQA
================================================
FILE: chainer_chemistry/dataset/converters/__init__.py
================================================
from chainer_chemistry.dataset.converters.cgcnn_converter import cgcnn_converter # NOQA
from chainer_chemistry.dataset.converters.concat_mols import concat_mols # NOQA
from chainer_chemistry.dataset.converters.megnet_converter import megnet_converter # NOQA
converter_method_dict = {
'ecfp': concat_mols,
'nfp': concat_mols,
'nfp_gwm': concat_mols,
'ggnn': concat_mols,
'ggnn_gwm': concat_mols,
'gin': concat_mols,
'gin_gwm': concat_mols,
'schnet': concat_mols,
'weavenet': concat_mols,
'relgcn': concat_mols,
'rsgcn': concat_mols,
'rsgcn_gwm': concat_mols,
'relgat': concat_mols,
'gnnfilm': concat_mols,
'megnet': megnet_converter,
'cgcnn': cgcnn_converter
}
================================================
FILE: chainer_chemistry/dataset/converters/cgcnn_converter.py
================================================
import numpy
import chainer
from chainer.dataset.convert import to_device
from chainer import functions
@chainer.dataset.converter()
def cgcnn_converter(batch, device=None, padding=None):
"""CGCNN converter"""
if len(batch) == 0:
raise ValueError("batch is empty")
atom_feat, nbr_feat, nbr_idx = [], [], []
batch_atom_idx, target = [], []
current_idx = 0
xp = device.xp
for element in batch:
atom_feat.append(element[0])
nbr_feat.append(element[1])
nbr_idx.append(element[2] + current_idx)
target.append(element[3])
n_atom = element[0].shape[0]
atom_idx = numpy.arange(n_atom) + current_idx
batch_atom_idx.append(atom_idx)
current_idx += n_atom
atom_feat = to_device(device, functions.concat(atom_feat, axis=0).data)
nbr_feat = to_device(device, functions.concat(nbr_feat, axis=0).data)
# Always use numpy array for batch_atom_index
# this is list of variable length array
batch_atom_idx = numpy.array(batch_atom_idx)
nbr_idx = to_device(device, functions.concat(nbr_idx, axis=0).data)
target = to_device(device, xp.asarray(target))
result = (atom_feat, nbr_feat, batch_atom_idx, nbr_idx, target)
return result
================================================
FILE: chainer_chemistry/dataset/converters/concat_mols.py
================================================
import chainer
@chainer.dataset.converter()
def concat_mols(batch, device=None, padding=0):
"""Concatenates a list of molecules into array(s).
This function converts an "array of tuples" into a "tuple of arrays".
Specifically, given a list of examples each of which consists of
a list of elements, this function first makes an array
by taking the element in the same position from each example
and concatenates them along the newly-inserted first axis
(called `batch dimension`) into one array.
It repeats this for all positions and returns the resulting arrays.
The output type depends on the type of examples in ``batch``.
For instance, consider each example consists of two arrays ``(x, y)``.
Then, this function concatenates ``x`` 's into one array, and ``y`` 's
into another array, and returns a tuple of these two arrays. Another
example: consider each example is a dictionary of two entries whose keys
are ``'x'`` and ``'y'``, respectively, and values are arrays. Then, this
function concatenates ``x`` 's into one array, and ``y`` 's into another
array, and returns a dictionary with two entries ``x`` and ``y`` whose
values are the concatenated arrays.
When the arrays to concatenate have different shapes, the behavior depends
on the ``padding`` value. If ``padding`` is ``None``, it raises an error.
Otherwise, it builds an array of the minimum shape that the
contents of all arrays can be substituted to. The padding value is then
used to the extra elements of the resulting arrays.
The current implementation is identical to
:func:`~chainer.dataset.concat_examples` of Chainer, except the default
value of the ``padding`` option is changed to ``0``.
.. admonition:: Example
>>> import numpy
>>> from chainer_chemistry.dataset.converters import concat_mols
>>> x0 = numpy.array([1, 2])
>>> x1 = numpy.array([4, 5, 6])
>>> dataset = [x0, x1]
>>> results = concat_mols(dataset)
>>> print(results)
[[1 2 0]
[4 5 6]]
.. seealso:: :func:`chainer.dataset.concat_examples`
Args:
batch (list):
A list of examples. This is typically given by a dataset
iterator.
device (int):
Device ID to which each array is sent. Negative value
indicates the host memory (CPU). If it is omitted, all arrays are
left in the original device.
padding:
Scalar value for extra elements. If this is None (default),
an error is raised on shape mismatch. Otherwise, an array of
minimum dimensionalities that can accommodate all arrays is
created, and elements outside of the examples are padded by this
value.
Returns:
Array, a tuple of arrays, or a dictionary of arrays:
The type depends on the type of each example in the batch.
"""
return chainer.dataset.concat_examples(batch, device, padding=padding)
================================================
FILE: chainer_chemistry/dataset/converters/megnet_converter.py
================================================
import chainer
from chainer.dataset.convert import to_device
@chainer.dataset.converter()
def megnet_converter(batch, device=None, padding=0):
"""MEGNet converter"""
if len(batch) == 0:
raise ValueError("batch is empty")
atom_feat, pair_feat, global_feat, target = [], [], [], []
atom_idx, pair_idx, start_idx, end_idx = [], [], [], []
batch_size = len(batch)
current_atom_idx = 0
for i in range(batch_size):
element = batch[i]
n_atom = element[0].shape[0]
n_pair = element[1].shape[0]
atom_feat.extend(element[0])
pair_feat.extend(element[1])
global_feat.append(element[2])
atom_idx.extend([i]*n_atom)
pair_idx.extend([i]*n_pair)
start_idx.extend(element[3][0] + current_atom_idx)
end_idx.extend(element[3][1] + current_atom_idx)
target.append(element[4])
current_atom_idx += n_atom
xp = device.xp
atom_feat = to_device(device, xp.asarray(atom_feat))
pair_feat = to_device(device, xp.asarray(pair_feat))
global_feat = to_device(device, xp.asarray(global_feat))
atom_idx = to_device(device, xp.asarray(atom_idx))
pair_idx = to_device(device, xp.asarray(pair_idx))
start_idx = to_device(device, xp.asarray(start_idx))
end_idx = to_device(device, xp.asarray(end_idx))
target = to_device(device, xp.asarray(target))
result = (atom_feat, pair_feat, global_feat, atom_idx, pair_idx,
start_idx, end_idx, target)
return result
================================================
FILE: chainer_chemistry/dataset/graph_dataset/__init__.py
================================================
================================================
FILE: chainer_chemistry/dataset/graph_dataset/base_graph_data.py
================================================
import numpy
import chainer
class BaseGraphData(object):
"""Base class of graph data """
def __init__(self, *args, **kwargs):
for k, v in kwargs.items():
setattr(self, k, v)
def to_device(self, device):
"""Send self to `device`
Args:
device (chainer.backend.Device): device
Returns:
self sent to `device`
"""
for k, v in self.__dict__.items():
if isinstance(v, (numpy.ndarray)):
setattr(self, k, device.send(v))
elif isinstance(v, (chainer.utils.CooMatrix)):
data = device.send(v.data.array)
row = device.send(v.row)
col = device.send(v.col)
device_coo_matrix = chainer.utils.CooMatrix(
data, row, col, v.shape, order=v.order)
setattr(self, k, device_coo_matrix)
return self
class PaddingGraphData(BaseGraphData):
"""Graph data class for padding pattern
Args:
x (numpy.ndarray): input node feature
adj (numpy.ndarray): adjacency matrix
y (int or numpy.ndarray): graph or node label
"""
def __init__(self, x=None, adj=None, super_node=None, pos=None, y=None,
**kwargs):
self.x = x
self.adj = adj
self.super_node = super_node
self.pos = pos
self.y = y
self.n_nodes = x.shape[0]
super(PaddingGraphData, self).__init__(**kwargs)
class SparseGraphData(BaseGraphData):
"""Graph data class for sparse pattern
Args:
x (numpy.ndarray): input node feature
edge_index (numpy.ndarray): sources and destinations of edges
edge_attr (numpy.ndarray): attribution of edges
y (int or numpy.ndarray): graph or node label
"""
def __init__(self, x=None, edge_index=None, edge_attr=None,
pos=None, super_node=None, y=None, **kwargs):
self.x = x
self.edge_index = edge_index
self.edge_attr = edge_attr
self.pos = pos
self.super_node = super_node
self.y = y
self.n_nodes = x.shape[0]
super(SparseGraphData, self).__init__(**kwargs)
================================================
FILE: chainer_chemistry/dataset/graph_dataset/base_graph_dataset.py
================================================
import numpy
import chainer
from chainer._backend import Device
from chainer_chemistry.dataset.graph_dataset.base_graph_data import BaseGraphData # NOQA
from chainer_chemistry.dataset.graph_dataset.feature_converters \
import batch_with_padding, batch_without_padding, concat, shift_concat, \
concat_with_padding, shift_concat_with_padding # NOQA
class BaseGraphDataset(object):
"""Base class of graph dataset (list of graph data)"""
_pattern = ''
_feature_entries = []
_feature_batch_method = []
def __init__(self, data_list, *args, **kwargs):
self.data_list = data_list
def register_feature(self, key, batch_method, skip_if_none=True):
"""Register feature with batch method
Args:
key (str): name of the feature
batch_method (function): batch method
skip_if_none (bool, optional): If true, skip if `batch_method` is
None. Defaults to True.
"""
if skip_if_none and getattr(self.data_list[0], key, None) is None:
return
self._feature_entries.append(key)
self._feature_batch_method.append(batch_method)
def update_feature(self, key, batch_method):
"""Update batch method of the feature
Args:
key (str): name of the feature
batch_method (function): batch method
"""
index = self._feature_entries.index(key)
self._feature_batch_method[index] = batch_method
def __len__(self):
return len(self.data_list)
def __getitem__(self, item):
return self.data_list[item]
def converter(self, batch, device=None):
"""Converter
Args:
batch (list[BaseGraphData]): list of graph data
device (int, optional): specifier of device. Defaults to None.
Returns:
self sent to `device`
"""
if not isinstance(device, Device):
device = chainer.get_device(device)
batch = [method(name, batch, device=device) for name, method in
zip(self._feature_entries, self._feature_batch_method)]
data = BaseGraphData(
**{key: value for key, value in zip(self._feature_entries, batch)})
return data
class PaddingGraphDataset(BaseGraphDataset):
"""Graph dataset class for padding pattern"""
_pattern = 'padding'
def __init__(self, data_list):
super(PaddingGraphDataset, self).__init__(data_list)
self.register_feature('x', batch_with_padding)
self.register_feature('adj', batch_with_padding)
self.register_feature('super_node', batch_with_padding)
self.register_feature('pos', batch_with_padding)
self.register_feature('y', batch_without_padding)
self.register_feature('n_nodes', batch_without_padding)
class SparseGraphDataset(BaseGraphDataset):
"""Graph dataset class for sparse pattern"""
_pattern = 'sparse'
def __init__(self, data_list):
super(SparseGraphDataset, self).__init__(data_list)
self.register_feature('x', concat)
self.register_feature('edge_index', shift_concat)
self.register_feature('edge_attr', concat)
self.register_feature('super_node', concat)
self.register_feature('pos', concat)
self.register_feature('y', batch_without_padding)
self.register_feature('n_nodes', batch_without_padding)
def converter(self, batch, device=None):
"""Converter
add `self.batch`, which represents the index of the graph each node
belongs to.
Args:
batch (list[BaseGraphData]): list of graph data
device (int, optional): specifier of device. Defaults to None.
Returns:
self sent to `device`
"""
data = super(SparseGraphDataset, self).converter(batch, device=device)
if not isinstance(device, Device):
device = chainer.get_device(device)
data.batch = numpy.concatenate([
numpy.full((data.x.shape[0]), i, dtype=numpy.int)
for i, data in enumerate(batch)
])
data.batch = device.send(data.batch)
return data
# for experiment
# use converter for the normal use
def converter_with_padding(self, batch, device=None):
self.update_feature('x', concat_with_padding)
self.update_feature('edge_index', shift_concat_with_padding)
data = super(SparseGraphDataset, self).converter(batch, device=device)
if not isinstance(device, Device):
device = chainer.get_device(device)
max_n_nodes = max([data.x.shape[0] for data in batch])
data.batch = numpy.concatenate([
numpy.full((max_n_nodes), i, dtype=numpy.int)
for i, data in enumerate(batch)
])
data.batch = device.send(data.batch)
return data
================================================
FILE: chainer_chemistry/dataset/graph_dataset/feature_converters.py
================================================
import numpy
from chainer.dataset.convert import _concat_arrays
def batch_with_padding(name, batch, device=None, pad=0):
"""Batch with padding (increase ndim by 1)
Args:
name (str): propaty name of graph data
batch (list[BaseGraphData]): list of base graph data
device (chainer.backend.Device, optional): device. Defaults to None.
pad (int, optional): padding value. Defaults to 0.
Returns:
BaseGraphDataset: graph dataset sent to `device`
"""
feat = _concat_arrays(
[getattr(example, name) for example in batch], pad)
return device.send(feat)
def batch_without_padding(name, batch, device=None):
"""Batch without padding (increase ndim by 1)
Args:
name (str): propaty name of graph data
batch (list[BaseGraphData]): list of base graph data
device (chainer.backend.Device, optional): device. Defaults to None.
Returns:
BaseGraphDataset: graph dataset sent to `device`
"""
feat = _concat_arrays(
[getattr(example, name) for example in batch], None)
return device.send(feat)
def concat_with_padding(name, batch, device=None, pad=0):
"""Concat without padding (ndim does not increase)
Args:
name (str): propaty name of graph data
batch (list[BaseGraphData]): list of base graph data
device (chainer.backend.Device, optional): device. Defaults to None.
pad (int, optional): padding value. Defaults to 0.
Returns:
BaseGraphDataset: graph dataset sent to `device`
"""
feat = batch_with_padding(name, batch, device=device, pad=pad)
a, b = feat.shape
return feat.reshape((a * b))
def concat(name, batch, device=None, axis=0):
"""Concat with padding (ndim does not increase)
Args:
name (str): propaty name of graph data
batch (list[BaseGraphData]): list of base graph data
device (chainer.backend.Device, optional): device. Defaults to None.
pad (int, optional): padding value. Defaults to 0.
Returns:
BaseGraphDataset: graph dataset sent to `device`
"""
feat = numpy.concatenate([getattr(data, name) for data in batch],
axis=axis)
return device.send(feat)
def shift_concat(name, batch, device=None, shift_attr='x', shift_axis=1):
"""Concat with index shift (ndim does not increase)
Concatenate graphs into a big one.
Used for sparse pattern batching.
Args:
name (str): propaty name of graph data
batch (list[BaseGraphData]): list of base graph data
device (chainer.backend.Device, optional): device. Defaults to None.
Returns:
BaseGraphDataset: graph dataset sent to `device`
"""
shift_index_array = numpy.cumsum(
numpy.array([0] + [getattr(data, shift_attr).shape[0]
for data in batch]))
feat = numpy.concatenate([
getattr(data, name) + shift_index_array[i]
for i, data in enumerate(batch)], axis=shift_axis)
return device.send(feat)
def shift_concat_with_padding(name, batch, device=None, shift_attr='x',
shift_axis=1):
"""Concat with index shift and padding (ndim does not increase)
Concatenate graphs into a big one.
Used for sparse pattern batching.
Args:
name (str): propaty name of graph data
batch (list[BaseGraphData]): list of base graph data
device (chainer.backend.Device, optional): device. Defaults to None.
Returns:
BaseGraphDataset: graph dataset sent to `device`
"""
max_n_nodes = max([data.x.shape[0] for data in batch])
shift_index_array = numpy.arange(0, len(batch) * max_n_nodes, max_n_nodes)
feat = numpy.concatenate([
getattr(data, name) + shift_index_array[i]
for i, data in enumerate(batch)], axis=shift_axis)
return device.send(feat)
================================================
FILE: chainer_chemistry/dataset/indexer.py
================================================
import numpy
import six
class ExtractBySliceNotSupportedError(Exception):
pass
class BaseIndexer(object):
"""Base class for Indexer"""
def __getitem__(self, item):
raise NotImplementedError
class BaseFeatureIndexer(BaseIndexer):
"""Base class for FeatureIndexer
FeatureIndexer can be accessed by 2-dimensional indices, axis=0 is used for
dataset index and axis=1 is used for feature index.
For example, let `features` be the instance of `BaseFeatureIndexer`, then
`features[i, j]` returns `i`-th dataset of `j`-th feature.
`features[ind]` works same with `features[ind, :]`
Note that the returned value will be numpy array, even though the
dataset is initilized with other format (e.g. list).
"""
def __init__(self, dataset):
super(BaseFeatureIndexer, self).__init__()
self.dataset = dataset
def features_length(self):
"""Returns length of features
Returns (int): feature length
"""
raise NotImplementedError
@property
def dataset_length(self):
return len(self.dataset)
@property
def shape(self):
return self.dataset_length, self.features_length()
def extract_feature_by_slice(self, slice_index, j):
"""Extracts `slice_index`-th data's `j`-th feature.
Here, `slice_index` is indices of slice object.
This method may be override to support efficient feature extraction.
If not override, `ExtractBySliceNotSupportedError` is raised by
default, and in this case `extract_feature` is used instead.
Args:
slice_index (slice): slice of data index to be extracted
j (int): `j`-th feature to be extracted
Returns: feature
"""
raise ExtractBySliceNotSupportedError
def extract_feature(self, i, j):
"""Extracts `i`-th data's `j`-th feature
Args:
i (int): `i`-th data to be extracted
j (int): `j`-th feature to be extracted
Returns: feature
"""
raise NotImplementedError
def create_feature_index_list(self, feature_index):
if isinstance(feature_index, slice):
feature_index_list = numpy.arange(
*feature_index.indices(self.features_length())
)
elif isinstance(feature_index, (list, numpy.ndarray)):
if isinstance(feature_index[0],
(bool, numpy.bool, numpy.bool_)):
if len(feature_index) != self.features_length():
raise ValueError('Feature index wrong length {} instead of'
' {}'.format(len(feature_index),
self.features_length()))
feature_index_list = numpy.argwhere(feature_index
).ravel()
else:
feature_index_list = feature_index
else:
# assuming int type
feature_index_list = [feature_index]
return feature_index_list
def preprocess(self, item):
pass
def postprocess(self, item):
pass
def __getitem__(self, item):
self.preprocess(item)
if isinstance(item, tuple):
index_dim = len(item)
# multi dimensional access
if index_dim == 1:
# This is not unexpected case...
data_index = item[0]
feature_index_list = self.create_feature_index_list(
slice(None)
)
elif index_dim == 2:
data_index, feature_index = item
feature_index_list = self.create_feature_index_list(
feature_index
)
else:
raise IndexError('too many indices for features')
else:
data_index = item
feature_index_list = self.create_feature_index_list(slice(None))
if len(feature_index_list) == 1:
self._extract_single_feature = True
ret = self._extract_feature(data_index, feature_index_list[0])
else:
self._extract_single_feature = False
ret = tuple([self._extract_feature(data_index, j) for j in
feature_index_list])
self.postprocess(item)
return ret
def check_type_feature_index(self, j):
if j >= self.features_length():
raise IndexError('index {} is out of bounds for axis 1 with '
'size {}'.format(j, self.features_length()))
def _extract_feature(self, data_index, j):
"""Format `data_index` and call proper method to extract feature.
Args:
data_index (int, slice, list or numpy.ndarray):
j (int or key):
"""
self.check_type_feature_index(j)
if isinstance(data_index, slice):
try:
return self.extract_feature_by_slice(data_index, j)
except ExtractBySliceNotSupportedError:
# Accessing by each index, copy occurs
current, stop, step = data_index.indices(self.dataset_length)
res = [self.extract_feature(i, j) for i in
six.moves.range(current, stop, step)]
elif isinstance(data_index, (list, numpy.ndarray)):
if len(data_index) == 0:
try:
# HACKING
return self.extract_feature_by_slice(slice(0, 0, 1), j)
except ExtractBySliceNotSupportedError:
res = []
else:
if isinstance(data_index[0], (bool, numpy.bool, numpy.bool_)):
# Access by bool flag list
if len(data_index) != self.dataset_length:
raise ValueError(
'Feature index wrong length {} instead of'
' {}'.format(len(data_index),
self.dataset_length))
data_index = numpy.argwhere(data_index).ravel()
res = [self.extract_feature(i, j) for i in data_index]
else:
# `data_index` is expected to be `int`
return self.extract_feature(data_index, j)
try:
feature = numpy.asarray(res)
except ValueError:
feature = numpy.empty(len(res), dtype=object)
feature[:] = res[:]
return feature
================================================
FILE: chainer_chemistry/dataset/indexers/__init__.py
================================================
from chainer_chemistry.dataset.indexers.numpy_tuple_dataset_feature_indexer import NumpyTupleDatasetFeatureIndexer # NOQA
================================================
FILE: chainer_chemistry/dataset/indexers/numpy_tuple_dataset_feature_indexer.py
================================================
from chainer_chemistry.dataset.indexer import BaseFeatureIndexer
class NumpyTupleDatasetFeatureIndexer(BaseFeatureIndexer):
"""FeatureIndexer for NumpyTupleDataset
Args:
dataset (NumpyTupleDataset): dataset instance
"""
def __init__(self, dataset):
super(NumpyTupleDatasetFeatureIndexer, self).__init__(dataset)
self.datasets = dataset.get_datasets()
def features_length(self):
return len(self.datasets)
def extract_feature_by_slice(self, slice_index, j):
return self.datasets[j][slice_index]
def extract_feature(self, i, j):
return self.datasets[j][i]
================================================
FILE: chainer_chemistry/dataset/networkx_preprocessors/base_networkx.py
================================================
import networkx
import numpy
import chainer
from chainer_chemistry.dataset.graph_dataset.base_graph_dataset import PaddingGraphDataset, SparseGraphDataset # NOQA
from chainer_chemistry.dataset.graph_dataset.base_graph_data import PaddingGraphData, SparseGraphData # NOQA
from chainer_chemistry.dataset.graph_dataset.feature_converters import batch_without_padding # NOQA
class BaseNetworkxPreprocessor(object):
"""Base class to preprocess `Networkx::Graph` object"""
def __init__(self, *args, **kwargs):
pass
def get_x(self, graph):
if 'x' in graph.graph:
x = graph.graph['x']
else:
feature_dim, = graph.nodes[0]['x'].shape
x = numpy.empty((graph.number_of_nodes(), feature_dim),
dtype=numpy.float32)
for v, data in graph.nodes.data():
x[v] = data['x']
return x
def get_y(self, graph):
if 'y' in graph.graph:
y = graph.graph['y']
else:
y = numpy.empty(graph.number_of_nodes(), dtype=numpy.int32)
for v, data in graph.nodes.data():
y[v] = data['y']
return y
class BasePaddingNetworkxPreprocessor(BaseNetworkxPreprocessor):
"""Base class to preprocess `Networkx::Graph` into `PaddingGraphDataset`
""" # NOQA
def __init__(self, use_coo=False, *args, **kwargs):
self.use_coo = use_coo
def construct_data(self, graph):
"""Construct `PaddingGraphData` from `Networkx::Graph`
Args:
graph (Networkx::Graph): graph
Returns:
PaddingGraphData: graph data of padding pattern
"""
if not self.use_coo:
return PaddingGraphData(
x=self.get_x(graph),
adj=networkx.to_numpy_array(graph, dtype=numpy.float32),
y=self.get_y(graph),
label_num=graph.graph['label_num']
)
n_edges = graph.number_of_edges() * 2
row = numpy.empty((n_edges), dtype=numpy.int)
col = numpy.empty((n_edges), dtype=numpy.int)
data = numpy.ones((n_edges), dtype=numpy.float32)
for i, edge in enumerate(graph.edges):
row[2 * i] = edge[0]
row[2 * i + 1] = edge[1]
col[2 * i] = edge[1]
col[2 * i + 1] = edge[0]
# ensure row is sorted
if not numpy.all(row[:-1] <= row[1:]):
order = numpy.argsort(row)
row = row[order]
col = col[order]
assert numpy.all(row[:-1] <= row[1:])
adj = chainer.utils.CooMatrix(
data=data, row=row, col=col,
shape=(graph.number_of_nodes(), graph.number_of_nodes()),
order='C')
return PaddingGraphData(
x=self.get_x(graph),
adj=adj,
y=self.get_y(graph),
label_num=graph.graph['label_num']
)
def create_dataset(self, graph_list):
"""Create `PaddingGraphDataset` from list of `Networkx::Graph`
Args:
graph_list (list[Networkx::Graph]): list of graphs
Returns:
PaddingGraphDataset: graph dataset of padding pattern
"""
data_list = [
self.construct_data(graph) for graph in graph_list
]
dataset = PaddingGraphDataset(data_list)
dataset.register_feature('label_num', batch_without_padding)
return dataset
class BaseSparseNetworkxPreprocessor(BaseNetworkxPreprocessor):
"""Base class to preprocess `Networkx::Graph` into `SparseGraphDataset`
"""
def construct_data(self, graph):
"""Construct `SparseGraphData` from `Networkx::Graph`
Args:
graph (Networkx::Graph): graph
Returns:
SparseGraphData: graph data of sparse pattern
"""
edge_index = numpy.empty((2, graph.number_of_edges() * 2),
dtype=numpy.int)
for i, edge in enumerate(graph.edges):
edge_index[0][2 * i] = edge[0]
edge_index[0][2 * i + 1] = edge[1]
edge_index[1][2 * i] = edge[1]
edge_index[1][2 * i + 1] = edge[0]
return SparseGraphData(
x=self.get_x(graph),
edge_index=numpy.array(edge_index, dtype=numpy.int),
y=self.get_y(graph),
label_num=graph.graph['label_num']
)
def add_self_loop(self, graph):
for v in range(graph.number_of_nodes()):
graph.add_edge(v, v)
return graph
def create_dataset(self, graph_list):
"""Create `SparseGraphDataset` from list of `Networkx::Graph`
Args:
graph_list (list[Networkx::Graph]): list of graphs
Returns:
SparseGraphDataset: graph dataset of sparse pattern
"""
data_list = [
self.construct_data(graph) for graph in graph_list
]
dataset = SparseGraphDataset(data_list)
dataset.register_feature('label_num', batch_without_padding)
return dataset
================================================
FILE: chainer_chemistry/dataset/networkx_preprocessors/reddit_coo.py
================================================
import os
import numpy
import scipy
import chainer
from chainer_chemistry.dataset.graph_dataset.base_graph_data import PaddingGraphData # NOQA
def get_reddit_coo_data(dirpath):
"""Temporary function to obtain reddit coo data for GIN
(because it takes to much time to convert it to networkx)
Returns:
PaddingGraphData: `PaddingGraphData` of reddit
"""
print("Loading node feature and label")
reddit_data = numpy.load(os.path.join(dirpath, "reddit_data.npz"))
print("Loading edge data")
coo_adj = scipy.sparse.load_npz(os.path.join(dirpath, "reddit_graph.npz"))
row = coo_adj.row.astype(numpy.int32)
col = coo_adj.col.astype(numpy.int32)
data = coo_adj.data.astype(numpy.float32)
# ensure row is sorted
if not numpy.all(row[:-1] <= row[1:]):
order = numpy.argsort(row)
row = row[order]
col = col[order]
assert numpy.all(row[:-1] <= row[1:])
adj = chainer.utils.CooMatrix(
data=data, row=row, col=col,
shape=coo_adj.shape,
order='C')
return PaddingGraphData(
x=reddit_data['feature'].astype(numpy.float32),
adj=adj,
y=reddit_data['label'].astype(numpy.int32),
label_num=41
)
================================================
FILE: chainer_chemistry/dataset/parsers/__init__.py
================================================
from chainer_chemistry.dataset.parsers import base_parser # NOQA
from chainer_chemistry.dataset.parsers import csv_file_parser # NOQA
from chainer_chemistry.dataset.parsers import data_frame_parser # NOQA
from chainer_chemistry.dataset.parsers import sdf_file_parser # NOQA
from chainer_chemistry.dataset.parsers import smiles_parser # NOQA
from chainer_chemistry.dataset.parsers.base_parser import BaseFileParser # NOQA
from chainer_chemistry.dataset.parsers.base_parser import BaseParser # NOQA
from chainer_chemistry.dataset.parsers.csv_file_parser import CSVFileParser # NOQA
from chainer_chemistry.dataset.parsers.data_frame_parser import DataFrameParser # NOQA
from chainer_chemistry.dataset.parsers.sdf_file_parser import SDFFileParser # NOQA
from chainer_chemistry.dataset.parsers.smiles_parser import SmilesParser # NOQA
================================================
FILE: chainer_chemistry/dataset/parsers/base_parser.py
================================================
class BaseParser(object):
def __init__(self):
pass
class BaseFileParser(BaseParser):
"""base class for file parser"""
def __init__(self, preprocessor):
super(BaseFileParser, self).__init__()
self.preprocessor = preprocessor
def parse(self, filepath):
raise NotImplementedError
================================================
FILE: chainer_chemistry/dataset/parsers/csv_file_parser.py
================================================
import pandas
from chainer_chemistry.dataset.parsers.data_frame_parser import DataFrameParser
class CSVFileParser(DataFrameParser):
"""csv file parser
This FileParser parses .csv file.
It should contain column which contain SMILES as input, and
label column which is the target to predict.
Args:
preprocessor (BasePreprocessor): preprocessor instance
labels (str or list): labels column
smiles_col (str): smiles column
postprocess_label (Callable): post processing function if necessary
postprocess_fn (Callable): post processing function if necessary
logger:
"""
def __init__(self, preprocessor,
labels=None,
smiles_col='smiles',
postprocess_label=None, postprocess_fn=None,
logger=None):
super(CSVFileParser, self).__init__(
preprocessor, labels=labels, smiles_col=smiles_col,
postprocess_label=postprocess_label, postprocess_fn=postprocess_fn,
logger=logger)
def parse(self, filepath, return_smiles=False, target_index=None,
return_is_successful=False):
"""parse csv file using `preprocessor`
Label is extracted from `labels` columns and input features are
extracted from smiles information in `smiles` column.
Args:
filepath (str): file path to be parsed.
return_smiles (bool): If set to True, this function returns
preprocessed dataset and smiles list.
If set to False, this function returns preprocessed dataset and
`None`.
target_index (list or None): target index list to partially extract
dataset. If None (default), all examples are parsed.
return_is_successful (bool): If set to `True`, boolean list is
returned in the key 'is_successful'. It represents
preprocessing has succeeded or not for each SMILES.
If set to False, `None` is returned in the key 'is_success'.
Returns (dict): dictionary that contains Dataset, 1-d numpy array with
dtype=object(string) which is a vector of smiles for each example
or None.
"""
df = pandas.read_csv(filepath)
return super(CSVFileParser, self).parse(
df, return_smiles=return_smiles, target_index=target_index,
return_is_successful=return_is_successful)
def extract_total_num(self, filepath):
"""Extracts total number of data which can be parsed
We can use this method to determine the value fed to `target_index`
option of `parse` method. For example, if we want to extract input
feature from 10% of whole dataset, we need to know how many samples
are in a file. The returned value of this method may not to be same as
the final dataset size.
Args:
filepath (str): file path of to check the total number.
Returns (int): total number of dataset can be parsed.
"""
df = pandas.read_csv(filepath)
return len(df)
================================================
FILE: chainer_chemistry/dataset/parsers/data_frame_parser.py
================================================
from logging import getLogger
import numpy
from rdkit import Chem
from tqdm import tqdm
from chainer_chemistry.dataset.parsers.base_parser import BaseFileParser
from chainer_chemistry.dataset.preprocessors.common import MolFeatureExtractionError # NOQA
from chainer_chemistry.dataset.preprocessors.mol_preprocessor import MolPreprocessor # NOQA
import traceback
class DataFrameParser(BaseFileParser):
"""data frame parser
This FileParser parses pandas dataframe.
It should contain column which contain SMILES as input, and
label column which is the target to predict.
Args:
preprocessor (BasePreprocessor): preprocessor instance
labels (str or list or None): labels column
smiles_col (str): smiles column
postprocess_label (Callable): post processing function if necessary
postprocess_fn (Callable): post processing function if necessary
logger:
"""
def __init__(self, preprocessor,
labels=None,
smiles_col='smiles',
postprocess_label=None, postprocess_fn=None,
logger=None):
super(DataFrameParser, self).__init__(preprocessor)
if isinstance(labels, str):
labels = [labels, ]
self.labels = labels # type: list
self.smiles_col = smiles_col
self.postprocess_label = postprocess_label
self.postprocess_fn = postprocess_fn
self.logger = logger or getLogger(__name__)
def parse(self, df, return_smiles=False, target_index=None,
return_is_successful=False):
"""parse DataFrame using `preprocessor`
Label is extracted from `labels` columns and input features are
extracted from smiles information in `smiles` column.
Args:
df (pandas.DataFrame): dataframe to be parsed.
return_smiles (bool): If set to `True`, smiles list is returned in
the key 'smiles', it is a list of SMILES from which input
features are successfully made.
If set to `False`, `None` is returned in the key 'smiles'.
target_index (list or None): target index list to partially extract
dataset. If None (default), all examples are parsed.
return_is_successful (bool): If set to `True`, boolean list is
returned in the key 'is_successful'. It represents
preprocessing has succeeded or not for each SMILES.
If set to False, `None` is returned in the key 'is_success'.
Returns (dict): dictionary that contains Dataset, 1-d numpy array with
dtype=object(string) which is a vector of smiles for each example
or None.
"""
logger = self.logger
pp = self.preprocessor
smiles_list = []
is_successful_list = []
# counter = 0
if isinstance(pp, MolPreprocessor):
if target_index is not None:
df = df.iloc[target_index]
features = None
smiles_index = df.columns.get_loc(self.smiles_col)
if self.labels is None:
labels_index = [] # dummy list
else:
labels_index = [df.columns.get_loc(c) for c in self.labels]
total_count = df.shape[0]
fail_count = 0
success_count = 0
for row in tqdm(df.itertuples(index=False), total=df.shape[0]):
smiles = row[smiles_index]
# TODO(Nakago): Check.
# currently it assumes list
labels = [row[i] for i in labels_index]
try:
mol = Chem.MolFromSmiles(smiles)
if mol is None:
fail_count += 1
if return_is_successful:
is_successful_list.append(False)
continue
# Note that smiles expression is not unique.
# we obtain canonical smiles
canonical_smiles, mol = pp.prepare_smiles_and_mol(mol)
input_features = pp.get_input_features(mol)
# Extract label
if self.postprocess_label is not None:
labels = self.postprocess_label(labels)
if return_smiles:
smiles_list.append(canonical_smiles)
except MolFeatureExtractionError as e: # NOQA
# This is expected error that extracting feature failed,
# skip this molecule.
fail_count += 1
if return_is_successful:
is_successful_list.append(False)
continue
except Exception as e:
logger.warning('parse(), type: {}, {}'
.format(type(e).__name__, e.args))
logger.info(traceback.format_exc())
fail_count += 1
if return_is_successful:
is_successful_list.append(False)
continue
# Initialize features: list of list
if features is None:
if isinstance(input_features, tuple):
num_features = len(input_features)
else:
num_features = 1
if self.labels is not None:
num_features += 1
features = [[] for _ in range(num_features)]
if isinstance(input_features, tuple):
for i in range(len(input_features)):
features[i].append(input_features[i])
else:
features[0].append(input_features)
if self.labels is not None:
features[len(features) - 1].append(labels)
success_count += 1
if return_is_successful:
is_successful_list.append(True)
ret = []
for feature in features:
try:
feat_array = numpy.asarray(feature)
except ValueError:
# Temporal work around.
# See,
# https://stackoverflow.com/questions/26885508/why-do-i-get-error-trying-to-cast-np-arraysome-list-valueerror-could-not-broa
feat_array = numpy.empty(len(feature), dtype=numpy.ndarray)
feat_array[:] = feature[:]
ret.append(feat_array)
result = tuple(ret)
logger.info('Preprocess finished. FAIL {}, SUCCESS {}, TOTAL {}'
.format(fail_count, success_count, total_count))
else:
raise NotImplementedError
smileses = numpy.array(
smiles_list, dtype=object) if return_smiles else None
if return_is_successful:
is_successful = numpy.array(is_successful_list)
else:
is_successful = None
if isinstance(result, tuple):
if self.postprocess_fn is not None:
result = self.postprocess_fn(*result)
dataset = pp.create_dataset(*result)
else:
if self.postprocess_fn is not None:
result = self.postprocess_fn(result)
dataset = pp.create_dataset(*result)
return {"dataset": dataset,
"smiles": smileses,
"is_successful": is_successful}
def extract_total_num(self, df):
"""Extracts total number of data which can be parsed
We can use this method to determine the value fed to `target_index`
option of `parse` method. For example, if we want to extract input
feature from 10% of whole dataset, we need to know how many samples
are in a file. The returned value of this method may not to be same as
the final dataset size.
Args:
df (pandas.DataFrame): dataframe to be parsed.
Returns (int): total number of dataset can be parsed.
"""
return len(df)
================================================
FILE: chainer_chemistry/dataset/parsers/sdf_file_parser.py
================================================
from logging import getLogger
import numpy
from rdkit import Chem
from tqdm import tqdm
from chainer_chemistry.dataset.parsers.base_parser import BaseFileParser
from chainer_chemistry.dataset.preprocessors.common import MolFeatureExtractionError # NOQA
from chainer_chemistry.dataset.preprocessors.mol_preprocessor import MolPreprocessor # NOQA
class SDFFileParser(BaseFileParser):
"""sdf file parser
Args:
preprocessor (BasePreprocessor): preprocessor instance
labels (str or list): labels column
postprocess_label (Callable): post processing function if necessary
postprocess_fn (Callable): post processing function if necessary
logger:
"""
def __init__(self, preprocessor, labels=None, postprocess_label=None,
postprocess_fn=None, logger=None):
super(SDFFileParser, self).__init__(preprocessor)
self.labels = labels
self.postprocess_label = postprocess_label
self.postprocess_fn = postprocess_fn
self.logger = logger or getLogger(__name__)
def parse(self, filepath, return_smiles=False, target_index=None,
return_is_successful=False):
"""parse sdf file using `preprocessor`
Note that label is extracted from preprocessor's method.
Args:
filepath (str): file path to be parsed.
return_smiles (bool): If set to True, this function returns
preprocessed dataset and smiles list.
If set to False, this function returns preprocessed dataset and
`None`.
target_index (list or None): target index list to partially extract
dataset. If None (default), all examples are parsed.
return_is_successful (bool): If set to `True`, boolean list is
returned in the key 'is_successful'. It represents
preprocessing has succeeded or not for each SMILES.
If set to False, `None` is returned in the key 'is_success'.
Returns (dict): dictionary that contains Dataset, 1-d numpy array with
dtype=object(string) which is a vector of smiles for each example
or None.
"""
logger = self.logger
pp = self.preprocessor
smiles_list = []
is_successful_list = []
if isinstance(pp, MolPreprocessor):
mol_supplier = Chem.SDMolSupplier(filepath)
if target_index is None:
target_index = list(range(len(mol_supplier)))
features = None
total_count = len(mol_supplier)
fail_count = 0
success_count = 0
for index in tqdm(target_index):
# `mol_supplier` does not accept numpy.integer, we must use int
mol = mol_supplier[int(index)]
if mol is None:
fail_count += 1
if return_is_successful:
is_successful_list.append(False)
continue
try:
# Labels need to be extracted from `mol` before standardize
# smiles.
if self.labels is not None:
label = pp.get_label(mol, self.labels)
if self.postprocess_label is not None:
label = self.postprocess_label(label)
# Note that smiles expression is not unique.
# we obtain canonical smiles
smiles = Chem.MolToSmiles(mol)
mol = Chem.MolFromSmiles(smiles)
canonical_smiles, mol = pp.prepare_smiles_and_mol(mol)
input_features = pp.get_input_features(mol)
# Initialize features: list of list
if features is None:
if isinstance(input_features, tuple):
num_features = len(input_features)
else:
num_features = 1
if self.labels is not None:
num_features += 1
features = [[] for _ in range(num_features)]
if return_smiles:
smiles_list.append(canonical_smiles)
except MolFeatureExtractionError as e: # NOQA
# This is expected error that extracting feature failed,
# skip this molecule.
fail_count += 1
if return_is_successful:
is_successful_list.append(False)
continue
except Exception as e:
logger.warning('parse() error, type: {}, {}'
.format(type(e).__name__, e.args))
fail_count += 1
if return_is_successful:
is_successful_list.append(False)
continue
if isinstance(input_features, tuple):
for i in range(len(input_features)):
features[i].append(input_features[i])
else:
features[0].append(input_features)
if self.labels is not None:
features[len(features) - 1].append(label)
success_count += 1
if return_is_successful:
is_successful_list.append(True)
ret = []
for feature in features:
try:
feat_array = numpy.asarray(feature)
except ValueError:
# Temporal work around to convert object-type list into
# numpy array.
# See, https://goo.gl/kgJXwb
feat_array = numpy.empty(len(feature), dtype=numpy.ndarray)
feat_array[:] = feature[:]
ret.append(feat_array)
result = tuple(ret)
logger.info('Preprocess finished. FAIL {}, SUCCESS {}, TOTAL {}'
.format(fail_count, success_count, total_count))
else:
# Spec not finalized yet for general case
result = pp.process(filepath)
smileses = numpy.array(
smiles_list, dtype=object) if return_smiles else None
if return_is_successful:
is_successful = numpy.array(is_successful_list)
else:
is_successful = None
if isinstance(result, tuple):
if self.postprocess_fn is not None:
result = self.postprocess_fn(*result)
dataset = pp.create_dataset(*result)
else:
if self.postprocess_fn is not None:
result = self.postprocess_fn(result)
dataset = pp.create_dataset(*result)
return {"dataset": dataset,
"smiles": smileses,
"is_successful": is_successful}
def extract_total_num(self, filepath):
"""Extracts total number of data which can be parsed
We can use this method to determine the value fed to `target_index`
option of `parse` method. For example, if we want to extract input
feature from 10% of whole dataset, we need to know how many samples
are in a file. The returned value of this method may not to be same as
the final dataset size.
Args:
filepath (str): file path of to check the total number.
Returns (int): total number of dataset can be parsed.
"""
mol_supplier = Chem.SDMolSupplier(filepath)
return len(mol_supplier)
================================================
FILE: chainer_chemistry/dataset/parsers/smiles_parser.py
================================================
import pandas
from chainer_chemistry.dataset.parsers.data_frame_parser import DataFrameParser
class SmilesParser(DataFrameParser):
"""smiles parser
It parses `smiles_list`, which is a list of string of smiles.
Args:
preprocessor (BasePreprocessor): preprocessor instance
postprocess_label (Callable): post processing function if necessary
postprocess_fn (Callable): post processing function if necessary
logger:
"""
def __init__(self, preprocessor,
postprocess_label=None, postprocess_fn=None,
logger=None):
super(SmilesParser, self).__init__(
preprocessor, labels=None, smiles_col='smiles',
postprocess_label=postprocess_label, postprocess_fn=postprocess_fn,
logger=logger)
def parse(self, smiles_list, return_smiles=False, target_index=None,
return_is_successful=False):
"""parse `smiles_list` using `preprocessor`
Label is extracted from `labels` columns and input features are
extracted from smiles information in `smiles` column.
Args:
smiles_list (list): list of strings of smiles
return_smiles (bool): If set to True, this function returns
preprocessed dataset and smiles list.
If set to False, this function returns preprocessed dataset and
`None`.
target_index (list or None): target index list to partially extract
dataset. If None (default), all examples are parsed.
return_is_successful (bool): If set to `True`, boolean list is
returned in the key 'is_successful'. It represents
preprocessing has succeeded or not for each SMILES.
If set to False, `None` is returned in the key 'is_success'.
Returns (dict): dictionary that contains Dataset, 1-d numpy array with
dtype=object(string) which is a vector of smiles for each example
or None.
"""
df = pandas.DataFrame({'smiles': smiles_list})
return super(SmilesParser, self).parse(
df, return_smiles=return_smiles, target_index=target_index,
return_is_successful=return_is_successful)
def extract_total_num(self, smiles_list):
"""Extracts total number of data which can be parsed
We can use this method to determine the value fed to `target_index`
option of `parse` method. For example, if we want to extract input
feature from 10% of whole dataset, we need to know how many samples
are in a file. The returned value of this method may not to be same as
the final dataset size.
Args:
smiles_list (list): list of strings of smiles
Returns (int): total number of dataset can be parsed.
"""
return len(smiles_list)
================================================
FILE: chainer_chemistry/dataset/preprocessors/__init__.py
================================================
from chainer_chemistry.dataset.preprocessors.atomic_number_preprocessor import AtomicNumberPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.base_preprocessor import BasePreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.cgcnn_preprocessor import CGCNNPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.common import construct_adj_matrix # NOQA
from chainer_chemistry.dataset.preprocessors.common import construct_atomic_number_array # NOQA
from chainer_chemistry.dataset.preprocessors.common import construct_discrete_edge_matrix # NOQA
from chainer_chemistry.dataset.preprocessors.common import construct_supernode_feature # NOQA
from chainer_chemistry.dataset.preprocessors.common import MolFeatureExtractionError # NOQA
from chainer_chemistry.dataset.preprocessors.common import type_check_num_atoms # NOQA
from chainer_chemistry.dataset.preprocessors.ecfp_preprocessor import ECFPPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.ggnn_preprocessor import GGNNPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.gin_preprocessor import GINPreprocessor, GINSparsePreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.gnnfilm_preprocessor import GNNFiLMPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.gwm_preprocessor import GGNNGWMPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.gwm_preprocessor import GINGWMPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.gwm_preprocessor import NFPGWMPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.gwm_preprocessor import RSGCNGWMPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.megnet_preprocessor import MEGNetPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.mol_preprocessor import MolPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.nfp_preprocessor import NFPPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.relgat_preprocessor import RelGATPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.relgcn_preprocessor import RelGCNPreprocessor, RelGCNSparsePreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.rsgcn_preprocessor import RSGCNPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.schnet_preprocessor import SchNetPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.weavenet_preprocessor import WeaveNetPreprocessor # NOQA
preprocess_method_dict = {
'ecfp': ECFPPreprocessor,
'nfp': NFPPreprocessor,
'nfp_gwm': NFPGWMPreprocessor,
'ggnn': GGNNPreprocessor,
'ggnn_gwm': GGNNGWMPreprocessor,
'gin': GINPreprocessor,
'gin_gwm': GINGWMPreprocessor,
'schnet': SchNetPreprocessor,
'weavenet': WeaveNetPreprocessor,
'relgcn': RelGCNPreprocessor,
'rsgcn': RSGCNPreprocessor,
'rsgcn_gwm': RSGCNGWMPreprocessor,
'relgat': RelGATPreprocessor,
'relgcn_sparse': RelGCNSparsePreprocessor,
'gin_sparse': GINSparsePreprocessor,
'gnnfilm': GNNFiLMPreprocessor,
'megnet': MEGNetPreprocessor,
'cgcnn': CGCNNPreprocessor
}
================================================
FILE: chainer_chemistry/dataset/preprocessors/atomic_number_preprocessor.py
================================================
from chainer_chemistry.dataset.preprocessors.common \
import construct_atomic_number_array
from chainer_chemistry.dataset.preprocessors.common import type_check_num_atoms
from chainer_chemistry.dataset.preprocessors.mol_preprocessor \
import MolPreprocessor
class AtomicNumberPreprocessor(MolPreprocessor):
"""Atomic number Preprocessor
Args:
max_atoms (int): Max number of atoms for each molecule, if the
number of atoms is more than this value, this data is simply
ignored.
Setting negative value indicates no limit for max atoms.
out_size (int): It specifies the size of array returned by
`get_input_features`.
If the number of atoms in the molecule is less than this value,
the returned arrays is padded to have fixed size.
Setting negative value indicates do not pad returned array.
"""
def __init__(self, max_atoms=-1, out_size=-1):
super(AtomicNumberPreprocessor, self).__init__()
if max_atoms >= 0 and out_size >= 0 and max_atoms > out_size:
raise ValueError('max_atoms {} must be less or equal to '
'out_size {}'.format(max_atoms, out_size))
self.max_atoms = max_atoms
self.out_size = out_size
def get_input_features(self, mol):
"""get input features
Args:
mol (Mol):
Returns:
"""
type_check_num_atoms(mol, self.max_atoms)
atom_array = construct_atomic_number_array(mol, out_size=self.out_size)
return atom_array
================================================
FILE: chainer_chemistry/dataset/preprocessors/base_preprocessor.py
================================================
"""
Preprocessor supports feature extraction for each model (network)
"""
class BasePreprocessor(object):
"""Base class for preprocessor"""
def __init__(self):
pass
def process(self, filepath):
pass
================================================
FILE: chainer_chemistry/dataset/preprocessors/cgcnn_preprocessor.py
================================================
from logging import getLogger
import numpy
import os
import shutil
from chainer.dataset import download
from chainer_chemistry.dataset.preprocessors.mol_preprocessor import MolPreprocessor # NOQA
from chainer_chemistry.dataset.utils import GaussianDistance
from chainer_chemistry.utils import load_json
download_url = 'https://raw.githubusercontent.com/txie-93/cgcnn/master/data/sample-regression/atom_init.json' # NOQA
file_name_atom_init_json = 'atom_init.json'
_root = 'pfnet/chainer/cgcnn'
def get_atom_init_json_filepath(download_if_not_exist=True):
"""Construct a filepath which stores atom_init_json
This method check whether the file exist or not, and downloaded it if
necessary.
Args:
download_if_not_exist (bool): If `True` download dataset
if it is not downloaded yet.
Returns (str): file path for atom_init_json
"""
cache_root = download.get_dataset_directory(_root)
cache_path = os.path.join(cache_root, file_name_atom_init_json)
if not os.path.exists(cache_path) and download_if_not_exist:
logger = getLogger(__name__)
logger.info('Downloading atom_init.json...')
download_file_path = download.cached_download(download_url)
shutil.copy(download_file_path, cache_path)
return cache_path
class CGCNNPreprocessor(MolPreprocessor):
"""CGCNNPreprocessor
Args:
For Molecule: TODO
"""
def __init__(self, max_num_nbr=12, max_radius=8, expand_dim=40):
super(CGCNNPreprocessor, self).__init__()
self.max_num_nbr = max_num_nbr
self.max_radius = max_radius
self.gdf = GaussianDistance(centers=numpy.linspace(0, 8, expand_dim))
feat_dict = load_json(get_atom_init_json_filepath())
self.atom_features = {int(key): numpy.array(value,
dtype=numpy.float32)
for key, value in feat_dict.items()}
def get_input_features(self, mol):
raise NotImplementedError()
================================================
FILE: chainer_chemistry/dataset/preprocessors/common.py
================================================
"""Common preprocess method is gethered in this file"""
import numpy
from rdkit import Chem
from rdkit.Chem import rdmolops
from chainer_chemistry.config import MAX_ATOMIC_NUM
class MolFeatureExtractionError(Exception):
pass
# --- Type check ---
def type_check_num_atoms(mol, num_max_atoms=-1):
"""Check number of atoms in `mol` does not exceed `num_max_atoms`
If number of atoms in `mol` exceeds the number `num_max_atoms`, it will
raise `MolFeatureExtractionError` exception.
Args:
mol (Mol):
num_max_atoms (int): If negative value is set, not check number of
atoms.
"""
num_atoms = mol.GetNumAtoms()
if num_max_atoms >= 0 and num_atoms > num_max_atoms:
# Skip extracting feature. ignore this case.
raise MolFeatureExtractionError(
'Number of atoms in mol {} exceeds num_max_atoms {}'
.format(num_atoms, num_max_atoms))
# --- Atom preprocessing ---
def construct_atomic_number_array(mol, out_size=-1):
"""Returns atomic numbers of atoms consisting a molecule.
Args:
mol (rdkit.Chem.Mol): Input molecule.
out_size (int): The size of returned array.
If this option is negative, it does not take any effect.
Otherwise, it must be larger than the number of atoms
in the input molecules. In that case, the tail of
the array is padded with zeros.
Returns:
numpy.ndarray: an array consisting of atomic numbers
of atoms in the molecule.
"""
atom_list = [a.GetAtomicNum() for a in mol.GetAtoms()]
n_atom = len(atom_list)
if out_size < 0:
return numpy.array(atom_list, dtype=numpy.int32)
elif out_size >= n_atom:
# 'empty' padding for atom_list
# 0 represents empty place for atom
atom_array = numpy.zeros(out_size, dtype=numpy.int32)
atom_array[:n_atom] = numpy.array(atom_list, dtype=numpy.int32)
return atom_array
else:
raise ValueError('`out_size` (={}) must be negative or '
'larger than or equal to the number '
'of atoms in the input molecules (={})'
'.'.format(out_size, n_atom))
# --- Adjacency matrix preprocessing ---
def construct_adj_matrix(mol, out_size=-1, self_connection=True):
"""Returns the adjacent matrix of the given molecule.
This function returns the adjacent matrix of the given molecule.
Contrary to the specification of
:func:`rdkit.Chem.rdmolops.GetAdjacencyMatrix`,
The diagonal entries of the returned matrix are all-one.
Args:
mol (rdkit.Chem.Mol): Input molecule.
out_size (int): The size of the returned matrix.
If this option is negative, it does not take any effect.
Otherwise, it must be larger than the number of atoms
in the input molecules. In that case, the adjacent
matrix is expanded and zeros are padded to right
columns and bottom rows.
self_connection (bool): Add self connection or not.
If True, diagonal element of adjacency matrix is filled with 1.
Returns:
adj_array (numpy.ndarray): The adjacent matrix of the input molecule.
It is 2-dimensional array with shape (atoms1, atoms2), where
atoms1 & atoms2 represent from and to of the edge respectively.
If ``out_size`` is non-negative, the returned
its size is equal to that value. Otherwise,
it is equal to the number of atoms in the the molecule.
"""
adj = rdmolops.GetAdjacencyMatrix(mol)
s0, s1 = adj.shape
if s0 != s1:
raise ValueError('The adjacent matrix of the input molecule'
'has an invalid shape: ({}, {}). '
'It must be square.'.format(s0, s1))
if self_connection:
adj = adj + numpy.eye(s0)
if out_size < 0:
adj_array = adj.astype(numpy.float32)
elif out_size >= s0:
adj_array = numpy.zeros((out_size, out_size),
dtype=numpy.float32)
adj_array[:s0, :s1] = adj
else:
raise ValueError(
'`out_size` (={}) must be negative or larger than or equal to the '
'number of atoms in the input molecules (={}).'
.format(out_size, s0))
return adj_array
def construct_discrete_edge_matrix(mol, out_size=-1,
add_self_connection_channel=False):
"""Returns the edge-type dependent adjacency matrix of the given molecule.
Args:
mol (rdkit.Chem.Mol): Input molecule.
out_size (int): The size of the returned matrix.
If this option is negative, it does not take any effect.
Otherwise, it must be larger than the number of atoms
in the input molecules. In that case, the adjacent
matrix is expanded and zeros are padded to right
columns and bottom rows.
add_self_connection_channel (bool): Add self connection or not.
If True, adjacency matrix whose diagonal element filled with 1
is added to last channel.
Returns:
adj_array (numpy.ndarray): The adjacent matrix of the input molecule.
It is 3-dimensional array with shape (edge_type, atoms1, atoms2),
where edge_type represents the bond type,
atoms1 & atoms2 represent from and to of the edge respectively.
If ``out_size`` is non-negative, its size is equal to that value.
Otherwise, it is equal to the number of atoms in the the molecule.
"""
if mol is None:
raise MolFeatureExtractionError('mol is None')
N = mol.GetNumAtoms()
if out_size < 0:
size = N
elif out_size >= N:
size = out_size
else:
raise ValueError(
'out_size {} is smaller than number of atoms in mol {}'
.format(out_size, N))
if add_self_connection_channel:
adjs = numpy.zeros((5, size, size), dtype=numpy.float32)
else:
adjs = numpy.zeros((4, size, size), dtype=numpy.float32)
bond_type_to_channel = {
Chem.BondType.SINGLE: 0,
Chem.BondType.DOUBLE: 1,
Chem.BondType.TRIPLE: 2,
Chem.BondType.AROMATIC: 3
}
for bond in mol.GetBonds():
bond_type = bond.GetBondType()
ch = bond_type_to_channel[bond_type]
i = bond.GetBeginAtomIdx()
j = bond.GetEndAtomIdx()
adjs[ch, i, j] = 1.0
adjs[ch, j, i] = 1.0
if add_self_connection_channel:
adjs[-1] = numpy.eye(N)
return adjs
def mol_basic_info_feature(mol, atom_array, adj):
n_atoms = mol.GetNumAtoms()
if n_atoms != len(atom_array):
raise ValueError("[ERROR] n_atoms {} != len(atom_array) {}"
.format(n_atoms, len(atom_array)))
# Note: this is actual number of edges * 2.
n_edges = adj.sum()
return numpy.asarray([n_atoms, n_edges])
def mol_atom_type_feature(mol, atom_array, adj):
atom_count = numpy.bincount(atom_array, minlength=MAX_ATOMIC_NUM + 1)
return (atom_count > 0).astype(numpy.float)[1:]
def mol_atom_freq_feature(mol, atom_array, adj):
atom_count = numpy.bincount(atom_array, minlength=MAX_ATOMIC_NUM + 1)
return (atom_count / len(atom_array))[1:]
def mol_bond_type_feature(mol, atom_array, adj):
if adj.ndim == 2:
adj = numpy.expand_dims(adj, axis=0)
adj = adj.reshape((adj.shape[0], -1))
return adj.max(axis=1)
def mol_bond_freq_feature(mol, atom_array, adj):
if adj.ndim == 2:
adj = numpy.expand_dims(adj, axis=0)
adj = adj.reshape((adj.shape[0], -1))
adj_sum = adj.sum()
if adj_sum == 0:
return adj.sum(axis=1)
else:
return adj.sum(axis=1) / adj_sum
def construct_supernode_feature(mol, atom_array, adj, feature_functions=None):
"""Construct an input feature x' for a supernode
`out_size` is automatically inferred by `atom_array` and `adj`
Args:
mol (rdkit.Chem.Mol): Input molecule
atom_array (numpy.ndarray) : array of atoms
adj (numpy.ndarray): N by N 2-way array, or |E| by N by N 3-way array
where |E| is the number of edgetypes.
feature_functions (None or list): list of callable
Returns:
super_node_x (numpy.ndarray); 1-way array, the supernode feature.
len(super_node_x) will be 2 + 2 + MAX_ATOMIC_NUM*2 for 2-way adjs,
2 + 4*2 + MAX_ATOMIC_NUM*2 for 3-way adjs
"""
if feature_functions is None:
feature_functions = [
mol_basic_info_feature, mol_bond_type_feature,
mol_bond_freq_feature, mol_atom_type_feature,
mol_atom_freq_feature]
super_node_x = numpy.concatenate(
[func(mol, atom_array, adj) for func in feature_functions])
super_node_x = super_node_x.astype(numpy.float32)
return super_node_x
================================================
FILE: chainer_chemistry/dataset/preprocessors/ecfp_preprocessor.py
================================================
from logging import getLogger
import numpy
from rdkit.Chem import rdMolDescriptors
from chainer_chemistry.dataset.preprocessors.common import MolFeatureExtractionError # NOQA
from chainer_chemistry.dataset.preprocessors.mol_preprocessor import MolPreprocessor # NOQA
class ECFPPreprocessor(MolPreprocessor):
def __init__(self, radius=2):
super(ECFPPreprocessor, self).__init__()
self.radius = radius
def get_input_features(self, mol):
try:
fp = rdMolDescriptors.GetMorganFingerprintAsBitVect(mol,
self.radius)
except Exception as e:
logger = getLogger(__name__)
logger.debug('exception caught at ECFPPreprocessor:', e)
# Extracting feature failed
raise MolFeatureExtractionError
# TODO(Nakago): Test it.
return numpy.asarray(fp, numpy.float32)
================================================
FILE: chainer_chemistry/dataset/preprocessors/ggnn_preprocessor.py
================================================
import numpy
from chainer_chemistry.dataset.graph_dataset.base_graph_data import SparseGraphData # NOQA
from chainer_chemistry.dataset.graph_dataset.base_graph_dataset import SparseGraphDataset # NOQA
from chainer_chemistry.dataset.preprocessors.common \
import construct_atomic_number_array, construct_discrete_edge_matrix # NOQA
from chainer_chemistry.dataset.preprocessors.common import type_check_num_atoms # NOQA
from chainer_chemistry.dataset.preprocessors.mol_preprocessor import MolPreprocessor # NOQA
class GGNNPreprocessor(MolPreprocessor):
"""GGNN Preprocessor
Args:
max_atoms (int): Max number of atoms for each molecule, if the
number of atoms is more than this value, this data is simply
ignored.
Setting negative value indicates no limit for max atoms.
out_size (int): It specifies the size of array returned by
`get_input_features`.
If the number of atoms in the molecule is less than this value,
the returned arrays is padded to have fixed size.
Setting negative value indicates do not pad returned array.
add_Hs (bool): If True, implicit Hs are added.
kekulize (bool): If True, Kekulizes the molecule.
"""
def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
kekulize=False):
super(GGNNPreprocessor, self).__init__(
add_Hs=add_Hs, kekulize=kekulize)
if max_atoms >= 0 and out_size >= 0 and max_atoms > out_size:
raise ValueError('max_atoms {} must be less or equal to '
'out_size {}'.format(max_atoms, out_size))
self.max_atoms = max_atoms
self.out_size = out_size
def get_input_features(self, mol):
"""get input features
Args:
mol (Mol): Molecule input
Returns:
"""
type_check_num_atoms(mol, self.max_atoms)
atom_array = construct_atomic_number_array(mol, out_size=self.out_size)
adj_array = construct_discrete_edge_matrix(mol, out_size=self.out_size)
return atom_array, adj_array
class GGNNSparsePreprocessor(GGNNPreprocessor):
"""Sparse GGNN Preprocessor"""
def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
kekulize=False):
super(GGNNSparsePreprocessor, self).__init__(
max_atoms=max_atoms, out_size=out_size, add_Hs=add_Hs,
kekulize=kekulize)
def construct_sparse_data(self, x, adj, y):
"""Construct `SparseGraphData` from `x`, `adj`, `y`
Args:
x (numpy.ndarray): input feature
adj (numpy.ndarray): adjacency matrix
y (numpy.ndarray): output label
Returns:
SparseGraphData: graph data object for sparse pattern
"""
edge_index = [[], []]
edge_attr = []
label_num, n, _ = adj.shape
for label in range(label_num):
for i in range(n):
for j in range(n):
if adj[label, i, j] != 0.:
edge_index[0].append(i)
edge_index[1].append(i)
edge_attr.append(label)
return SparseGraphData(
x=x,
edge_index=numpy.array(edge_index, dtype=numpy.int),
edge_attr=numpy.array(edge_attr, dtype=numpy.int),
y=y
)
def create_dataset(self, *args, **kwargs):
"""Create `SparseGraphData` from list of `(x, adj, y)`
Returns:
SparseGraphDataset: graph dataset object for sparse pattern
"""
# args: (atom_array, adj_array, label_array)
data_list = [
self.construct_sparse_data(x, adj, y) for (x, adj, y) in zip(*args)
]
return SparseGraphDataset(data_list)
================================================
FILE: chainer_chemistry/dataset/preprocessors/gin_preprocessor.py
================================================
import numpy
from chainer_chemistry.dataset.graph_dataset.base_graph_data import SparseGraphData # NOQA
from chainer_chemistry.dataset.graph_dataset.base_graph_dataset import SparseGraphDataset # NOQA
from chainer_chemistry.dataset.preprocessors.common \
import construct_atomic_number_array, construct_adj_matrix # NOQA
from chainer_chemistry.dataset.preprocessors.common import type_check_num_atoms
from chainer_chemistry.dataset.preprocessors.mol_preprocessor import MolPreprocessor # NOQA
class GINPreprocessor(MolPreprocessor):
"""GIN Preprocessor
"""
def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False):
"""initialize the GIN Preprocessor.
Args:
max_atoms (int): Max number of atoms for each molecule,
if the number of atoms is more than this value,
this data is simply ignored.
Setting negative value indicates no limit for max atoms.
out_size (int): It specifies the size of array returned by
`get_input_features`.
If the number of atoms in the molecule is less than this value,
the returned arrays is padded to have fixed size.
Setting negative value indicates do not pad returned array.
add_Hs (bool): If true, add Hydrogens explicitly.
"""
super(GINPreprocessor, self).__init__(add_Hs=add_Hs)
if max_atoms >= 0 and out_size >= 0 and max_atoms > out_size:
raise ValueError('max_atoms {} must be less or equal to '
'out_size {}'.format(max_atoms, out_size))
self.max_atoms = max_atoms
self.out_size = out_size
def get_input_features(self, mol):
"""get input features
Args:
mol (Mol):
Returns:
"""
type_check_num_atoms(mol, self.max_atoms)
atom_array = construct_atomic_number_array(mol, out_size=self.out_size)
adj_array = construct_adj_matrix(mol, out_size=self.out_size)
return atom_array, adj_array
class GINSparsePreprocessor(MolPreprocessor):
"""Sparse GIN Preprocessor"""
def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False):
super(GINSparsePreprocessor, self).__init__(add_Hs=add_Hs)
if max_atoms >= 0 and out_size >= 0 and max_atoms > out_size:
raise ValueError('max_atoms {} must be less or equal to '
'out_size {}'.format(max_atoms, out_size))
self.max_atoms = max_atoms
self.out_size = out_size
def get_input_features(self, mol):
type_check_num_atoms(mol, self.max_atoms)
atom_array = construct_atomic_number_array(mol, out_size=self.out_size)
adj_array = construct_adj_matrix(mol, out_size=self.out_size)
return atom_array, adj_array
def construct_sparse_data(self, x, adj, y):
"""Construct `SparseGraphData` from `x`, `adj`, `y`
Args:
x (numpy.ndarray): input feature
adj (numpy.ndarray): adjacency matrix
y (numpy.ndarray): output label
Returns:
SparseGraphData: graph data object for sparse pattern
"""
edge_index = [[], []]
n, _ = adj.shape
for i in range(n):
for j in range(n):
if adj[i, j] != 0.:
edge_index[0].append(i)
edge_index[1].append(j)
return SparseGraphData(
x=x,
edge_index=numpy.array(edge_index, dtype=numpy.int),
y=y
)
def create_dataset(self, *args, **kwargs):
"""Create `SparseGraphData` from list of `(x, adj, y)`
Returns:
SparseGraphDataset: graph dataset object for sparse pattern
"""
# args: (atom_array, adj_array, label_array)
data_list = [
self.construct_sparse_data(x, adj, y) for (x, adj, y) in zip(*args)
]
return SparseGraphDataset(data_list)
================================================
FILE: chainer_chemistry/dataset/preprocessors/gnnfilm_preprocessor.py
================================================
from chainer_chemistry.dataset.preprocessors.common \
import construct_atomic_number_array, construct_discrete_edge_matrix # NOQA
from chainer_chemistry.dataset.preprocessors.common import type_check_num_atoms # NOQA
from chainer_chemistry.dataset.preprocessors.mol_preprocessor import MolPreprocessor # NOQA
class GNNFiLMPreprocessor(MolPreprocessor):
"""GNNFiLM Preprocessor
Args:
max_atoms (int): Max number of atoms for each molecule, if the
number of atoms is more than this value, this data is simply
ignored.
Setting negative value indicates no limit for max atoms.
out_size (int): It specifies the size of array returned by
`get_input_features`.
If the number of atoms in the molecule is less than this value,
the returned arrays is padded to have fixed size.
Setting negative value indicates do not pad returned array.
add_Hs (bool): If True, implicit Hs are added.
kekulize (bool): If True, Kekulizes the molecule.
"""
def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
kekulize=False):
super(GNNFiLMPreprocessor, self).__init__(
add_Hs=add_Hs, kekulize=kekulize)
if max_atoms >= 0 and out_size >= 0 and max_atoms > out_size:
raise ValueError('max_atoms {} must be less or equal to '
'out_size {}'.format(max_atoms, out_size))
self.max_atoms = max_atoms
self.out_size = out_size
def get_input_features(self, mol):
"""get input features
Args:
mol (Mol): Molecule input
Returns:
"""
type_check_num_atoms(mol, self.max_atoms)
atom_array = construct_atomic_number_array(mol, out_size=self.out_size)
adj_array = construct_discrete_edge_matrix(
mol, out_size=self.out_size, add_self_connection_channel=True)
return atom_array, adj_array
================================================
FILE: chainer_chemistry/dataset/preprocessors/gwm_preprocessor.py
================================================
from chainer_chemistry.dataset.preprocessors.common import construct_supernode_feature # NOQA
from chainer_chemistry.dataset.preprocessors.ggnn_preprocessor import GGNNPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.gin_preprocessor import GINPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.nfp_preprocessor import NFPPreprocessor # NOQA
from chainer_chemistry.dataset.preprocessors.rsgcn_preprocessor import RSGCNPreprocessor # NOQA
class NFPGWMPreprocessor(NFPPreprocessor):
def get_input_features(self, mol):
atom_array, adj_array = super(
NFPGWMPreprocessor, self).get_input_features(mol)
super_node_x = construct_supernode_feature(
mol, atom_array, adj_array)
return atom_array, adj_array, super_node_x
class GGNNGWMPreprocessor(GGNNPreprocessor):
def get_input_features(self, mol):
atom_array, adj_array = super(
GGNNGWMPreprocessor, self).get_input_features(mol)
super_node_x = construct_supernode_feature(
mol, atom_array, adj_array)
return atom_array, adj_array, super_node_x
class GINGWMPreprocessor(GINPreprocessor):
def get_input_features(self, mol):
atom_array, adj_array = super(
GINGWMPreprocessor, self).get_input_features(mol)
super_node_x = construct_supernode_feature(
mol, atom_array, adj_array)
return atom_array, adj_array, super_node_x
class RSGCNGWMPreprocessor(RSGCNPreprocessor):
def get_input_features(self, mol):
atom_array, adj_array = super(
RSGCNGWMPreprocessor, self).get_input_features(mol)
super_node_x = construct_supernode_feature(
mol, atom_array, adj_array)
return atom_array, adj_array, super_node_x
================================================
FILE: chainer_chemistry/dataset/preprocessors/megnet_preprocessor.py
================================================
from logging import getLogger
import os
import traceback
import numpy
from rdkit import Chem, RDConfig # NOQA
from rdkit.Chem import AllChem, ChemicalFeatures, Descriptors, rdmolops # NOQA
from chainer_chemistry.dataset.preprocessors.common import MolFeatureExtractionError # NOQA
from chainer_chemistry.dataset.preprocessors.common import type_check_num_atoms # NOQA
from chainer_chemistry.dataset.preprocessors.mol_preprocessor import MolPreprocessor # NOQA
from chainer_chemistry.dataset.utils import GaussianDistance
MAX_ATOM_ELEMENT = 94
ATOM = ['H', 'C', 'N', 'O', 'F']
# create singleton class
class ChemicalFeaturesFactory(object):
_instance = None
@classmethod
def get_instance(self):
if not self._instance:
fdefName = os.path.join(RDConfig.RDDataDir, 'BaseFeatures.fdef')
self._instance = ChemicalFeatures.BuildFeatureFactory(fdefName)
return self._instance
# --- atom feature extraction ---
def construct_atom_type_vec(mol, num_max_atoms, atom_list=None,
include_unknown_atom=False):
atom_list = atom_list or ATOM
if include_unknown_atom:
# all atom not in `atom_list` as considered as "unknown atom"
# and its index is `len(atom_list)`
n_atom_type = len(atom_list) + 1
else:
n_atom_type = len(atom_list)
atom_type_vec = numpy.zeros((num_max_atoms, n_atom_type),
dtype=numpy.float32)
for i in range(num_max_atoms):
a = mol.GetAtomWithIdx(i)
try:
atom_idx = atom_list.index(a.GetSymbol())
except ValueError as e:
if include_unknown_atom:
atom_idx = len(atom_list)
else:
raise MolFeatureExtractionError(e)
atom_type_vec[i, atom_idx] = 1.0
return atom_type_vec
def construct_atom_chirality_vec(mol, num_max_atoms):
chirality_vec = numpy.zeros((num_max_atoms, 2), dtype=numpy.float32)
# chiral_cc: (atom_index, chirality) : (1, 'S')
chiral_cc = Chem.FindMolChiralCenters(mol)
for chiral_dict in chiral_cc:
if chiral_dict[1] == 'R':
chirality_vec[chiral_dict[0]] = [1, 0]
if chiral_dict[1] == 'S':
chirality_vec[chiral_dict[0]] = [0, 1]
return chirality_vec
def construct_atom_ring_vec(mol, num_max_atoms):
sssr = Chem.GetSymmSSSR(mol)
ring_feature = numpy.zeros((num_max_atoms, 6,), dtype=numpy.float32)
for ring in sssr:
ring = list(ring)
for i in range(num_max_atoms):
if i in ring:
ring_size = len(ring)
if ring_size >= 3 and ring_size <= 8:
ring_feature[i, ring_size - 3] = 1.0
return ring_feature
def construct_hybridization_vec(mol, num_max_atoms):
hybridization_vec = numpy.zeros((num_max_atoms, 3), dtype=numpy.float32)
for i in range(num_max_atoms):
a = mol.GetAtomWithIdx(i)
hybridization_type = a.GetHybridization()
if hybridization_type is None:
continue
hybridization_type = str(hybridization_type)
if hybridization_type == 'SP1':
hybridization_vec[i, 0] = 1.0
elif hybridization_type == 'SP2':
hybridization_vec[i, 1] = 1.0
elif hybridization_type == 'SP3':
hybridization_vec[i, 2] = 1.0
return hybridization_vec
def construct_hydrogen_bonding(mol, num_max_atoms):
factory = ChemicalFeaturesFactory.get_instance()
feats = factory.GetFeaturesForMol(mol)
hydrogen_bonding_vec = numpy.zeros((num_max_atoms, 2), dtype=numpy.float32)
for f in feats:
atom_type = f.GetFamily()
if atom_type == 'Donor':
idx = f.GetAtomIds()[0]
hydrogen_bonding_vec[idx, 0] = 1.0
if atom_type == 'Acceptor':
idx = f.GetAtomIds()[0]
hydrogen_bonding_vec[idx, 1] = 1.0
return hydrogen_bonding_vec
def construct_aromaticity_vec(mol, num_max_atoms):
aromaticity_vec = numpy.zeros((num_max_atoms, 1), dtype=numpy.float32)
aromatix_atoms = mol.GetAromaticAtoms()
for a in aromatix_atoms:
aromaticity_vec[a.GetIdx()] = 1.0
return aromaticity_vec
def construct_atom_feature(mol, use_all_feature, atom_list=None,
include_unknown_atom=False):
"""construct atom feature
Args:
mol (Mol): mol instance
use_all_feature (bool):
If True, all atom features are extracted.
If False, a part of atom features is extracted.
You can confirm the detail in the paper.
atom_list (list): list of atoms to extract feature. If None, default
`ATOM` is used as `atom_list`
include_unknown_atom (bool): If False, when the `mol` includes atom
which is not in `atom_list`, it will raise
`MolFeatureExtractionError`.
If True, even the atom is not in `atom_list`, `atom_type` is set
as "unknown" atom.
Returns:
atom_feature (numpy.ndarray):
The shape is (num_nodes, num_node_features).
"""
num_max_atoms = mol.GetNumAtoms()
atom_type_vec = construct_atom_type_vec(
mol, num_max_atoms, atom_list=atom_list,
include_unknown_atom=include_unknown_atom)
atom_chirality_vec = construct_atom_chirality_vec(
mol, num_max_atoms=num_max_atoms)
atom_ring_vec = construct_atom_ring_vec(
mol, num_max_atoms=num_max_atoms)
hybridization_vec = construct_hybridization_vec(
mol, num_max_atoms=num_max_atoms)
hydrogen_bonding = construct_hydrogen_bonding(
mol, num_max_atoms=num_max_atoms)
aromaticity_vec = construct_aromaticity_vec(
mol, num_max_atoms=num_max_atoms)
if use_all_feature:
feature = numpy.hstack((atom_type_vec, atom_chirality_vec,
atom_ring_vec, hybridization_vec,
hydrogen_bonding, aromaticity_vec))
else:
feature = construct_atom_type_vec(
mol, num_max_atoms, atom_list=atom_list,
include_unknown_atom=include_unknown_atom)
return feature
# --- pair feature extraction ---
def construct_bond_vec(mol, i, j):
bond_feature_vec = numpy.zeros((4, ), dtype=numpy.float32)
k = mol.GetBondBetweenAtoms(i, j)
if k is not None:
bond_type = str(k.GetBondType())
if bond_type == 'SINGLE':
bond_feature_vec[0] = 1.0
elif bond_type == 'DOUBLE':
bond_feature_vec[1] = 1.0
elif bond_type == 'TRIPLE':
bond_feature_vec[2] = 1.0
elif bond_type == 'AROMATIC':
bond_feature_vec[3] = 1.0
else:
raise ValueError("Unknown bond type {}".format(bond_type))
return bond_feature_vec
def get_is_in_ring(mol):
"""create a cache about whether the atom is in a ring or not
Args:
mol (Mol): mol instance
Returns
is_in_ring (dict): key is the atom idx, value is the set()
"""
sssr = Chem.GetSymmSSSR(mol)
is_in_ring = {}
ring_idx = 0
for ring in sssr:
ring = list(ring)
for i in ring:
if i not in is_in_ring:
is_in_ring[i] = set()
is_in_ring[i].add(ring_idx)
ring_idx += 1
return is_in_ring
def construct_ring_feature_vec(is_in_ring, i, j):
ring_feature_vec = numpy.zeros((1, ), dtype=numpy.float32)
if i in is_in_ring and j in is_in_ring and is_in_ring[i] & is_in_ring[j]:
ring_feature_vec[0] = 1.0
return ring_feature_vec
def construct_expanded_distance_vec(distance_matrix_3d, converter, i, j):
# calculate the bond length
distance = distance_matrix_3d[i, j]
# convert from the bond length to vector
expanded_distance_vec = converter.expand(distance)
return expanded_distance_vec
def construct_pair_feature(mol, use_all_feature):
"""construct pair feature
Args:
mol (Mol): mol instance
use_all_feature (bool):
If True, all pair features are extracted.
If False, a part of pair features is extracted.
You can confirm the detail in the paper.
Returns:
features (numpy.ndarray): The shape is (num_edges, num_edge_features)
bond_idx (numpy.ndarray): The shape is (2, num_edges)
bond_idx[0] represents the list of StartNodeIdx and bond_idx[1]
represents the list of EndNodeIdx.
"""
converter = GaussianDistance()
# prepare the data for extracting the pair feature
bonds = mol.GetBonds()
# (n_nodes, n_nodes): distance in terms of the graph bond.
graph_distance_matrix = Chem.GetDistanceMatrix(mol)
is_in_ring = get_is_in_ring(mol)
confid = AllChem.EmbedMolecule(mol)
try:
distance_matrix_3d = rdmolops.Get3DDistanceMatrix(
mol, confId=confid)
except ValueError as e:
logger = getLogger(__name__)
logger.info('construct_distance_matrix failed, type: {}, {}'
.format(type(e).__name__, e.args))
logger.debug(traceback.format_exc())
raise MolFeatureExtractionError
feature = []
bond_idx = []
for bond in bonds:
start_node = bond.GetBeginAtomIdx()
end_node = bond.GetEndAtomIdx()
# create pair feature
distance_feature = numpy.array(
graph_distance_matrix[start_node][end_node], dtype=numpy.float32)
bond_feature = construct_bond_vec(mol, start_node, end_node)
ring_feature = construct_ring_feature_vec(
is_in_ring, start_node, end_node)
bond_idx.append((start_node, end_node))
if use_all_feature:
expanded_distance_feature = \
construct_expanded_distance_vec(
distance_matrix_3d, converter, start_node, end_node)
feature.append(numpy.hstack((bond_feature, ring_feature,
distance_feature,
expanded_distance_feature)))
else:
expanded_distance_feature = \
construct_expanded_distance_vec(
distance_matrix_3d, converter, start_node, end_node)
feature.append(expanded_distance_feature)
bond_idx = numpy.array(bond_idx).T
feature = numpy.array(feature)
return feature, bond_idx
def construct_global_state_feature(mol):
"""construct global state feature
Args:
mol (Mol): mol instance
Returns:
feature (numpy.ndarray): 1 dimensional array
"""
n_atom = mol.GetNumAtoms()
ave_mol_wt = Descriptors.MolWt(mol) / n_atom
ave_num_of_bonds = len(mol.GetBonds()) / n_atom
feature = numpy.array([ave_mol_wt, ave_num_of_bonds], dtype=numpy.float32)
return feature
class MEGNetPreprocessor(MolPreprocessor):
"""MEGNetPreprocessor
Args:
For Molecule
max_atoms (int): Max number of atoms for each molecule, if the
number of atoms is more than this value, this data is simply
ignored.
Setting negative value indicates no limit for max atoms.
add_Hs (bool): If True, implicit Hs are added.
use_all_feature (bool):
If True, all atom and pair features is extracted.
If it is False, a part of atom and pair features is extracted.
You can confirm the detail in the paper.
atom_list (list): list of atoms to extract feature. If None, default
`ATOM` is used as `atom_list`
include_unknown_atom (bool): If False, when the `mol` includes atom
which is not in `atom_list`, it will raise
`MolFeatureExtractionError`.
If True, even the atom is not in `atom_list`, `atom_type` is set
as "unknown" atom.
kekulize (bool): If True, Kekulizes the molecule.
"""
def __init__(self, max_atoms=-1, add_Hs=True,
use_all_feature=False, atom_list=None,
include_unknown_atom=False, kekulize=False,
max_num_nbr=12, max_radius=8, expand_dim=100):
super(MEGNetPreprocessor, self).__init__(
add_Hs=add_Hs, kekulize=kekulize)
self.max_atoms = max_atoms
self.add_Hs = add_Hs
self.use_all_feature = use_all_feature
self.atom_list = atom_list
self.include_unknown_atom = include_unknown_atom
self.max_num_nbr = max_num_nbr
self.max_radius = max_radius
self.expand_dim = expand_dim
self.gdf = GaussianDistance(centers=numpy.linspace(0, 5, expand_dim))
def get_input_features(self, mol):
"""get input features from mol object
Args:
mol (Mol):
"""
type_check_num_atoms(mol, self.max_atoms)
atom_feature = construct_atom_feature(mol, self.use_all_feature,
self.atom_list,
self.include_unknown_atom)
pair_feature, bond_idx = construct_pair_feature(mol,
self.use_all_feature)
global_feature = construct_global_state_feature(mol)
return atom_feature, pair_feature, global_feature, bond_idx
================================================
FILE: chainer_chemistry/dataset/preprocessors/mol_preprocessor.py
================================================
from rdkit import Chem
from chainer_chemistry.dataset.preprocessors.base_preprocessor import BasePreprocessor # NOQA
from chainer_chemistry.datasets.numpy_tuple_dataset import NumpyTupleDataset # NOQA
class MolPreprocessor(BasePreprocessor):
"""preprocessor class specified for rdkit mol instance
Args:
add_Hs (bool): If True, implicit Hs are added.
kekulize (bool): If True, Kekulizes the molecule.
"""
def __init__(self, add_Hs=False, kekulize=False):
super(MolPreprocessor, self).__init__()
self.add_Hs = add_Hs
self.kekulize = kekulize
def prepare_smiles_and_mol(self, mol):
"""Prepare `smiles` and `mol` used in following preprocessing.
This method is called before `get_input_features` is called, by parser
class.
This method may be overriden to support custom `smile`/`mol` extraction
Args:
mol (mol): mol instance
Returns (tuple): (`smiles`, `mol`)
"""
# Note that smiles expression is not unique.
# we obtain canonical smiles which is unique in `mol`
canonical_smiles = Chem.MolToSmiles(mol, isomericSmiles=False,
canonical=True)
mol = Chem.MolFromSmiles(canonical_smiles)
if self.add_Hs:
mol = Chem.AddHs(mol)
if self.kekulize:
Chem.Kekulize(mol)
return canonical_smiles, mol
def get_label(self, mol, label_names=None):
"""Extracts label information from a molecule.
This method extracts properties whose keys are
specified by ``label_names`` from a molecule ``mol``
and returns these values as a list.
The order of the values is same as that of ``label_names``.
If the molecule does not have a
property with some label, this function fills the corresponding
index of the returned list with ``None``.
Args:
mol (rdkit.Chem.Mol): molecule whose features to be extracted
label_names (None or iterable): list of label names.
Returns:
list of str: label information. Its length is equal to
that of ``label_names``. If ``label_names`` is ``None``,
this function returns an empty list.
"""
if label_names is None:
return []
label_list = []
for label_name in label_names:
if mol.HasProp(label_name):
label_list.append(mol.GetProp(label_name))
else:
label_list.append(None)
# TODO(Nakago): Review implementation
# Label -1 work in case of classification.
# However in regression, assign -1 is not a good strategy...
# label_list.append(-1)
# Failed to GetProp for label, skip this case.
# print('no label')
# raise MolFeatureExtractionError
return label_list
def get_input_features(self, mol):
"""get molecule's feature representation, descriptor.
Each subclass must override this method.
Args:
mol (Mol): molecule whose feature to be extracted.
`mol` is prepared by the method `prepare_smiles_and_mol`.
"""
raise NotImplementedError
def create_dataset(self, *args, **kwargs):
return NumpyTupleDataset(*args)
def process(self, filepath):
# Not used now...
pass
================================================
FILE: chainer_chemistry/dataset/preprocessors/nfp_preprocessor.py
================================================
from chainer_chemistry.dataset.preprocessors.common import construct_adj_matrix
from chainer_chemistry.dataset.preprocessors.common \
import construct_atomic_number_array
from chainer_chemistry.dataset.preprocessors.common import type_check_num_atoms
from chainer_chemistry.dataset.preprocessors.mol_preprocessor \
import MolPreprocessor
class NFPPreprocessor(MolPreprocessor):
"""NFP Preprocessor
Args:
max_atoms (int): Max number of atoms for each molecule, if the
number of atoms is more than this value, this data is simply
ignored.
Setting negative value indicates no limit for max atoms.
out_size (int): It specifies the size of array returned by
`get_input_features`.
If the number of atoms in the molecule is less than this value,
the returned arrays is padded to have fixed size.
Setting negative value indicates do not pad returned array.
add_Hs (bool): If True, implicit Hs are added.
kekulize (bool): If True, Kekulizes the molecule.
"""
def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
kekulize=False):
super(NFPPreprocessor, self).__init__(
add_Hs=add_Hs, kekulize=kekulize)
if max_atoms >= 0 and out_size >= 0 and max_atoms > out_size:
raise ValueError('max_atoms {} must be less or equal to '
'out_size {}'.format(max_atoms, out_size))
self.max_atoms = max_atoms
self.out_size = out_size
def get_input_features(self, mol):
"""get input features
Args:
mol (Mol):
Returns:
"""
type_check_num_atoms(mol, self.max_atoms)
atom_array = construct_atomic_number_array(mol, out_size=self.out_size)
adj_array = construct_adj_matrix(mol, out_size=self.out_size)
return atom_array, adj_array
================================================
FILE: chainer_chemistry/dataset/preprocessors/relgat_preprocessor.py
================================================
from chainer_chemistry.dataset.preprocessors.common import construct_atomic_number_array # NOQA
from chainer_chemistry.dataset.preprocessors.common import construct_discrete_edge_matrix # NOQA
from chainer_chemistry.dataset.preprocessors.common import MolFeatureExtractionError # NOQA
from chainer_chemistry.dataset.preprocessors.common import type_check_num_atoms
from chainer_chemistry.dataset.preprocessors.mol_preprocessor import MolPreprocessor # NOQA
class RelGATPreprocessor(MolPreprocessor):
"""RelGAT Preprocessor
Args:
max_atoms (int): Max number of atoms for each molecule, if the
number of atoms is more than this value, this data is simply
ignored.
Setting negative value indicates no limit for max atoms.
out_size (int): It specifies the size of array returned by
`get_input_features`.
If the number of atoms in the molecule is less than this value,
the returned arrays is padded to have fixed size.
Setting negative value indicates do not pad returned array.
"""
def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False):
super(RelGATPreprocessor, self).__init__(add_Hs=add_Hs)
if max_atoms >= 0 and out_size >= 0 and max_atoms > out_size:
raise ValueError('max_atoms {} must be less or equal to '
'out_size {}'.format(max_atoms, out_size))
self.max_atoms = max_atoms
self.out_size = out_size
def get_input_features(self, mol):
"""get input features
Args:
mol (Mol):
Returns:
"""
type_check_num_atoms(mol, self.max_atoms)
atom_array = construct_atomic_number_array(mol, out_size=self.out_size)
adj_array = construct_discrete_edge_matrix(mol, out_size=self.out_size)
return atom_array, adj_array
================================================
FILE: chainer_chemistry/dataset/preprocessors/relgcn_preprocessor.py
================================================
from chainer_chemistry.dataset.preprocessors.ggnn_preprocessor import GGNNPreprocessor, GGNNSparsePreprocessor # NOQA
class RelGCNPreprocessor(GGNNPreprocessor):
"""RelGCN Preprocessor
Args:
max_atoms (int): Max number of atoms for each molecule, if the
number of atoms is more than this value, this data is simply
ignored.
Setting negative value indicates no limit for max atoms.
out_size (int): It specifies the size of array returned by
`get_input_features`.
If the number of atoms in the molecule is less than this value,
the returned arrays is padded to have fixed size.
Setting negative value indicates do not pad returned array.
add_Hs (bool): If True, implicit Hs are added.
kekulize (bool): If True, Kekulizes the molecule.
"""
def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
kekulize=False):
super(RelGCNPreprocessor, self).__init__(
max_atoms=max_atoms, out_size=out_size, add_Hs=add_Hs,
kekulize=kekulize)
def get_input_features(self, mol):
"""get input features
Args:
mol (Mol):
Returns:
"""
return super(RelGCNPreprocessor, self).get_input_features(mol)
class RelGCNSparsePreprocessor(GGNNSparsePreprocessor):
pass
================================================
FILE: chainer_chemistry/dataset/preprocessors/rsgcn_preprocessor.py
================================================
from chainer_chemistry.dataset.preprocessors.common import construct_adj_matrix # NOQA
from chainer_chemistry.dataset.preprocessors.common import construct_atomic_number_array # NOQA
from chainer_chemistry.dataset.preprocessors.common import type_check_num_atoms # NOQA
from chainer_chemistry.dataset.preprocessors.mol_preprocessor import MolPreprocessor # NOQA
import numpy
class RSGCNPreprocessor(MolPreprocessor):
"""RSGCN Preprocessor
Args:
max_atoms (int): Max number of atoms for each molecule, if the
number of atoms is more than this value, this data is simply
ignored.
Setting negative value indicates no limit for max atoms.
out_size (int): It specifies the size of array returned by
`get_input_features`.
If the number of atoms in the molecule is less than this value,
the returned arrays is padded to have fixed size.
Setting negative value indicates do not pad returned array.
add_Hs (bool): If True, implicit Hs are added.
kekulize (bool): If True, Kekulizes the molecule.
"""
def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
kekulize=False):
super(RSGCNPreprocessor, self).__init__(
add_Hs=add_Hs, kekulize=kekulize)
if max_atoms >= 0 and out_size >= 0 and max_atoms > out_size:
raise ValueError('max_atoms {} must be less or equal to '
'out_size {}'.format(max_atoms, out_size))
self.max_atoms = max_atoms
self.out_size = out_size
def get_input_features(self, mol):
"""get input features
Args:
mol (Mol):
Returns:
"""
type_check_num_atoms(mol, self.max_atoms)
num_atoms = mol.GetNumAtoms()
# Construct the atom array and adjacency matrix.
atom_array = construct_atomic_number_array(mol, out_size=self.out_size)
adj_array = construct_adj_matrix(mol, out_size=self.out_size)
# Adjust the adjacency matrix.
degree_vec = numpy.sum(adj_array[:num_atoms], axis=1)
degree_sqrt_inv = 1. / numpy.sqrt(degree_vec)
adj_array[:num_atoms, :num_atoms] *= numpy.broadcast_to(
degree_sqrt_inv[:, None], (num_atoms, num_atoms))
adj_array[:num_atoms, :num_atoms] *= numpy.broadcast_to(
degree_sqrt_inv[None, :], (num_atoms, num_atoms))
return atom_array, adj_array
================================================
FILE: chainer_chemistry/dataset/preprocessors/schnet_preprocessor.py
================================================
from logging import getLogger
import traceback
import numpy
from rdkit.Chem import AllChem
from rdkit.Chem import rdmolops
from chainer_chemistry.dataset.preprocessors.common \
import construct_atomic_number_array
from chainer_chemistry.dataset.preprocessors.common import MolFeatureExtractionError # NOQA
from chainer_chemistry.dataset.preprocessors.common import type_check_num_atoms
from chainer_chemistry.dataset.preprocessors.mol_preprocessor \
import MolPreprocessor
def construct_distance_matrix(mol, out_size=-1, contain_Hs=False):
"""Construct distance matrix
Args:
mol (Chem.Mol):
out_size (int):
contain_Hs (bool):
Returns (numpy.ndarray): 2 dimensional array which represents distance
between atoms
"""
if mol is None:
raise MolFeatureExtractionError('mol is None')
N = mol.GetNumAtoms()
if out_size < 0:
size = N
elif out_size >= N:
size = out_size
else:
raise MolFeatureExtractionError('out_size {} is smaller than number '
'of atoms in mol {}'
.format(out_size, N))
if contain_Hs:
mol2 = mol
else:
mol2 = AllChem.AddHs(mol)
conf_id = AllChem.EmbedMolecule(mol2)
if not contain_Hs:
mol2 = AllChem.RemoveHs(mol2)
try:
dist_matrix = rdmolops.Get3DDistanceMatrix(mol2, confId=conf_id)
except ValueError as e:
logger = getLogger(__name__)
logger.info('construct_distance_matrix failed, type: {}, {}'
.format(type(e).__name__, e.args))
logger.debug(traceback.format_exc())
raise MolFeatureExtractionError
if size > N:
dists = numpy.zeros((size, size), dtype=numpy.float32)
a0, a1 = dist_matrix.shape
dists[:a0, :a1] = dist_matrix
else:
dists = dist_matrix
return dists.astype(numpy.float32)
class SchNetPreprocessor(MolPreprocessor):
"""SchNet Preprocessor
Args:
max_atoms (int): Max number of atoms for each molecule, if the
number of atoms is more than this value, this data is simply
ignored.
Setting negative value indicates no limit for max atoms.
out_size (int): It specifies the size of array returned by
`get_input_features`.
If the number of atoms in the molecule is less than this value,
the returned arrays is padded to have fixed size.
Setting negative value indicates do not pad returned array.
add_Hs (bool): If True, implicit Hs are added.
kekulize (bool): If True, Kekulizes the molecule.
"""
def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
kekulize=False):
super(SchNetPreprocessor, self).__init__(
add_Hs=add_Hs, kekulize=kekulize)
if max_atoms >= 0 and out_size >= 0 and max_atoms > out_size:
raise ValueError('max_atoms {} must be less or equal to '
'out_size {}'.format(max_atoms, out_size))
self.max_atoms = max_atoms
self.out_size = out_size
def get_input_features(self, mol):
"""get input features
Args:
mol (Mol):
Returns:
"""
type_check_num_atoms(mol, self.max_atoms)
atom_array = construct_atomic_number_array(mol, out_size=self.out_size)
dist_array = construct_distance_matrix(mol, out_size=self.out_size,
contain_Hs=self.add_Hs)
return atom_array, dist_array
================================================
FILE: chainer_chemistry/dataset/preprocessors/weavenet_preprocessor.py
================================================
import os
import numpy
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import ChemicalFeatures
from rdkit import RDConfig
from chainer_chemistry.config import WEAVE_DEFAULT_NUM_MAX_ATOMS
from chainer_chemistry.dataset.preprocessors.common \
import construct_atomic_number_array
from chainer_chemistry.dataset.preprocessors.common \
import MolFeatureExtractionError
from chainer_chemistry.dataset.preprocessors.common import type_check_num_atoms
from chainer_chemistry.dataset.preprocessors.mol_preprocessor \
import MolPreprocessor
ATOM = ['H', 'C', 'N', 'O', 'S', 'Cl', 'Br', 'F', 'P', 'I']
MAX_DISTANCE = 2 # 7
# --- Atom feature extraction ---
def construct_atom_type_vec(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS,
atom_list=None, include_unknown_atom=False):
atom_list = atom_list or ATOM
if include_unknown_atom:
# all atom not in `atom_list` as considered as "unknown atom"
# and its index is `len(atom_list)`
n_atom_type = len(atom_list) + 1
else:
n_atom_type = len(atom_list)
n_atom = mol.GetNumAtoms()
atom_type_vec = numpy.zeros((num_max_atoms, n_atom_type),
dtype=numpy.float32)
for i in range(n_atom):
a = mol.GetAtomWithIdx(i)
try:
atom_idx = atom_list.index(a.GetSymbol())
except ValueError as e:
if include_unknown_atom:
atom_idx = len(atom_list)
else:
raise MolFeatureExtractionError(e)
atom_type_vec[i, atom_idx] = 1.0
return atom_type_vec
def construct_formal_charge_vec(mol,
num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS):
n_atom = mol.GetNumAtoms()
formal_charge_vec = numpy.zeros((num_max_atoms, 1), dtype=numpy.float32)
for i in range(n_atom):
a = mol.GetAtomWithIdx(i)
formal_charge_vec[i, 0] = a.GetFormalCharge()
return formal_charge_vec
def construct_hybridization_vec(mol,
num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS):
# TODO(Oono)
# Can we enhance preprocessing speed by making factory once
# prior to calling this function many times?
n_atom = mol.GetNumAtoms()
hybridization_vec = numpy.zeros((num_max_atoms, 3), dtype=numpy.float32)
for i in range(n_atom):
a = mol.GetAtomWithIdx(i)
if a.GetHybridization() is None:
continue
hybridization_type = str(a.GetHybridization())
if hybridization_type == 'SP1':
hybridization_vec[i, 0] = 1.0
elif hybridization_type == 'SP2':
hybridization_vec[i, 1] = 1.0
elif hybridization_type == 'SP3':
hybridization_vec[i, 2] = 1.0
return hybridization_vec
def construct_partial_charge_vec(
mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS):
AllChem.ComputeGasteigerCharges(mol)
n = mol.GetNumAtoms()
partial_charge_vec = numpy.zeros((num_max_atoms, 1), dtype=numpy.float32)
for i in range(n):
a = mol.GetAtomWithIdx(i)
partial_charge_vec[i, 0] = a.GetProp("_GasteigerCharge")
return partial_charge_vec
def construct_atom_ring_vec(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS):
nAtom = mol.GetNumAtoms()
sssr = Chem.GetSymmSSSR(mol)
ring_feature = numpy.zeros((num_max_atoms, 6,), dtype=numpy.float32)
for ring in sssr:
ring = list(ring)
for i in range(nAtom):
if i in ring:
ring_size = len(ring)
if ring_size >= 3 and ring_size <= 8:
ring_feature[i, ring_size - 3] = 1.0
return ring_feature
def construct_hydrogen_bonding(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS):
fdefName = os.path.join(RDConfig.RDDataDir, 'BaseFeatures.fdef')
factory = ChemicalFeatures.BuildFeatureFactory(fdefName)
feats = factory.GetFeaturesForMol(mol)
hydrogen_bonding_vec = numpy.zeros((num_max_atoms, 2), dtype=numpy.float32)
for f in feats:
if f.GetFamily() == 'Donor':
idx = f.GetAtomIds()[0]
hydrogen_bonding_vec[idx, 0] = 1.0
if f.GetFamily() == 'Acceptor':
idx = f.GetAtomIds()[0]
hydrogen_bonding_vec[idx, 1] = 1.0
return hydrogen_bonding_vec
def construct_num_hydrogens_vec(mol,
num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS):
n_hydrogen_vec = numpy.zeros((num_max_atoms, 1), dtype=numpy.float32)
n_atom = mol.GetNumAtoms()
for i in range(n_atom):
n = 0
for j in range(n_atom):
if i == j:
continue
a = mol.GetAtomWithIdx(j)
if a.GetSymbol() != 'H':
continue
k = mol.GetBondBetweenAtoms(i, j)
if k is not None:
n += 1
n_hydrogen_vec[i, 0] = n
return n_hydrogen_vec
def construct_aromaticity_vec(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS):
aromaticity_vec = numpy.zeros((num_max_atoms, 1), dtype=numpy.float32)
aromatix_atoms = mol.GetAromaticAtoms()
for a in aromatix_atoms:
aromaticity_vec[a.GetIdx()] = 1.0
return aromaticity_vec
def construct_atom_feature(mol, add_Hs,
num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS,
atom_list=None, include_unknown_atom=False):
"""construct atom feature
Args:
mol (Mol): mol instance
add_Hs (bool): if the `mol` instance was added Hs, set True.
num_max_atoms (int): number of max atoms
atom_list (list): list of atoms to extract feature. If None, default
`ATOM` is used as `atom_list`
include_unknown_atom (bool): If False, when the `mol` includes atom
which is not in `atom_list`, it will raise
`MolFeatureExtractionError`.
If True, even the atom is not in `atom_list`, `atom_type` is set
as "unknown" atom.
Returns (numpy.ndarray): 2 dimensional array. First axis size is
`num_max_atoms`, representing each atom index.
Second axis for feature.
"""
atom_type_vec = construct_atom_type_vec(
mol, num_max_atoms, atom_list=atom_list,
include_unknown_atom=include_unknown_atom)
# TODO(nakago): Chilarity
formal_charge_vec = construct_formal_charge_vec(
mol, num_max_atoms=num_max_atoms)
partial_charge_vec = construct_partial_charge_vec(
mol, num_max_atoms=num_max_atoms)
atom_ring_vec = construct_atom_ring_vec(
mol, num_max_atoms=num_max_atoms)
hybridization_vec = construct_hybridization_vec(
mol, num_max_atoms=num_max_atoms)
hydrogen_bonding = construct_hydrogen_bonding(
mol, num_max_atoms=num_max_atoms)
aromaticity_vec = construct_aromaticity_vec(
mol, num_max_atoms=num_max_atoms)
if add_Hs:
num_hydrogens_vec = construct_num_hydrogens_vec(
mol, num_max_atoms=num_max_atoms)
feature = numpy.hstack((atom_type_vec, formal_charge_vec,
partial_charge_vec, atom_ring_vec,
hybridization_vec, hydrogen_bonding,
aromaticity_vec, num_hydrogens_vec))
else:
feature = numpy.hstack((atom_type_vec, formal_charge_vec,
partial_charge_vec, atom_ring_vec,
hybridization_vec, hydrogen_bonding,
aromaticity_vec))
return feature
# --- Pair feature extraction ---
def construct_bond_vec(mol, i, j):
bond_feature_vec = numpy.zeros((4, ), dtype=numpy.float32)
k = mol.GetBondBetweenAtoms(i, j)
if k is not None:
bond_type = str(k.GetBondType())
if bond_type == 'SINGLE':
bond_feature_vec[0] = 1.0
elif bond_type == 'DOUBLE':
bond_feature_vec[1] = 1.0
elif bond_type == 'TRIPLE':
bond_feature_vec[2] = 1.0
elif bond_type == 'AROMATIC':
bond_feature_vec[3] = 1.0
else:
raise ValueError("Unknown bond type {}".format(bond_type))
return bond_feature_vec
def construct_distance_vec(distance_matrix, i, j):
distance = min(MAX_DISTANCE, int(distance_matrix[i][j]))
distance_feature = numpy.zeros((MAX_DISTANCE, ), dtype=numpy.float32)
distance_feature[:distance] = 1.0
return distance_feature
def construct_ring_feature_vec(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS):
n_atom = mol.GetNumAtoms()
sssr = Chem.GetSymmSSSR(mol)
ring_feature_vec = numpy.zeros(
(num_max_atoms ** 2, 1,), dtype=numpy.float32)
for ring in sssr:
ring = list(ring)
n_atom_in_ring = len(ring)
for i in range(n_atom_in_ring):
for j in range(n_atom_in_ring):
a0 = ring[i]
a1 = ring[j]
ring_feature_vec[a0 * n_atom + a1] = 1
return ring_feature_vec
def construct_pair_feature(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS):
"""construct pair feature
Args:
mol (Mol): mol instance
num_max_atoms (int): number of max atoms
Returns (numpy.ndarray): 2 dimensional array. First axis size is
`num_max_atoms` ** 2, representing index of each atom pair.
Second axis for feature.
"""
n_atom = mol.GetNumAtoms()
distance_matrix = Chem.GetDistanceMatrix(mol)
distance_feature = numpy.zeros((num_max_atoms ** 2, MAX_DISTANCE,),
dtype=numpy.float32)
for i in range(n_atom):
for j in range(n_atom):
distance_feature[i * n_atom + j] = construct_distance_vec(
distance_matrix, i, j)
bond_feature = numpy.zeros((num_max_atoms ** 2, 4,), dtype=numpy.float32)
for i in range(n_atom):
for j in range(n_atom):
bond_feature[i * n_atom + j] = construct_bond_vec(mol, i, j)
ring_feature = construct_ring_feature_vec(mol, num_max_atoms=num_max_atoms)
feature = numpy.hstack((distance_feature, bond_feature, ring_feature))
return feature
class WeaveNetPreprocessor(MolPreprocessor):
"""WeaveNetPreprocessor
WeaveNet must have fixed-size atom list for now, zero_padding option
is always set to True.
Args:
max_atoms (int): Max number of atoms for each molecule, if the
number of atoms is more than this value, this data is simply
ignored.
Setting negative value indicates no limit for max atoms.
add_Hs (bool): If True, implicit Hs are added.
use_fixed_atom_feature (bool):
If True, atom feature is extracted used in original paper.
If it is False, atomic number is used instead.
atom_list (list): list of atoms to extract feature. If None, default
`ATOM` is used as `atom_list`
include_unknown_atom (bool): If False, when the `mol` includes atom
which is not in `atom_list`, it will raise
`MolFeatureExtractionError`.
If True, even the atom is not in `atom_list`, `atom_type` is set
as "unknown" atom.
kekulize (bool): If True, Kekulizes the molecule.
"""
def __init__(self, max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS, add_Hs=True,
use_fixed_atom_feature=False, atom_list=None,
include_unknown_atom=False, kekulize=False):
super(WeaveNetPreprocessor, self).__init__(
add_Hs=add_Hs, kekulize=kekulize)
zero_padding = True
if zero_padding and max_atoms <= 0:
raise ValueError('max_atoms must be set to positive value when '
'zero_padding is True')
self.max_atoms = max_atoms
self.add_Hs = add_Hs
self.zero_padding = zero_padding
self.use_fixed_atom_feature = use_fixed_atom_feature
self.atom_list = atom_list
self.include_unknown_atom = include_unknown_atom
def get_input_features(self, mol):
"""get input features for WeaveNet
WeaveNetPreprocessor automatically add `H` to `mol`
Args:
mol (Mol):
"""
type_check_num_atoms(mol, self.max_atoms)
if self.use_fixed_atom_feature:
# original paper feature extraction
atom_array = construct_atom_feature(mol, self.add_Hs,
self.max_atoms, self.atom_list,
self.include_unknown_atom)
else:
# embed id of atomic numbers
atom_array = construct_atomic_number_array(mol, self.max_atoms)
pair_feature = construct_pair_feature(mol,
num_max_atoms=self.max_atoms)
return atom_array, pair_feature
================================================
FILE: chainer_chemistry/dataset/preprocessors/wle.py
================================================
import collections
import numpy as np
from chainer_chemistry.dataset.preprocessors import wle_io
from chainer_chemistry.dataset.preprocessors import wle_atom_array_update as wle_update
DEBUG = False
def apply_wle_for_datasets(datasets, cutoff=0, k=1):
"""
Apply label Weisfeiler--Lehman Embedding for the tuple of datasets.
Args:
datasets: tuple of dataset (usually, train/val/test),
each dataset consists of atom_array and
adj_array and teach_signal
cutoff: int, if more than 0, the expanded labels
whose freq <= cutoff will be removed.
k: int, the number of iterations of neighborhood
aggregation.
Returns:
- tuple of dataset (usually, train/val/test),
each dataest consists of atom_number_array and
adj_tensor with expanded labels
- list of all labels, used in the dataset parts.
- dictionary of label frequencies key:label valeu:frequency count
"""
atom_arrays, adj_arrays, teach_signals = wle_io.load_dataset_elements(datasets)
for _ in range(k):
atom_arrays, labels_frequencies = wle_update.update_atom_arrays(
atom_arrays, adj_arrays, cutoff)
datasets_expanded = wle_io.create_datasets(atom_arrays, adj_arrays, teach_signals)
expanded_labels = list(labels_frequencies.keys())
return tuple(datasets_expanded), expanded_labels, labels_frequencies
def apply_cwle_for_datasets(datasets, k=1):
"""
Apply Concatenated Weisfeiler--Lehman embedding for the tuple of datasets.
This also applicalbe for the Gated-sum Weisfeiler--Lehman embedding.
Args:
datasets: tuple of dataset (usually, train/val/test),
each dataset consists of atom_array and
adj_array and teach_signal
k: int, the number of iterations of neighborhood
aggregation.
Returns:
- tuple of dataset (usually, train/val/test),
each dataest consists of atom_number_array,
expanded_label_array, and adj_tensor
- list of all expanded labels, used in the dataset parts.
- dictionary of label frequencies key:label valeu:frequency count
"""
if k <= 0:
raise ValueError('Iterations should be a positive integer. '
'Found k={}'.format(k))
atom_arrays, adj_arrays, teach_signals = wle_io.load_dataset_elements(datasets)
for i in range(k):
if i != k - 1:
atom_arrays, labels_frequencies = wle_update.update_atom_arrays(
atom_arrays, adj_arrays, 0)
else:
wle_arrays, labels_frequencies = wle_update.update_atom_arrays(
atom_arrays, adj_arrays, 0, False)
datasets_expanded = wle_io.create_datasets(
atom_arrays, adj_arrays, teach_signals, wle_arrays)
expanded_labels = list(labels_frequencies.keys())
return tuple(datasets_expanded), expanded_labels, labels_frequencies
def _findmaxidx(datasets, idx):
atom_data_size = len(datasets[0][0])
if atom_data_size <= idx:
raise ValueError(
'data index is out of index. '
'atom_data size={} <= idx={}'.format(
atom_data_size, idx))
max_idx = -1
for dataset in datasets:
for mol_data in dataset:
atom_array = mol_data[idx]
max_atom_idx = np.max(atom_array)
if max_atom_idx > max_idx:
max_idx = max_atom_idx
return max_idx + 1 # 0-origin
def findmaxidx(datasets, target='atom_label'):
"""
Retruns the maximum number of the symbol index in an atom array,
throughout the datasets.
Args:
datasets: dataset entity
target: choice of 'atom_label' of 'wle_label'
Returns:
_findmaxidx(datasets, 0/2)
"""
if target == 'atom_label':
return _findmaxidx(datasets, 0)
elif target == 'wle_label':
return _findmaxidx(datasets, 2)
================================================
FILE: chainer_chemistry/dataset/preprocessors/wle_atom_array_update.py
================================================
import collections
import numpy as np
from chainer_chemistry.dataset.preprocessors import wle_util
def update_atom_arrays(atom_arrays, adj_arrays, cutoff, with_focus_atom=True):
expanded_atom_lists, labels_frequencies = list_all_expanded_labels(
atom_arrays, adj_arrays, with_focus_atom)
if cutoff > 0:
expanded_atom_lists, labels_frequencies = shrink_expanded_labels(
expanded_atom_lists, labels_frequencies, cutoff)
expanded_labels = list(labels_frequencies.keys())
atom_arrays = [wle_util.to_index(l, expanded_labels)
for l in expanded_atom_lists]
return atom_arrays, labels_frequencies
def shrink_expanded_labels(expanded_atom_lists,
labels_frequencies,
cutoff):
"""
Cut off the few-appearance expanded labels
Args:
expanded_atom_lists: tuple of list of expanded labels
labels_frequencies: list of label apperacne frequencies
cutoff: int, frequency cut of expanded labels
Returns:
- 3 (train/val/test) tuple of expanded atom arrays
(all nodes are associated with string representations of expanded signals)
- dictionary of frequencies all labels (key: label, value: frequency)
"""
# atom_array values are expanded label "STRING", not numbers
new_expanded_atom_lists = []
new_labels_frequencies = collections.defaultdict(lambda: 0)
# for each train/val/test, do
for set_expanded_atom_list in expanded_atom_lists:
# for each molecule sample, do
new_set_expanded_atom_list = []
for expanded_atom_list in set_expanded_atom_list:
mol_expanded_atom_list = []
# for each node i in the molecule,
# get the neighbor's atom label (number index)
for expanded_label in expanded_atom_list:
freq = labels_frequencies[expanded_label]
# check frequency here
if freq > cutoff:
label = expanded_label
else:
label = wle_util.get_focus_node_label(expanded_label)
mol_expanded_atom_list.append(label)
new_labels_frequencies[label] = new_labels_frequencies[label] + 1
# end cutoff-ifelse
# end i-for
new_set_expanded_atom_list.append(mol_expanded_atom_list)
# end zip(atom_arrays, adj_array)-for
new_expanded_atom_lists.append(new_set_expanded_atom_list)
# end zip(atom_arrays, adj_array)-for
return new_expanded_atom_lists, dict(new_labels_frequencies)
def list_all_expanded_labels(atom_arrays, adj_arrays, with_focus_atom=True):
"""
Exapnd all nodes into WLE representation. At the same time, return the list of all labels after expansion
Args:
atom_arrays: 3 (train/val/test) tuple of atom arrays
adj_arrays: 3 (train/val/test) tuple of adj.arrays
with_focus_atom: bool, if True, the expanded label starts from the original atom label ("C-ON-OFN")
if False, the exnapndd label do not include the original atom albel("-CN-OFN")
Returns:
- 3 (train/val/test) tuple of expanded atom arrays
(all nodes are associated with string representations of expanded signals)
- list of all labels appeared in the expanded atom arrays.
- dictionary of frequencies all labels (key: label, value: frequency)
"""
expanded_atom_lists = [] # atom_array values are expanded label "STRING", not numbers
labels_frequencies = collections.defaultdict(lambda: 0)
# for each train/val/test, do
for set_atom_arrays, set_adj_arrays in zip(atom_arrays, adj_arrays):
# for each molecule sample, do
set_expanded_atom_list = []
for atom_array, adj_array in zip(set_atom_arrays, set_adj_arrays):
N = len(atom_array) # number of molecules
# atom_array: N by F
# adj_array: N by N or N by R by N
# compress the relation axis
adj_array = wle_util.compress_relation_axis(adj_array)
assert adj_array.shape == (N, N)
# find neighbors
# array[0]: row index array[1]: column index
neighbors = np.nonzero(adj_array)
mol_expanded_atom_list = []
# for each node i in the molecule,
# get the neighbor's atom label (number index)
for i in range(N):
expanded_label = wle_util.get_neighbor_representation(
i, atom_array, neighbors, with_focus_atom)
mol_expanded_atom_list.append(expanded_label)
labels_frequencies[expanded_label] = labels_frequencies[expanded_label] + 1
# end i-for
set_expanded_atom_list.append(mol_expanded_atom_list)
# end zip(atom_arrays, adj_array)-for
expanded_atom_lists.append(set_expanded_atom_list)
# end zip(atom_arrays, adj_array)-for
# Convert to a normal dictionary because
# we cannot pickle defaultdicts with lambdas.
return expanded_atom_lists, dict(labels_frequencies)
================================================
FILE: chainer_chemistry/dataset/preprocessors/wle_io.py
================================================
import numpy as np
from chainer_chemistry.datasets.numpy_tuple_dataset import NumpyTupleDataset
DEBUG = False
def create_datasets(atom_arrays, adj_arrays, teach_signals, wle_arrays=None):
"""
Expand the atomic_num_arrays with the expanded labels,
then return valid datasets (tuple of NumpyTupleDataset)
Args:
atom_arrays: 3-tuple of list of lists.
atom_arrays[i][j][k] is the id of an atom
i: train/val/test
j: index of a sample (i.e. molcule)
k: index of an atom
adj_arrays: list of list of numpy.array, all mol's adjacnecy tensors
teach_signals: list of list of numpy.array,
all teacher (supervision) signals
wle_arrays: None (for WLE) or 3-tuple of list of lists (for CWLE and GWLE).
Returns: 3 tuple of valid datasets (train/vel/test) in NumpyTuppleDataset
"""
output_datasets = []
# ToDo: try another indexing: e.g. orignal node label + extneions
assert len(atom_arrays) == len(adj_arrays) == len(teach_signals)
if wle_arrays is not None:
assert len(atom_arrays) == len(wle_arrays)
for i in range(len(atom_arrays)):
# We have swaped the axes 0 and 1 for adj-arrays. re-swap
set_adj_arrays = np.array(adj_arrays[i])
for m in range(len(set_adj_arrays)):
set_adj_arrays[m] = np.swapaxes(set_adj_arrays[m], 0, 1)
if wle_arrays is None:
dataset = NumpyTupleDataset(np.array(atom_arrays[i]),
set_adj_arrays,
np.array(teach_signals[i]))
else:
dataset = NumpyTupleDataset(np.array(atom_arrays[i]),
set_adj_arrays,
np.array(wle_arrays[i]),
np.array(teach_signals[i]))
output_datasets.append(dataset)
# end expanded-for
return output_datasets
def load_dataset_elements(datasets):
"""
Load all dataset tuples: atom array, adj. array, and teacher signals.
Args:
datasets: tuple of NumpyTupleDataset
Returns:
- tuple of lists of atom arrays, adj.arrays, and teacher signals.
"""
if DEBUG:
print('type(datasets)', type(datasets)) # tuple
atom_arrays = [] # 3 by num_mols by N by F
adj_arrays = [] # 3 by num_mols by N by N, or 3 by N by R by N by N by N
teach_signals = [] # 3 by num_mols by N by (data-dependent)
for dataset in datasets:
if DEBUG:
print('type(dataset)', type(dataset)) # NumpyTupleDataset
set_atom_arrays = [] # Mol by N
set_adj_arrays = [] # Mol by N by N or N by R by N by N
set_teach_signals = [] # Mol by (data-dependent)
for mol_data in dataset:
atom_array = mol_data[0]
adj_array = mol_data[1]
teach_signal = mol_data[2]
if DEBUG:
print("type(mol_data)=", type(mol_data)) # tuple
print("type(atom_arrray)=", type(atom_array)) # ndarray
print("type(adj_arrray)=", type(adj_array)) # ndarray
print("type(teach_signal)=", type(teach_signal)) # ndarray
set_atom_arrays.append(atom_array)
# for 3-D tensor, we swap axis here
set_adj_arrays.append(adj_array.swapaxes(0, 1))
set_teach_signals.append(teach_signal)
# end dataset-for
atom_arrays.append(set_atom_arrays)
adj_arrays.append(set_adj_arrays)
teach_signals.append(set_teach_signals)
# end datasets-for
return atom_arrays, adj_arrays, teach_signals
================================================
FILE: chainer_chemistry/dataset/preprocessors/wle_util.py
================================================
import numpy as np
DEBUG = False
def _index(atom, values):
idx = values.index(atom)
if DEBUG:
print("idx=", idx)
print("expanded_label=", atom)
return idx
def to_index(mols, values):
return np.array([np.array([_index(atom, values) for atom in mol],
dtype=np.int32)
for mol in mols])
def compress_relation_axis(adj_array):
ndim = adj_array.ndim
if ndim == 2:
return adj_array
elif ndim == 3:
return np.sum(adj_array, axis=1, keepdims=False)
else:
raise ValueError(
'ndim of adjacency matrix should be 2 or 3. '
'Found ndim={}.'.format(ndim))
def _to_string(atom_label, neighbor_labels, with_focus_atom):
expanded_label = ".".join(map(str, neighbor_labels))
if with_focus_atom:
expanded_label = str(atom_label) + "-" + expanded_label
if DEBUG:
print("expanded_label=" + expanded_label)
return expanded_label
def get_neighbor_representation(idx, atom_array, neighbors, with_focus_atom):
atom_label = atom_array[idx]
neighbor = neighbors[1][np.where(neighbors[0] == idx)]
if DEBUG:
print(neighbor)
print("len(neighbor_i)=", len(neighbor))
neighbor_labels = np.sort([atom_array[x] for x in neighbor if x != idx])
return _to_string(
atom_label, neighbor_labels, with_focus_atom)
def get_focus_node_label(expanded_label):
tokens = expanded_label.split('-')
if len(tokens) != 2:
raise ValueError(
'Invalid label={}'.format(expanded_label))
return tokens[0]
================================================
FILE: chainer_chemistry/dataset/splitters/__init__.py
================================================
from chainer_chemistry.dataset.splitters import base_splitter # NOQA
from chainer_chemistry.dataset.splitters import random_splitter # NOQA
from chainer_chemistry.dataset.splitters import scaffold_splitter # NOQA
from chainer_chemistry.dataset.splitters import deepchem_scaffold_splitter # NOQA
from chainer_chemistry.dataset.splitters import stratified_splitter # NOQA
from chainer_chemistry.dataset.splitters import time_splitter # NOQA
from chainer_chemistry.dataset.splitters.base_splitter import BaseSplitter # NOQA
from chainer_chemistry.dataset.splitters.random_splitter import RandomSplitter # NOQA
from chainer_chemistry.dataset.splitters.scaffold_splitter import ScaffoldSplitter # NOQA
from chainer_chemistry.dataset.splitters.deepchem_scaffold_splitter import DeepChemScaffoldSplitter # NOQA
from chainer_chemistry.dataset.splitters.stratified_splitter import StratifiedSplitter # NOQA
from chainer_chemistry.dataset.splitters.time_splitter import TimeSplitter # NOQA
split_method_dict = {
'random': RandomSplitter,
'stratified': StratifiedSplitter,
'scaffold': ScaffoldSplitter,
'dc_scaffold': DeepChemScaffoldSplitter,
'time': TimeSplitter,
}
================================================
FILE: chainer_chemistry/dataset/splitters/base_splitter.py
================================================
from chainer_chemistry.datasets.numpy_tuple_dataset import NumpyTupleDataset
def converter_default(dataset, indices):
return dataset[indices]
def converter_numpy_tuple_dataset(dataset, indices):
return NumpyTupleDataset(*dataset.features[indices])
converter_dict = {
NumpyTupleDataset: converter_numpy_tuple_dataset
}
class BaseSplitter(object):
def k_fold_split(self, dataset, k):
raise NotImplementedError
def _split(self, dataset, **kwargs):
raise NotImplementedError
def train_valid_test_split(self, dataset, frac_train=0.8, frac_valid=0.1,
frac_test=0.1, converter=None,
return_index=True, **kwargs):
if converter is None:
converter = converter_dict.get(type(dataset), converter_default)
train_inds, valid_inds, test_inds = self._split(dataset, frac_train,
frac_valid, frac_test,
**kwargs)
if return_index:
return train_inds, valid_inds, test_inds
else:
train = converter(dataset, train_inds)
valid = converter(dataset, valid_inds)
test = converter(dataset, test_inds)
return train, valid, test,
def train_valid_split(self, dataset, frac_train=0.9, frac_valid=0.1,
converter=None, return_index=True, **kwargs):
train_inds, valid_inds, test_inds = self._split(dataset, frac_train,
frac_valid, 0.,
**kwargs)
assert len(test_inds) == 0
if converter is None:
converter = converter_dict.get(type(dataset), converter_default)
if return_index:
return train_inds, valid_inds
else:
train = converter(dataset, train_inds)
valid = converter(dataset, valid_inds)
return train, valid,
================================================
FILE: chainer_chemistry/dataset/splitters/deepchem_scaffold_splitter.py
================================================
from collections import defaultdict
import numpy
from rdkit import Chem
from rdkit.Chem.Scaffolds import MurckoScaffold
from chainer_chemistry.dataset.splitters.base_splitter import BaseSplitter
def generate_scaffold(smiles, include_chirality=False):
"""return scaffold string of target molecule"""
mol = Chem.MolFromSmiles(smiles)
scaffold = MurckoScaffold\
.MurckoScaffoldSmiles(mol=mol, includeChirality=include_chirality)
return scaffold
class DeepChemScaffoldSplitter(BaseSplitter):
"""Class for doing data splits by chemical scaffold.
Referred Deepchem for the implementation, https://github.com/deepchem/deepchem/blob/master/deepchem/splits/splitters.py
"""
def _split(self, dataset, frac_train=0.8, frac_valid=0.1, frac_test=0.1,
**kwargs):
print("Using DeepChem Scaffold")
numpy.testing.assert_almost_equal(frac_train + frac_valid + frac_test,
1.)
seed = kwargs.get('seed', None)
smiles_list = kwargs.get('smiles_list')
include_chirality = kwargs.get('include_chirality')
if len(dataset) != len(smiles_list):
raise ValueError("The lengths of dataset and smiles_list are "
"different")
rng = numpy.random.RandomState(seed)
scaffolds = {}
data_len = len(dataset)
for ind, smiles in enumerate(smiles_list):
scaffold = generate_scaffold(smiles, include_chirality)
if scaffold not in scaffolds:
scaffolds[scaffold] = [ind]
else:
scaffolds[scaffold].append(ind)
# Sort from largest to smallest scaffold sets
scaffolds = {key: sorted(value) for key, value in scaffolds.items()}
scaffold_sets = [ scaffold_set for (scaffold, scaffold_set) in sorted(scaffolds.items(), key=lambda x: (len(x[1]), x[1][0]), reverse=True) ]
train_cutoff = frac_train * len(dataset)
valid_cutoff = (frac_train + frac_valid) * len(dataset)
train_inds, valid_inds, test_inds = [], [], []
for scaffold_set in scaffold_sets:
if len(train_inds) + len(scaffold_set) > train_cutoff:
if len(train_inds) + len(valid_inds) + len(scaffold_set) > valid_cutoff:
test_inds += scaffold_set
else:
valid_inds += scaffold_set
else:
train_inds += scaffold_set
return numpy.array(train_inds), numpy.array(valid_inds),\
numpy.array(test_inds),\
def train_valid_test_split(self, dataset, smiles_list, frac_train=0.8,
frac_valid=0.1, frac_test=0.1, converter=None,
return_index=True, seed=None,
include_chirality=False, **kwargs):
"""Split dataset into train, valid and test set.
Split indices are generated by splitting based on the scaffold of small
molecules.
Args:
dataset(NumpyTupleDataset, numpy.ndarray):
Dataset.
smiles_list(list):
SMILES list corresponding to datset.
seed (int):
Random seed.
frac_train(float):
Fraction of dataset put into training data.
frac_valid(float):
Fraction of dataset put into validation data.
converter(callable):
return_index(bool):
If `True`, this function returns only indices. If `False`, this
function returns splitted dataset.
Returns:
SplittedDataset(tuple): splitted dataset or indices
"""
return super(DeepChemScaffoldSplitter, self)\
.train_valid_test_split(dataset, frac_train, frac_valid, frac_test,
converter, return_index, seed=seed,
smiles_list=smiles_list,
include_chirality=include_chirality,
**kwargs)
def train_valid_split(self, dataset, smiles_list, frac_train=0.9,
frac_valid=0.1, converter=None, return_index=True,
seed=None, include_chirality=False, **kwargs):
"""Split dataset into train and valid set.
Split indices are generated by splitting based on the scaffold of small
molecules.
Args:
dataset(NumpyTupleDataset, numpy.ndarray):
Dataset.
smiles_list(list):
SMILES list corresponding to datset.
seed (int):
Random seed.
frac_train(float):
Fraction of dataset put into training data.
frac_valid(float):
Fraction of dataset put into validation data.
converter(callable):
return_index(bool):
If `True`, this function returns only indices. If `False`, this
function returns splitted dataset.
Returns:
SplittedDataset(tuple): splitted dataset or indices
"""
return super(DeepChemScaffoldSplitter, self)\
.train_valid_split(dataset, frac_train, frac_valid, converter,
return_index, seed=seed,
smiles_list=smiles_list,
include_chirality=include_chirality, **kwargs)
================================================
FILE: chainer_chemistry/dataset/splitters/random_splitter.py
================================================
import numpy
from chainer_chemistry.dataset.splitters.base_splitter import BaseSplitter
class RandomSplitter(BaseSplitter):
"""Class for doing random data splits."""
def _split(self, dataset, frac_train=0.8, frac_valid=0.1, frac_test=0.1,
**kwargs):
seed = kwargs.get('seed')
numpy.testing.assert_almost_equal(frac_train + frac_valid + frac_test,
1.)
if seed is not None:
perm = numpy.random.RandomState(seed).permutation(len(dataset))
else:
perm = numpy.random.permutation(len(dataset))
train_data_size = int(len(dataset) * frac_train)
valid_data_size = int(len(dataset) * frac_valid)
return (perm[:train_data_size],
perm[train_data_size:train_data_size + valid_data_size],
perm[train_data_size + valid_data_size:])
def train_valid_test_split(self, dataset, frac_train=0.8, frac_valid=0.1,
frac_test=0.1, converter=None,
return_index=True, seed=None, **kwargs):
"""Generate indices to split data into train, valid and test set.
Args:
dataset(NumpyTupleDataset, numpy.ndarray):
Dataset.
seed (int):
Random seed.
frac_train(float):
Fraction of dataset put into training data.
frac_valid(float):
Fraction of dataset put into validation data.
frac_test(float):
Fraction of dataset put into test data.
converter(callable):
return_index(bool):
If `True`, this function returns only indexes. If `False`, this
function returns splitted dataset.
Returns:
SplittedDataset(tuple):
splitted dataset or indexes
.. admonition:: Example
>>> from chainer_chemistry.datasets import NumpyTupleDataset
>>> from chainer_chemistry.dataset.splitters import RandomSplitter
>>> a = numpy.random.random((10, 10))
>>> b = numpy.random.random((10, 8))
>>> c = numpy.random.random((10, 1))
>>> d = NumpyTupleDataset(a, b, c)
>>> splitter = RandomSplitter()
>>> train, valid, test =
splitter.train_valid_test_split(dataset,
return_index=False)
>>> print(len(train), len(valid), len(test))
8, 1, 1
"""
return super(RandomSplitter, self).train_valid_test_split(dataset,
frac_train,
frac_valid,
frac_test,
converter,
return_index,
seed=seed,
**kwargs)
def train_valid_split(self, dataset, frac_train=0.9, frac_valid=0.1,
converter=None, return_index=True, seed=None,
**kwargs):
"""Generate indices to split data into train and valid set.
Args:
dataset(NumpyTupleDataset, numpy.ndarray):
Dataset.
seed (int):
Random seed.
frac_train(float):
Fraction of dataset put into training data.
frac_valid(float):
Fraction of dataset put into validation data.
converter(callable):
return_index(bool):
If `True`, this function returns only indexes. If `False`, this
function returns splitted dataset.
Returns:
SplittedDataset(tuple):
splitted dataset or indexes
.. admonition:: Example
>>> from chainer_chemistry.datasets import NumpyTupleDataset
>>> from chainer_chemistry.dataset.splitters import RandomSplitter
>>> a = numpy.random.random((10, 10))
>>> b = numpy.random.random((10, 8))
>>> c = numpy.random.random((10, 1))
>>> d = NumpyTupleDataset(a, b, c)
>>> splitter = RandomSplitter()
>>> train, valid =
splitter.train_valid_split(dataset, return_index=False)
>>> print(len(train), len(valid))
9, 1
"""
return super(RandomSplitter, self).train_valid_split(dataset,
frac_train,
frac_valid,
converter,
return_index,
seed=seed,
**kwargs)
================================================
FILE: chainer_chemistry/dataset/splitters/scaffold_splitter.py
================================================
from collections import defaultdict
import numpy
from rdkit import Chem
from rdkit.Chem.Scaffolds import MurckoScaffold
from chainer_chemistry.dataset.splitters.base_splitter import BaseSplitter
def generate_scaffold(smiles, include_chirality=False):
"""return scaffold string of target molecule"""
mol = Chem.MolFromSmiles(smiles)
scaffold = MurckoScaffold\
.MurckoScaffoldSmiles(mol=mol, includeChirality=include_chirality)
return scaffold
class ScaffoldSplitter(BaseSplitter):
"""Class for doing data splits by chemical scaffold.
Referred Deepchem for the implementation, https://git.io/fXzF4
"""
def _split(self, dataset, frac_train=0.8, frac_valid=0.1, frac_test=0.1,
**kwargs):
numpy.testing.assert_almost_equal(frac_train + frac_valid + frac_test,
1.)
seed = kwargs.get('seed', None)
smiles_list = kwargs.get('smiles_list')
include_chirality = kwargs.get('include_chirality')
if len(dataset) != len(smiles_list):
raise ValueError("The lengths of dataset and smiles_list are "
"different")
rng = numpy.random.RandomState(seed)
scaffolds = defaultdict(list)
for ind, smiles in enumerate(smiles_list):
scaffold = generate_scaffold(smiles, include_chirality)
scaffolds[scaffold].append(ind)
scaffold_sets = rng.permutation(list(scaffolds.values()))
n_total_valid = int(numpy.floor(frac_valid * len(dataset)))
n_total_test = int(numpy.floor(frac_test * len(dataset)))
train_index = []
valid_index = []
test_index = []
for scaffold_set in scaffold_sets:
if len(valid_index) + len(scaffold_set) <= n_total_valid:
valid_index.extend(scaffold_set)
elif len(test_index) + len(scaffold_set) <= n_total_test:
test_index.extend(scaffold_set)
else:
train_index.extend(scaffold_set)
return numpy.array(train_index), numpy.array(valid_index),\
numpy.array(test_index),\
def train_valid_test_split(self, dataset, smiles_list, frac_train=0.8,
frac_valid=0.1, frac_test=0.1, converter=None,
return_index=True, seed=None,
include_chirality=False, **kwargs):
"""Split dataset into train, valid and test set.
Split indices are generated by splitting based on the scaffold of small
molecules.
Args:
dataset(NumpyTupleDataset, numpy.ndarray):
Dataset.
smiles_list(list):
SMILES list corresponding to datset.
seed (int):
Random seed.
frac_train(float):
Fraction of dataset put into training data.
frac_valid(float):
Fraction of dataset put into validation data.
converter(callable):
return_index(bool):
If `True`, this function returns only indices. If `False`, this
function returns splitted dataset.
Returns:
SplittedDataset(tuple): splitted dataset or indices
"""
return super(ScaffoldSplitter, self)\
.train_valid_test_split(dataset, frac_train, frac_valid, frac_test,
converter, return_index, seed=seed,
smiles_list=smiles_list,
include_chirality=include_chirality,
**kwargs)
def train_valid_split(self, dataset, smiles_list, frac_train=0.9,
frac_valid=0.1, converter=None, return_index=True,
seed=None, include_chirality=False, **kwargs):
"""Split dataset into train and valid set.
Split indices are generated by splitting based on the scaffold of small
molecules.
Args:
dataset(NumpyTupleDataset, numpy.ndarray):
Dataset.
smiles_list(list):
SMILES list corresponding to datset.
seed (int):
Random seed.
frac_train(float):
Fraction of dataset put into training data.
frac_valid(float):
Fraction of dataset put into validation data.
converter(callable):
return_index(bool):
If `True`, this function returns only indices. If `False`, this
function returns splitted dataset.
Returns:
SplittedDataset(tuple): splitted dataset or indices
"""
return super(ScaffoldSplitter, self)\
.train_valid_split(dataset, frac_train, frac_valid, converter,
return_index, seed=seed,
smiles_list=smiles_list,
include_chirality=include_chirality, **kwargs)
================================================
FILE: chainer_chemistry/dataset/splitters/stratified_splitter.py
================================================
import numpy
import pandas
from chainer_chemistry.dataset.splitters.base_splitter import BaseSplitter
from chainer_chemistry.datasets.numpy_tuple_dataset import NumpyTupleDataset
def _approximate_mode(class_counts, n_draws):
"""Referred scikit-learn, https://git.io/fPMmB"""
n_class = len(class_counts)
continuous = class_counts * n_draws / class_counts.sum()
floored = numpy.floor(continuous)
assert n_draws // n_class == floored.sum() // n_class
n_remainder = int(n_draws - floored.sum())
remainder = continuous - floored
inds = numpy.argsort(remainder)[::-1]
inds = inds[:n_remainder]
floored[inds] += 1
assert n_draws == floored.sum()
return floored.astype(numpy.int)
class StratifiedSplitter(BaseSplitter):
"""Class for doing stratified data splits."""
def _split(self, dataset, frac_train=0.8, frac_valid=0.1, frac_test=0.1,
labels=None, **kwargs):
numpy.testing.assert_almost_equal(frac_train + frac_valid + frac_test,
1.)
seed = kwargs.get('seed', None)
label_axis = kwargs.get('label_axis', -1)
task_index = kwargs.get('task_index', 0)
n_bin = kwargs.get('n_bin', 10)
task_type = kwargs.get('task_type', 'auto')
if task_type not in ['classification', 'regression', 'auto']:
raise ValueError("{} is invalid. Please use 'classification',"
"'regression' or 'auto'".format(task_type))
rng = numpy.random.RandomState(seed)
if isinstance(labels, list):
labels = numpy.array(labels)
elif labels is None:
if not isinstance(dataset, NumpyTupleDataset):
raise ValueError("Please assign label dataset.")
labels = dataset.features[:, label_axis]
if labels.ndim == 1:
labels = labels
else:
labels = labels[:, task_index]
if task_type == 'auto':
if labels.dtype.kind == 'i':
task_type = 'classification'
elif labels.dtype.kind == 'f':
task_type = 'regression'
else:
raise ValueError
if task_type == 'classification':
classes, labels = numpy.unique(labels, return_inverse=True)
elif task_type == 'regression':
classes = numpy.arange(n_bin)
labels = pandas.qcut(labels, n_bin, labels=False)
else:
raise ValueError
n_classes = classes.shape[0]
n_total_valid = int(numpy.floor(frac_valid * len(dataset)))
n_total_test = int(numpy.floor(frac_test * len(dataset)))
class_counts = numpy.bincount(labels)
class_indices = numpy.split(numpy.argsort(labels,
kind='mergesort'),
numpy.cumsum(class_counts)[:-1])
# n_total_train is the remainder: n - n_total_valid - n_total_test
n_valid_samples = _approximate_mode(class_counts, n_total_valid)
class_counts = class_counts - n_valid_samples
n_test_samples = _approximate_mode(class_counts, n_total_test)
train_index = []
valid_index = []
test_index = []
for i in range(n_classes):
n_valid = n_valid_samples[i]
n_test = n_test_samples[i]
perm = rng.permutation(len(class_indices[i]))
class_perm_index = class_indices[i][perm]
gitextract_w32vn7wx/
├── .codecov.yml
├── .flexci/
│ ├── config.pbtxt
│ ├── gen_config.py
│ └── pytest_script.sh
├── .gitignore
├── .readthedocs.yml
├── .travis.yml
├── LICENSE
├── README.md
├── chainer_chemistry/
│ ├── __init__.py
│ ├── _version.py
│ ├── config.py
│ ├── dataset/
│ │ ├── __init__.py
│ │ ├── converters/
│ │ │ ├── __init__.py
│ │ │ ├── cgcnn_converter.py
│ │ │ ├── concat_mols.py
│ │ │ └── megnet_converter.py
│ │ ├── graph_dataset/
│ │ │ ├── __init__.py
│ │ │ ├── base_graph_data.py
│ │ │ ├── base_graph_dataset.py
│ │ │ └── feature_converters.py
│ │ ├── indexer.py
│ │ ├── indexers/
│ │ │ ├── __init__.py
│ │ │ └── numpy_tuple_dataset_feature_indexer.py
│ │ ├── networkx_preprocessors/
│ │ │ ├── base_networkx.py
│ │ │ └── reddit_coo.py
│ │ ├── parsers/
│ │ │ ├── __init__.py
│ │ │ ├── base_parser.py
│ │ │ ├── csv_file_parser.py
│ │ │ ├── data_frame_parser.py
│ │ │ ├── sdf_file_parser.py
│ │ │ └── smiles_parser.py
│ │ ├── preprocessors/
│ │ │ ├── __init__.py
│ │ │ ├── atomic_number_preprocessor.py
│ │ │ ├── base_preprocessor.py
│ │ │ ├── cgcnn_preprocessor.py
│ │ │ ├── common.py
│ │ │ ├── ecfp_preprocessor.py
│ │ │ ├── ggnn_preprocessor.py
│ │ │ ├── gin_preprocessor.py
│ │ │ ├── gnnfilm_preprocessor.py
│ │ │ ├── gwm_preprocessor.py
│ │ │ ├── megnet_preprocessor.py
│ │ │ ├── mol_preprocessor.py
│ │ │ ├── nfp_preprocessor.py
│ │ │ ├── relgat_preprocessor.py
│ │ │ ├── relgcn_preprocessor.py
│ │ │ ├── rsgcn_preprocessor.py
│ │ │ ├── schnet_preprocessor.py
│ │ │ ├── weavenet_preprocessor.py
│ │ │ ├── wle.py
│ │ │ ├── wle_atom_array_update.py
│ │ │ ├── wle_io.py
│ │ │ └── wle_util.py
│ │ ├── splitters/
│ │ │ ├── __init__.py
│ │ │ ├── base_splitter.py
│ │ │ ├── deepchem_scaffold_splitter.py
│ │ │ ├── random_splitter.py
│ │ │ ├── scaffold_splitter.py
│ │ │ ├── stratified_splitter.py
│ │ │ └── time_splitter.py
│ │ └── utils.py
│ ├── datasets/
│ │ ├── __init__.py
│ │ ├── citation_network/
│ │ │ ├── citation.py
│ │ │ ├── citeseer.py
│ │ │ └── cora.py
│ │ ├── molnet/
│ │ │ ├── __init__.py
│ │ │ ├── chembl_tasks.py
│ │ │ ├── molnet.py
│ │ │ ├── molnet_config.py
│ │ │ ├── pdbbind_time.py
│ │ │ └── toxcast_tasks.py
│ │ ├── numpy_tuple_dataset.py
│ │ ├── qm9.py
│ │ ├── reddit/
│ │ │ └── reddit.py
│ │ ├── tox21.py
│ │ └── zinc.py
│ ├── functions/
│ │ ├── __init__.py
│ │ ├── activation/
│ │ │ ├── __init__.py
│ │ │ ├── megnet_softplus.py
│ │ │ ├── shifted_softplus.py
│ │ │ └── softmax.py
│ │ ├── evaluation/
│ │ │ ├── __init__.py
│ │ │ └── r2_score.py
│ │ ├── loss/
│ │ │ ├── __init__.py
│ │ │ ├── mean_absolute_error.py
│ │ │ └── mean_squared_error.py
│ │ └── math/
│ │ ├── __init__.py
│ │ └── matmul.py
│ ├── iterators/
│ │ ├── __init__.py
│ │ ├── balanced_serial_iterator.py
│ │ └── index_iterator.py
│ ├── link_hooks/
│ │ ├── __init__.py
│ │ └── variable_monitor_link_hook.py
│ ├── links/
│ │ ├── __init__.py
│ │ ├── array/
│ │ │ ├── __init__.py
│ │ │ └── shape_transformer_to_2d.py
│ │ ├── connection/
│ │ │ ├── __init__.py
│ │ │ ├── embed_atom_id.py
│ │ │ ├── graph_linear.py
│ │ │ └── graph_mlp.py
│ │ ├── normalization/
│ │ │ ├── __init__.py
│ │ │ └── graph_batch_normalization.py
│ │ ├── readout/
│ │ │ ├── __init__.py
│ │ │ ├── cgcnn_readout.py
│ │ │ ├── general_readout.py
│ │ │ ├── ggnn_readout.py
│ │ │ ├── megnet_readout.py
│ │ │ ├── mpnn_readout.py
│ │ │ ├── nfp_readout.py
│ │ │ ├── scatter_ggnn_readout.py
│ │ │ ├── schnet_readout.py
│ │ │ └── set2set.py
│ │ ├── scaler/
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── flow_scaler.py
│ │ │ ├── max_abs_scaler.py
│ │ │ ├── min_max_scaler.py
│ │ │ └── standard_scaler.py
│ │ └── update/
│ │ ├── __init__.py
│ │ ├── cgcnn_update.py
│ │ ├── ggnn_update.py
│ │ ├── gin_update.py
│ │ ├── gnn_film_update.py
│ │ ├── megnet_update.py
│ │ ├── mpnn_update.py
│ │ ├── nfp_update.py
│ │ ├── relgat_update.py
│ │ ├── relgcn_update.py
│ │ ├── rsgcn_update.py
│ │ └── schnet_update.py
│ ├── models/
│ │ ├── __init__.py
│ │ ├── cgcnn.py
│ │ ├── cwle/
│ │ │ ├── __init__.py
│ │ │ ├── cwle_graph_conv_model.py
│ │ │ └── cwle_net.py
│ │ ├── ggnn.py
│ │ ├── gin.py
│ │ ├── gnn_film.py
│ │ ├── gwle/
│ │ │ ├── __init__.py
│ │ │ ├── gwle_graph_conv_model.py
│ │ │ └── gwle_net.py
│ │ ├── gwm/
│ │ │ ├── __init__.py
│ │ │ ├── gwm.py
│ │ │ ├── gwm_graph_conv_model.py
│ │ │ └── gwm_net.py
│ │ ├── megnet.py
│ │ ├── mlp.py
│ │ ├── mpnn.py
│ │ ├── nfp.py
│ │ ├── prediction/
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── classifier.py
│ │ │ ├── graph_conv_predictor.py
│ │ │ ├── node_classifier.py
│ │ │ ├── regressor.py
│ │ │ └── set_up_predictor.py
│ │ ├── relgat.py
│ │ ├── relgcn.py
│ │ ├── rsgcn.py
│ │ ├── schnet.py
│ │ └── weavenet.py
│ ├── saliency/
│ │ ├── __init__.py
│ │ ├── calculator/
│ │ │ ├── __init__.py
│ │ │ ├── base_calculator.py
│ │ │ ├── calculator_utils.py
│ │ │ ├── gradient_calculator.py
│ │ │ ├── integrated_gradients_calculator.py
│ │ │ └── occlusion_calculator.py
│ │ └── visualizer/
│ │ ├── __init__.py
│ │ ├── base_visualizer.py
│ │ ├── image_visualizer.py
│ │ ├── mol_visualizer.py
│ │ ├── table_visualizer.py
│ │ └── visualizer_utils.py
│ ├── training/
│ │ ├── __init__.py
│ │ └── extensions/
│ │ ├── __init__.py
│ │ ├── auto_print_report.py
│ │ ├── batch_evaluator.py
│ │ ├── prc_auc_evaluator.py
│ │ ├── r2_score_evaluator.py
│ │ └── roc_auc_evaluator.py
│ └── utils/
│ ├── __init__.py
│ ├── extend.py
│ ├── json_utils.py
│ ├── permutation.py
│ ├── sparse_utils.py
│ └── train_utils.py
├── docker/
│ ├── conda/
│ │ ├── python36/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37-chainerx-cpu-base/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37-chainerx-cpu-latest/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37-chainerx-cpu-stable/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37-chainerx-gpu-base/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ ├── python37-chainerx-gpu-latest/
│ │ │ ├── Dockerfile
│ │ │ └── conda-entrypoint.sh
│ │ └── python37-chainerx-gpu-stable/
│ │ ├── Dockerfile
│ │ └── conda-entrypoint.sh
│ └── python3/
│ └── Dockerfile
├── docs/
│ ├── Makefile
│ └── source/
│ ├── _autosummary_check.py
│ ├── conf.py
│ ├── contribution.rst
│ ├── dataset.rst
│ ├── datasets.rst
│ ├── development.rst
│ ├── environment.yml
│ ├── functions.rst
│ ├── index.rst
│ ├── install.rst
│ ├── iterators.rst
│ ├── links.rst
│ ├── models.rst
│ ├── reference.rst
│ ├── requirements.txt
│ ├── training.rst
│ ├── tutorial.rst
│ └── utils.rst
├── examples/
│ ├── .gitignore
│ ├── README.md
│ ├── molnet/
│ │ ├── README.md
│ │ ├── evaluate_models_molnet.sh
│ │ ├── predict_molnet.py
│ │ ├── summary_eval_molnet.py
│ │ ├── test_molnet.sh
│ │ └── train_molnet.py
│ ├── molnet_wle/
│ │ ├── README.md
│ │ ├── predict_molnet_wle.py
│ │ └── train_molnet_wle.py
│ ├── network_graph/
│ │ ├── README.md
│ │ ├── citeseer/
│ │ │ └── .gitignore
│ │ ├── cora/
│ │ │ └── .gitignore
│ │ ├── padding_model_wrapper.py
│ │ ├── reddit/
│ │ │ └── .gitignore
│ │ └── train_network_graph.py
│ ├── own_dataset/
│ │ ├── README.md
│ │ ├── dataset_test.csv
│ │ ├── dataset_train.csv
│ │ ├── evaluate_own_dataset.sh
│ │ ├── plot.py
│ │ ├── predict_own_dataset.py
│ │ ├── test_own_dataset.sh
│ │ └── train_own_dataset.py
│ ├── qm9/
│ │ ├── README.md
│ │ ├── evaluate_models_qm9.sh
│ │ ├── plot.py
│ │ ├── predict_qm9.py
│ │ ├── qm9_dataset_exploration.ipynb
│ │ ├── test_qm9.sh
│ │ └── train_qm9.py
│ ├── test_examples.sh
│ └── tox21/
│ ├── .gitignore
│ ├── README.md
│ ├── data.py
│ ├── evaluate_models_tox21.sh
│ ├── plot.py
│ ├── predict_tox21_with_classifier.py
│ ├── test_tox21.sh
│ ├── tox21_dataset_exploration.ipynb
│ └── train_tox21.py
├── setup.py
└── tests/
├── dataset_tests/
│ ├── parsers_tests/
│ │ ├── test_csv_file_parser.py
│ │ ├── test_data_frame_parser.py
│ │ ├── test_sdf_file_parser.py
│ │ └── test_smiles_parser.py
│ ├── preprocessor_tests/
│ │ └── test_common.py
│ ├── preprocessors_tests/
│ │ ├── test_atomic_number_preprocessor.py
│ │ ├── test_cgcnn_preprocessor.py
│ │ ├── test_gat_preprocessor.py
│ │ ├── test_ggnn_preprocessor.py
│ │ ├── test_gwm_preprocessor.py
│ │ ├── test_mol_preprocessor.py
│ │ ├── test_nfp_preprocessor.py
│ │ ├── test_relgcn_preprocessor.py
│ │ ├── test_rsgcn_preprocessor.py
│ │ ├── test_schnet_preprocessor.py
│ │ ├── test_weavenet_preprocessor.py
│ │ ├── test_wle.py
│ │ ├── test_wle_atom_array_update.py
│ │ └── test_wle_util.py
│ ├── splitters_tests/
│ │ ├── test_deepchem_scaffold_splitter.py
│ │ ├── test_random_splitter.py
│ │ ├── test_scaffold_splitter.py
│ │ ├── test_stratified_splitter.py
│ │ └── test_time_splitter.py
│ ├── test_converters.py
│ └── test_numpy_tuple_feature_indexer.py
├── datasets_tests/
│ ├── molnet_tests/
│ │ ├── test_molnet.py
│ │ └── test_pdbbind_time.py
│ ├── test_numpy_tuple_dataset.py
│ ├── test_qm9.py
│ ├── test_tox21.py
│ └── test_zinc.py
├── functions_tests/
│ ├── activation/
│ │ ├── test_megnet_softplus.py
│ │ ├── test_shifted_softplus.py
│ │ └── test_softmax.py
│ ├── evaluation/
│ │ └── test_r2_score.py
│ └── loss/
│ ├── test_mean_absolute_error.py
│ └── test_mean_squared_error.py
├── iterators_tests/
│ ├── test_balanced_serial_iterator.py
│ └── test_index_iterator.py
├── link_hooks_tests/
│ └── test_variable_monitor_link_hook.py
├── links_tests/
│ ├── array_tests/
│ │ └── test_shape_transformer_to_2d.py
│ ├── connection_tests/
│ │ ├── test_embed_atom_id.py
│ │ ├── test_graph_linear.py
│ │ └── test_graph_mlp.py
│ ├── readout_tests/
│ │ ├── test_cgcnn_readout.py
│ │ ├── test_general_readout.py
│ │ ├── test_ggnn_readout.py
│ │ ├── test_megnet_readout.py
│ │ ├── test_mpnn_readout.py
│ │ ├── test_nfp_readout.py
│ │ ├── test_schnet_readout.py
│ │ └── test_set2set.py
│ ├── scaler_tests/
│ │ ├── test_flow_scaler.py
│ │ ├── test_max_abs_scaler.py
│ │ ├── test_min_max_scaler.py
│ │ └── test_standard_scaler.py
│ └── update_tests/
│ ├── test_cgcnn_update.py
│ ├── test_ggnn_update.py
│ ├── test_gin_update.py
│ ├── test_gnn_film_update.py
│ ├── test_megnet_update.py
│ ├── test_mpnn_update.py
│ ├── test_nfp_update.py
│ ├── test_relgat_update.py
│ ├── test_relgcn_update.py
│ ├── test_rsgcn_update.py
│ └── test_schnet_update.py
├── models_tests/
│ ├── gwm_tests/
│ │ ├── test_gwm.py
│ │ └── test_gwm_graph_conv_model.py
│ ├── prediction_tests/
│ │ ├── test_base.py
│ │ ├── test_classifier.py
│ │ ├── test_graph_conv_predictor.py
│ │ ├── test_regressor.py
│ │ └── test_set_up_predictor.py
│ ├── test_cgcnn.py
│ ├── test_ggnn.py
│ ├── test_gin.py
│ ├── test_gnn_film.py
│ ├── test_megnet.py
│ ├── test_mlp.py
│ ├── test_mpnn.py
│ ├── test_nfp.py
│ ├── test_relgat.py
│ ├── test_relgcn.py
│ ├── test_rsgcn.py
│ ├── test_schnet.py
│ └── test_weavenet.py
├── saliency_tests/
│ ├── calculator_tests/
│ │ ├── test_base_calculator.py
│ │ ├── test_calculator_utils.py
│ │ ├── test_gradient_calculator.py
│ │ ├── test_integrated_gradient_calculator.py
│ │ └── test_occlusion_calculator.py
│ └── visualizer_tests/
│ ├── test_image_visualizer.py
│ ├── test_mol_visualizer.py
│ ├── test_table_visualizer.py
│ └── test_visualizer_utils.py
├── test_init.py
├── training_tests/
│ └── extensions_tests/
│ ├── test_auto_print_report.py
│ ├── test_prc_auc_evaluator.py
│ ├── test_r2_score_evaluator.py
│ └── test_roc_auc_evaluator.py
└── utils_tests/
├── test_extend.py
├── test_json_utils.py
├── test_permutation.py
├── test_sparse_utils.py
└── test_train_utils.py
SYMBOL INDEX (1707 symbols across 266 files)
FILE: .flexci/gen_config.py
function test_config (line 11) | def test_config(python, chainer, target, chainerx):
function main (line 40) | def main():
function dump_pbtxt (line 58) | def dump_pbtxt(key, value, level=0):
FILE: chainer_chemistry/dataset/converters/cgcnn_converter.py
function cgcnn_converter (line 9) | def cgcnn_converter(batch, device=None, padding=None):
FILE: chainer_chemistry/dataset/converters/concat_mols.py
function concat_mols (line 5) | def concat_mols(batch, device=None, padding=0):
FILE: chainer_chemistry/dataset/converters/megnet_converter.py
function megnet_converter (line 6) | def megnet_converter(batch, device=None, padding=0):
FILE: chainer_chemistry/dataset/graph_dataset/base_graph_data.py
class BaseGraphData (line 6) | class BaseGraphData(object):
method __init__ (line 9) | def __init__(self, *args, **kwargs):
method to_device (line 13) | def to_device(self, device):
class PaddingGraphData (line 35) | class PaddingGraphData(BaseGraphData):
method __init__ (line 44) | def __init__(self, x=None, adj=None, super_node=None, pos=None, y=None,
class SparseGraphData (line 55) | class SparseGraphData(BaseGraphData):
method __init__ (line 65) | def __init__(self, x=None, edge_index=None, edge_attr=None,
FILE: chainer_chemistry/dataset/graph_dataset/base_graph_dataset.py
class BaseGraphDataset (line 11) | class BaseGraphDataset(object):
method __init__ (line 17) | def __init__(self, data_list, *args, **kwargs):
method register_feature (line 20) | def register_feature(self, key, batch_method, skip_if_none=True):
method update_feature (line 34) | def update_feature(self, key, batch_method):
method __len__ (line 45) | def __len__(self):
method __getitem__ (line 48) | def __getitem__(self, item):
method converter (line 51) | def converter(self, batch, device=None):
class PaddingGraphDataset (line 70) | class PaddingGraphDataset(BaseGraphDataset):
method __init__ (line 74) | def __init__(self, data_list):
class SparseGraphDataset (line 84) | class SparseGraphDataset(BaseGraphDataset):
method __init__ (line 88) | def __init__(self, data_list):
method converter (line 98) | def converter(self, batch, device=None):
method converter_with_padding (line 123) | def converter_with_padding(self, batch, device=None):
FILE: chainer_chemistry/dataset/graph_dataset/feature_converters.py
function batch_with_padding (line 6) | def batch_with_padding(name, batch, device=None, pad=0):
function batch_without_padding (line 23) | def batch_without_padding(name, batch, device=None):
function concat_with_padding (line 39) | def concat_with_padding(name, batch, device=None, pad=0):
function concat (line 56) | def concat(name, batch, device=None, axis=0):
function shift_concat (line 73) | def shift_concat(name, batch, device=None, shift_attr='x', shift_axis=1):
function shift_concat_with_padding (line 96) | def shift_concat_with_padding(name, batch, device=None, shift_attr='x',
FILE: chainer_chemistry/dataset/indexer.py
class ExtractBySliceNotSupportedError (line 5) | class ExtractBySliceNotSupportedError(Exception):
class BaseIndexer (line 9) | class BaseIndexer(object):
method __getitem__ (line 12) | def __getitem__(self, item):
class BaseFeatureIndexer (line 16) | class BaseFeatureIndexer(BaseIndexer):
method __init__ (line 32) | def __init__(self, dataset):
method features_length (line 36) | def features_length(self):
method dataset_length (line 45) | def dataset_length(self):
method shape (line 49) | def shape(self):
method extract_feature_by_slice (line 52) | def extract_feature_by_slice(self, slice_index, j):
method extract_feature (line 69) | def extract_feature(self, i, j):
method create_feature_index_list (line 81) | def create_feature_index_list(self, feature_index):
method preprocess (line 102) | def preprocess(self, item):
method postprocess (line 105) | def postprocess(self, item):
method __getitem__ (line 108) | def __getitem__(self, item):
method check_type_feature_index (line 139) | def check_type_feature_index(self, j):
method _extract_feature (line 144) | def _extract_feature(self, data_index, j):
FILE: chainer_chemistry/dataset/indexers/numpy_tuple_dataset_feature_indexer.py
class NumpyTupleDatasetFeatureIndexer (line 4) | class NumpyTupleDatasetFeatureIndexer(BaseFeatureIndexer):
method __init__ (line 12) | def __init__(self, dataset):
method features_length (line 16) | def features_length(self):
method extract_feature_by_slice (line 19) | def extract_feature_by_slice(self, slice_index, j):
method extract_feature (line 22) | def extract_feature(self, i, j):
FILE: chainer_chemistry/dataset/networkx_preprocessors/base_networkx.py
class BaseNetworkxPreprocessor (line 10) | class BaseNetworkxPreprocessor(object):
method __init__ (line 13) | def __init__(self, *args, **kwargs):
method get_x (line 16) | def get_x(self, graph):
method get_y (line 27) | def get_y(self, graph):
class BasePaddingNetworkxPreprocessor (line 37) | class BasePaddingNetworkxPreprocessor(BaseNetworkxPreprocessor):
method __init__ (line 42) | def __init__(self, use_coo=False, *args, **kwargs):
method construct_data (line 45) | def construct_data(self, graph):
method create_dataset (line 91) | def create_dataset(self, graph_list):
class BaseSparseNetworkxPreprocessor (line 108) | class BaseSparseNetworkxPreprocessor(BaseNetworkxPreprocessor):
method construct_data (line 113) | def construct_data(self, graph):
method add_self_loop (line 137) | def add_self_loop(self, graph):
method create_dataset (line 142) | def create_dataset(self, graph_list):
FILE: chainer_chemistry/dataset/networkx_preprocessors/reddit_coo.py
function get_reddit_coo_data (line 11) | def get_reddit_coo_data(dirpath):
FILE: chainer_chemistry/dataset/parsers/base_parser.py
class BaseParser (line 1) | class BaseParser(object):
method __init__ (line 2) | def __init__(self):
class BaseFileParser (line 6) | class BaseFileParser(BaseParser):
method __init__ (line 9) | def __init__(self, preprocessor):
method parse (line 13) | def parse(self, filepath):
FILE: chainer_chemistry/dataset/parsers/csv_file_parser.py
class CSVFileParser (line 6) | class CSVFileParser(DataFrameParser):
method __init__ (line 22) | def __init__(self, preprocessor,
method parse (line 32) | def parse(self, filepath, return_smiles=False, target_index=None,
method extract_total_num (line 62) | def extract_total_num(self, filepath):
FILE: chainer_chemistry/dataset/parsers/data_frame_parser.py
class DataFrameParser (line 14) | class DataFrameParser(BaseFileParser):
method __init__ (line 30) | def __init__(self, preprocessor,
method parse (line 44) | def parse(self, df, return_smiles=False, target_index=None,
method extract_total_num (line 184) | def extract_total_num(self, df):
FILE: chainer_chemistry/dataset/parsers/sdf_file_parser.py
class SDFFileParser (line 12) | class SDFFileParser(BaseFileParser):
method __init__ (line 23) | def __init__(self, preprocessor, labels=None, postprocess_label=None,
method parse (line 31) | def parse(self, filepath, return_smiles=False, target_index=None,
method extract_total_num (line 171) | def extract_total_num(self, filepath):
FILE: chainer_chemistry/dataset/parsers/smiles_parser.py
class SmilesParser (line 6) | class SmilesParser(DataFrameParser):
method __init__ (line 18) | def __init__(self, preprocessor,
method parse (line 26) | def parse(self, smiles_list, return_smiles=False, target_index=None,
method extract_total_num (line 56) | def extract_total_num(self, smiles_list):
FILE: chainer_chemistry/dataset/preprocessors/atomic_number_preprocessor.py
class AtomicNumberPreprocessor (line 8) | class AtomicNumberPreprocessor(MolPreprocessor):
method __init__ (line 24) | def __init__(self, max_atoms=-1, out_size=-1):
method get_input_features (line 32) | def get_input_features(self, mol):
FILE: chainer_chemistry/dataset/preprocessors/base_preprocessor.py
class BasePreprocessor (line 6) | class BasePreprocessor(object):
method __init__ (line 9) | def __init__(self):
method process (line 12) | def process(self, filepath):
FILE: chainer_chemistry/dataset/preprocessors/cgcnn_preprocessor.py
function get_atom_init_json_filepath (line 18) | def get_atom_init_json_filepath(download_if_not_exist=True):
class CGCNNPreprocessor (line 40) | class CGCNNPreprocessor(MolPreprocessor):
method __init__ (line 47) | def __init__(self, max_num_nbr=12, max_radius=8, expand_dim=40):
method get_input_features (line 58) | def get_input_features(self, mol):
FILE: chainer_chemistry/dataset/preprocessors/common.py
class MolFeatureExtractionError (line 9) | class MolFeatureExtractionError(Exception):
function type_check_num_atoms (line 14) | def type_check_num_atoms(mol, num_max_atoms=-1):
function construct_atomic_number_array (line 35) | def construct_atomic_number_array(mol, out_size=-1):
function construct_adj_matrix (line 70) | def construct_adj_matrix(mol, out_size=-1, self_connection=True):
function construct_discrete_edge_matrix (line 121) | def construct_discrete_edge_matrix(mol, out_size=-1,
function mol_basic_info_feature (line 180) | def mol_basic_info_feature(mol, atom_array, adj):
function mol_atom_type_feature (line 191) | def mol_atom_type_feature(mol, atom_array, adj):
function mol_atom_freq_feature (line 196) | def mol_atom_freq_feature(mol, atom_array, adj):
function mol_bond_type_feature (line 201) | def mol_bond_type_feature(mol, atom_array, adj):
function mol_bond_freq_feature (line 208) | def mol_bond_freq_feature(mol, atom_array, adj):
function construct_supernode_feature (line 219) | def construct_supernode_feature(mol, atom_array, adj, feature_functions=...
FILE: chainer_chemistry/dataset/preprocessors/ecfp_preprocessor.py
class ECFPPreprocessor (line 10) | class ECFPPreprocessor(MolPreprocessor):
method __init__ (line 12) | def __init__(self, radius=2):
method get_input_features (line 16) | def get_input_features(self, mol):
FILE: chainer_chemistry/dataset/preprocessors/ggnn_preprocessor.py
class GGNNPreprocessor (line 11) | class GGNNPreprocessor(MolPreprocessor):
method __init__ (line 29) | def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
method get_input_features (line 39) | def get_input_features(self, mol):
class GGNNSparsePreprocessor (line 55) | class GGNNSparsePreprocessor(GGNNPreprocessor):
method __init__ (line 58) | def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
method construct_sparse_data (line 64) | def construct_sparse_data(self, x, adj, y):
method create_dataset (line 92) | def create_dataset(self, *args, **kwargs):
FILE: chainer_chemistry/dataset/preprocessors/gin_preprocessor.py
class GINPreprocessor (line 11) | class GINPreprocessor(MolPreprocessor):
method __init__ (line 16) | def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False):
method get_input_features (line 38) | def get_input_features(self, mol):
class GINSparsePreprocessor (line 53) | class GINSparsePreprocessor(MolPreprocessor):
method __init__ (line 56) | def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False):
method get_input_features (line 64) | def get_input_features(self, mol):
method construct_sparse_data (line 70) | def construct_sparse_data(self, x, adj, y):
method create_dataset (line 94) | def create_dataset(self, *args, **kwargs):
FILE: chainer_chemistry/dataset/preprocessors/gnnfilm_preprocessor.py
class GNNFiLMPreprocessor (line 7) | class GNNFiLMPreprocessor(MolPreprocessor):
method __init__ (line 25) | def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
method get_input_features (line 35) | def get_input_features(self, mol):
FILE: chainer_chemistry/dataset/preprocessors/gwm_preprocessor.py
class NFPGWMPreprocessor (line 8) | class NFPGWMPreprocessor(NFPPreprocessor):
method get_input_features (line 9) | def get_input_features(self, mol):
class GGNNGWMPreprocessor (line 17) | class GGNNGWMPreprocessor(GGNNPreprocessor):
method get_input_features (line 18) | def get_input_features(self, mol):
class GINGWMPreprocessor (line 26) | class GINGWMPreprocessor(GINPreprocessor):
method get_input_features (line 27) | def get_input_features(self, mol):
class RSGCNGWMPreprocessor (line 35) | class RSGCNGWMPreprocessor(RSGCNPreprocessor):
method get_input_features (line 36) | def get_input_features(self, mol):
FILE: chainer_chemistry/dataset/preprocessors/megnet_preprocessor.py
class ChemicalFeaturesFactory (line 20) | class ChemicalFeaturesFactory(object):
method get_instance (line 24) | def get_instance(self):
function construct_atom_type_vec (line 33) | def construct_atom_type_vec(mol, num_max_atoms, atom_list=None,
function construct_atom_chirality_vec (line 58) | def construct_atom_chirality_vec(mol, num_max_atoms):
function construct_atom_ring_vec (line 72) | def construct_atom_ring_vec(mol, num_max_atoms):
function construct_hybridization_vec (line 85) | def construct_hybridization_vec(mol, num_max_atoms):
function construct_hydrogen_bonding (line 102) | def construct_hydrogen_bonding(mol, num_max_atoms):
function construct_aromaticity_vec (line 117) | def construct_aromaticity_vec(mol, num_max_atoms):
function construct_atom_feature (line 126) | def construct_atom_feature(mol, use_all_feature, atom_list=None,
function construct_bond_vec (line 176) | def construct_bond_vec(mol, i, j):
function get_is_in_ring (line 194) | def get_is_in_ring(mol):
function construct_ring_feature_vec (line 217) | def construct_ring_feature_vec(is_in_ring, i, j):
function construct_expanded_distance_vec (line 225) | def construct_expanded_distance_vec(distance_matrix_3d, converter, i, j):
function construct_pair_feature (line 233) | def construct_pair_feature(mol, use_all_feature):
function construct_global_state_feature (line 299) | def construct_global_state_feature(mol):
class MEGNetPreprocessor (line 315) | class MEGNetPreprocessor(MolPreprocessor):
method __init__ (line 339) | def __init__(self, max_atoms=-1, add_Hs=True,
method get_input_features (line 356) | def get_input_features(self, mol):
FILE: chainer_chemistry/dataset/preprocessors/mol_preprocessor.py
class MolPreprocessor (line 7) | class MolPreprocessor(BasePreprocessor):
method __init__ (line 15) | def __init__(self, add_Hs=False, kekulize=False):
method prepare_smiles_and_mol (line 20) | def prepare_smiles_and_mol(self, mol):
method get_label (line 43) | def get_label(self, mol, label_names=None):
method get_input_features (line 85) | def get_input_features(self, mol):
method create_dataset (line 96) | def create_dataset(self, *args, **kwargs):
method process (line 99) | def process(self, filepath):
FILE: chainer_chemistry/dataset/preprocessors/nfp_preprocessor.py
class NFPPreprocessor (line 9) | class NFPPreprocessor(MolPreprocessor):
method __init__ (line 27) | def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
method get_input_features (line 37) | def get_input_features(self, mol):
FILE: chainer_chemistry/dataset/preprocessors/relgat_preprocessor.py
class RelGATPreprocessor (line 8) | class RelGATPreprocessor(MolPreprocessor):
method __init__ (line 24) | def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False):
method get_input_features (line 32) | def get_input_features(self, mol):
FILE: chainer_chemistry/dataset/preprocessors/relgcn_preprocessor.py
class RelGCNPreprocessor (line 4) | class RelGCNPreprocessor(GGNNPreprocessor):
method __init__ (line 22) | def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
method get_input_features (line 28) | def get_input_features(self, mol):
class RelGCNSparsePreprocessor (line 40) | class RelGCNSparsePreprocessor(GGNNSparsePreprocessor):
FILE: chainer_chemistry/dataset/preprocessors/rsgcn_preprocessor.py
class RSGCNPreprocessor (line 10) | class RSGCNPreprocessor(MolPreprocessor):
method __init__ (line 28) | def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
method get_input_features (line 38) | def get_input_features(self, mol):
FILE: chainer_chemistry/dataset/preprocessors/schnet_preprocessor.py
function construct_distance_matrix (line 16) | def construct_distance_matrix(mol, out_size=-1, contain_Hs=False):
class SchNetPreprocessor (line 68) | class SchNetPreprocessor(MolPreprocessor):
method __init__ (line 86) | def __init__(self, max_atoms=-1, out_size=-1, add_Hs=False,
method get_input_features (line 96) | def get_input_features(self, mol):
FILE: chainer_chemistry/dataset/preprocessors/weavenet_preprocessor.py
function construct_atom_type_vec (line 24) | def construct_atom_type_vec(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS,
function construct_formal_charge_vec (line 49) | def construct_formal_charge_vec(mol,
function construct_hybridization_vec (line 59) | def construct_hybridization_vec(mol,
function construct_partial_charge_vec (line 80) | def construct_partial_charge_vec(
function construct_atom_ring_vec (line 91) | def construct_atom_ring_vec(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATO...
function construct_hydrogen_bonding (line 105) | def construct_hydrogen_bonding(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_...
function construct_num_hydrogens_vec (line 120) | def construct_num_hydrogens_vec(mol,
function construct_aromaticity_vec (line 139) | def construct_aromaticity_vec(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_A...
function construct_atom_feature (line 148) | def construct_atom_feature(mol, add_Hs,
function construct_bond_vec (line 202) | def construct_bond_vec(mol, i, j):
function construct_distance_vec (line 220) | def construct_distance_vec(distance_matrix, i, j):
function construct_ring_feature_vec (line 227) | def construct_ring_feature_vec(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_...
function construct_pair_feature (line 243) | def construct_pair_feature(mol, num_max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS):
class WeaveNetPreprocessor (line 272) | class WeaveNetPreprocessor(MolPreprocessor):
method __init__ (line 298) | def __init__(self, max_atoms=WEAVE_DEFAULT_NUM_MAX_ATOMS, add_Hs=True,
method get_input_features (line 315) | def get_input_features(self, mol):
FILE: chainer_chemistry/dataset/preprocessors/wle.py
function apply_wle_for_datasets (line 10) | def apply_wle_for_datasets(datasets, cutoff=0, k=1):
function apply_cwle_for_datasets (line 42) | def apply_cwle_for_datasets(datasets, k=1):
function _findmaxidx (line 81) | def _findmaxidx(datasets, idx):
function findmaxidx (line 99) | def findmaxidx(datasets, target='atom_label'):
FILE: chainer_chemistry/dataset/preprocessors/wle_atom_array_update.py
function update_atom_arrays (line 8) | def update_atom_arrays(atom_arrays, adj_arrays, cutoff, with_focus_atom=...
function shrink_expanded_labels (line 20) | def shrink_expanded_labels(expanded_atom_lists,
function list_all_expanded_labels (line 73) | def list_all_expanded_labels(atom_arrays, adj_arrays, with_focus_atom=Tr...
FILE: chainer_chemistry/dataset/preprocessors/wle_io.py
function create_datasets (line 10) | def create_datasets(atom_arrays, adj_arrays, teach_signals, wle_arrays=N...
function load_dataset_elements (line 57) | def load_dataset_elements(datasets):
FILE: chainer_chemistry/dataset/preprocessors/wle_util.py
function _index (line 7) | def _index(atom, values):
function to_index (line 15) | def to_index(mols, values):
function compress_relation_axis (line 21) | def compress_relation_axis(adj_array):
function _to_string (line 33) | def _to_string(atom_label, neighbor_labels, with_focus_atom):
function get_neighbor_representation (line 42) | def get_neighbor_representation(idx, atom_array, neighbors, with_focus_a...
function get_focus_node_label (line 53) | def get_focus_node_label(expanded_label):
FILE: chainer_chemistry/dataset/splitters/base_splitter.py
function converter_default (line 4) | def converter_default(dataset, indices):
function converter_numpy_tuple_dataset (line 8) | def converter_numpy_tuple_dataset(dataset, indices):
class BaseSplitter (line 17) | class BaseSplitter(object):
method k_fold_split (line 18) | def k_fold_split(self, dataset, k):
method _split (line 21) | def _split(self, dataset, **kwargs):
method train_valid_test_split (line 24) | def train_valid_test_split(self, dataset, frac_train=0.8, frac_valid=0.1,
method train_valid_split (line 43) | def train_valid_split(self, dataset, frac_train=0.9, frac_valid=0.1,
FILE: chainer_chemistry/dataset/splitters/deepchem_scaffold_splitter.py
function generate_scaffold (line 10) | def generate_scaffold(smiles, include_chirality=False):
class DeepChemScaffoldSplitter (line 18) | class DeepChemScaffoldSplitter(BaseSplitter):
method _split (line 23) | def _split(self, dataset, frac_train=0.8, frac_valid=0.1, frac_test=0.1,
method train_valid_test_split (line 67) | def train_valid_test_split(self, dataset, smiles_list, frac_train=0.8,
method train_valid_split (line 103) | def train_valid_split(self, dataset, smiles_list, frac_train=0.9,
FILE: chainer_chemistry/dataset/splitters/random_splitter.py
class RandomSplitter (line 6) | class RandomSplitter(BaseSplitter):
method _split (line 8) | def _split(self, dataset, frac_train=0.8, frac_valid=0.1, frac_test=0.1,
method train_valid_test_split (line 24) | def train_valid_test_split(self, dataset, frac_train=0.8, frac_valid=0.1,
method train_valid_split (line 73) | def train_valid_split(self, dataset, frac_train=0.9, frac_valid=0.1,
FILE: chainer_chemistry/dataset/splitters/scaffold_splitter.py
function generate_scaffold (line 10) | def generate_scaffold(smiles, include_chirality=False):
class ScaffoldSplitter (line 18) | class ScaffoldSplitter(BaseSplitter):
method _split (line 23) | def _split(self, dataset, frac_train=0.8, frac_valid=0.1, frac_test=0.1,
method train_valid_test_split (line 62) | def train_valid_test_split(self, dataset, smiles_list, frac_train=0.8,
method train_valid_split (line 98) | def train_valid_split(self, dataset, smiles_list, frac_train=0.9,
FILE: chainer_chemistry/dataset/splitters/stratified_splitter.py
function _approximate_mode (line 8) | def _approximate_mode(class_counts, n_draws):
class StratifiedSplitter (line 23) | class StratifiedSplitter(BaseSplitter):
method _split (line 26) | def _split(self, dataset, frac_train=0.8, frac_valid=0.1, frac_test=0.1,
method train_valid_test_split (line 109) | def train_valid_test_split(self, dataset, labels=None, label_axis=-1,
method train_valid_split (line 164) | def train_valid_split(self, dataset, labels=None, label_axis=-1,
FILE: chainer_chemistry/dataset/splitters/time_splitter.py
class TimeSplitter (line 6) | class TimeSplitter(BaseSplitter):
method _split (line 9) | def _split(self, dataset, frac_train=0.8, frac_valid=0.1, frac_test=0.1,
method train_valid_test_split (line 29) | def train_valid_test_split(self, dataset, time_list=None, frac_train=0.8,
method train_valid_split (line 73) | def train_valid_split(self, dataset, time_list=None, frac_train=0.9,
FILE: chainer_chemistry/dataset/utils.py
class GaussianDistance (line 4) | class GaussianDistance(object):
method __init__ (line 13) | def __init__(self, centers=None, width=0.5):
method expand (line 20) | def expand(self, d):
method expand_from_distances (line 33) | def expand_from_distances(self, distances):
FILE: chainer_chemistry/datasets/citation_network/citation.py
function citation_to_networkx (line 8) | def citation_to_networkx(dirpath, name):
FILE: chainer_chemistry/datasets/citation_network/citeseer.py
function get_citeseer_label_names (line 17) | def get_citeseer_label_names():
function get_citeseer_dirpath (line 23) | def get_citeseer_dirpath(download_if_not_exist=True):
function get_citeseer_filepath (line 45) | def get_citeseer_filepath(download_if_not_exist=True):
function _get_citeseer_filepath (line 70) | def _get_citeseer_filepath():
function download_and_extract_citeseer (line 85) | def download_and_extract_citeseer(save_dirpath):
FILE: chainer_chemistry/datasets/citation_network/cora.py
function get_cora_label_names (line 21) | def get_cora_label_names():
function get_cora_dirpath (line 27) | def get_cora_dirpath(download_if_not_exist=True):
function get_cora_filepath (line 49) | def get_cora_filepath(download_if_not_exist=True):
function _get_cora_filepath (line 75) | def _get_cora_filepath():
function download_and_extract_cora (line 91) | def download_and_extract_cora(save_dirpath):
FILE: chainer_chemistry/datasets/molnet/molnet.py
function get_molnet_dataset (line 25) | def get_molnet_dataset(dataset_name, preprocessor=None, labels=None,
function get_molnet_dataframe (line 166) | def get_molnet_dataframe(dataset_name, pdbbind_subset=None):
function get_molnet_filepath (line 205) | def get_molnet_filepath(dataset_name, filetype='onefile',
function _get_molnet_filepath (line 244) | def _get_molnet_filepath(file_name):
function download_dataset (line 260) | def download_dataset(dataset_url, save_filepath):
function get_pdbbind_smiles (line 279) | def get_pdbbind_smiles(pdbbind_subset, preprocessor=None, labels=None,
function get_pdbbind_grid (line 385) | def get_pdbbind_grid(pdbbind_subset, split=None, frac_train=.8, frac_val...
function get_grid_featurized_pdbbind_dataset (line 434) | def get_grid_featurized_pdbbind_dataset(subset):
function get_grid_featurized_pdbbind_dirpath (line 451) | def get_grid_featurized_pdbbind_dirpath(subset, download_if_not_exist=Tr...
function get_grid_featurized_pdbbind_filepath (line 482) | def get_grid_featurized_pdbbind_filepath(subset):
FILE: chainer_chemistry/datasets/molnet/molnet_config.py
function mae (line 16) | def mae(x, t):
function mse (line 20) | def mse(x, t):
function rmse (line 24) | def rmse(x, t):
function r2_score (line 28) | def r2_score(x, t):
FILE: chainer_chemistry/datasets/molnet/pdbbind_time.py
function get_pdbbind_time (line 10) | def get_pdbbind_time():
function get_pdbbind_time_filepath (line 24) | def get_pdbbind_time_filepath(download_if_not_exist=True):
function _get_pdbbind_time_filepath (line 50) | def _get_pdbbind_time_filepath(file_name):
function download_pdbbind_time (line 66) | def download_pdbbind_time(url, save_filepath):
FILE: chainer_chemistry/datasets/numpy_tuple_dataset.py
class NumpyTupleDataset (line 10) | class NumpyTupleDataset(object):
method __init__ (line 25) | def __init__(self, *datasets):
method __getitem__ (line 37) | def __getitem__(self, index):
method __len__ (line 46) | def __len__(self):
method get_datasets (line 49) | def get_datasets(self):
method converter (line 53) | def converter(self):
method features (line 57) | def features(self):
method save (line 78) | def save(cls, filepath, numpy_tuple_dataset):
method load (line 94) | def load(cls, filepath, allow_pickle=True):
FILE: chainer_chemistry/datasets/qm9.py
function get_qm9_label_names (line 26) | def get_qm9_label_names():
function get_qm9 (line 31) | def get_qm9(preprocessor=None, labels=None, return_smiles=False,
function get_qm9_filepath (line 71) | def get_qm9_filepath(download_if_not_exist=True):
function _get_qm9_filepath (line 94) | def _get_qm9_filepath():
function download_and_extract_qm9 (line 107) | def download_and_extract_qm9(save_filepath):
FILE: chainer_chemistry/datasets/reddit/reddit.py
function reddit_to_networkx (line 18) | def reddit_to_networkx(dirpath):
function get_reddit_dirpath (line 35) | def get_reddit_dirpath(download_if_not_exist=True):
function get_reddit_filepath (line 57) | def get_reddit_filepath(download_if_not_exist=True):
function _get_reddit_filepath (line 82) | def _get_reddit_filepath():
function download_and_extract_reddit (line 98) | def download_and_extract_reddit(save_dirpath):
FILE: chainer_chemistry/datasets/tox21.py
function get_tox21_label_names (line 38) | def get_tox21_label_names():
function get_tox21 (line 43) | def get_tox21(preprocessor=None, labels=None, return_smiles=False,
function _get_tox21_filepath (line 109) | def _get_tox21_filepath(dataset_type):
function get_tox21_filepath (line 136) | def get_tox21_filepath(dataset_type, download_if_not_exist=True):
function _download_and_extract_tox21 (line 165) | def _download_and_extract_tox21(config_name, save_filepath):
function download_and_extract_tox21 (line 183) | def download_and_extract_tox21():
FILE: chainer_chemistry/datasets/zinc.py
function get_zinc250k_label_names (line 20) | def get_zinc250k_label_names():
function get_zinc250k (line 25) | def get_zinc250k(preprocessor=None, labels=None, return_smiles=False,
function get_zinc250k_filepath (line 65) | def get_zinc250k_filepath(download_if_not_exist=True):
function _get_zinc250k_filepath (line 89) | def _get_zinc250k_filepath():
function _remove_new_line (line 102) | def _remove_new_line(s):
function download_and_extract_zinc250k (line 106) | def download_and_extract_zinc250k(save_filepath):
FILE: chainer_chemistry/functions/activation/megnet_softplus.py
function megnet_softplus (line 4) | def megnet_softplus(x):
FILE: chainer_chemistry/functions/activation/shifted_softplus.py
function shifted_softplus (line 5) | def shifted_softplus(x, beta=1, shift=0.5, threshold=20):
FILE: chainer_chemistry/functions/activation/softmax.py
function softmax (line 4) | def softmax(x, axis=1, mask=None, mask_value=1e10):
FILE: chainer_chemistry/functions/evaluation/r2_score.py
class R2Score (line 6) | class R2Score(function.Function):
method __init__ (line 8) | def __init__(self, sample_weight, multioutput, ignore_nan=False):
method check_type_forward (line 17) | def check_type_forward(self, in_types):
method forward (line 30) | def forward(self, inputs):
function r2_score (line 52) | def r2_score(pred, true, sample_weight=None, multioutput='uniform_average',
FILE: chainer_chemistry/functions/loss/mean_absolute_error.py
class MeanAbsoluteError (line 9) | class MeanAbsoluteError(function_node.FunctionNode):
method __init__ (line 13) | def __init__(self, ignore_nan=False):
method check_type_forward (line 17) | def check_type_forward(self, in_types):
method forward_cpu (line 25) | def forward_cpu(self, inputs):
method forward_gpu (line 34) | def forward_gpu(self, inputs):
method backward (line 42) | def backward(self, indexes, gy):
function mean_absolute_error (line 54) | def mean_absolute_error(x0, x1, ignore_nan=False):
FILE: chainer_chemistry/functions/loss/mean_squared_error.py
class MeanSquaredError (line 9) | class MeanSquaredError(function_node.FunctionNode):
method __init__ (line 13) | def __init__(self, ignore_nan=False):
method check_type_forward (line 17) | def check_type_forward(self, in_types):
method forward_cpu (line 25) | def forward_cpu(self, inputs):
method forward_gpu (line 33) | def forward_gpu(self, inputs):
method backward (line 42) | def backward(self, indexes, gy):
function mean_squared_error (line 59) | def mean_squared_error(x0, x1, ignore_nan=False):
FILE: chainer_chemistry/functions/math/matmul.py
function matmul (line 10) | def matmul(a, b, transa=False, transb=False):
FILE: chainer_chemistry/iterators/balanced_serial_iterator.py
class BalancedSerialIterator (line 11) | class BalancedSerialIterator(iterator.Iterator):
method __init__ (line 35) | def __init__(self, dataset, batch_size, labels, repeat=True, shuffle=T...
method __next__ (line 77) | def __next__(self):
method epoch_detail (line 111) | def epoch_detail(self):
method previous_epoch_detail (line 115) | def previous_epoch_detail(self):
method serialize (line 122) | def serialize(self, serializer):
method _update_order (line 136) | def _update_order(self):
method reset (line 155) | def reset(self):
method show_label_stats (line 164) | def show_label_stats(self):
FILE: chainer_chemistry/iterators/index_iterator.py
class IndexIterator (line 6) | class IndexIterator(iterator.Iterator):
method __init__ (line 20) | def __init__(self, index_list, shuffle=True, num=0):
method update_current_index_list (line 31) | def update_current_index_list(self):
method __next__ (line 37) | def __next__(self):
method get_next_indices (line 40) | def get_next_indices(self, num):
method serialize (line 80) | def serialize(self, serializer):
FILE: chainer_chemistry/link_hooks/variable_monitor_link_hook.py
function _default_extract_pre (line 8) | def _default_extract_pre(hook, args):
function _default_extract_post (line 20) | def _default_extract_post(hook, args):
class VariableMonitorLinkHook (line 32) | class VariableMonitorLinkHook(chainer.LinkHook):
method __init__ (line 87) | def __init__(self, target_link, name='VariableMonitorLinkHook',
method add_process (line 119) | def add_process(self, key, fn):
method delete_process (line 134) | def delete_process(self, key):
method get_variable (line 149) | def get_variable(self):
method forward_preprocess (line 156) | def forward_preprocess(self, args):
method forward_postprocess (line 163) | def forward_postprocess(self, args):
FILE: chainer_chemistry/links/array/shape_transformer_to_2d.py
class ShapeTransformerTo2D (line 5) | class ShapeTransformerTo2D(chainer.Link):
method __init__ (line 19) | def __init__(self, axis=1):
method transform (line 25) | def transform(self, x):
method inverse_transform (line 39) | def inverse_transform(self, x):
FILE: chainer_chemistry/links/connection/embed_atom_id.py
class EmbedAtomID (line 5) | class EmbedAtomID(chainer.links.EmbedID):
method __init__ (line 20) | def __init__(self, out_size, in_size=MAX_ATOMIC_NUM, initialW=None,
method __call__ (line 26) | def __call__(self, x):
FILE: chainer_chemistry/links/connection/graph_linear.py
class GraphLinear (line 4) | class GraphLinear(chainer.links.Linear):
method __call__ (line 14) | def __call__(self, x):
FILE: chainer_chemistry/links/connection/graph_mlp.py
class GraphMLP (line 9) | class GraphMLP(chainer.Chain):
method __init__ (line 21) | def __init__(self, channels, in_channels=None, activation=relu):
method __call__ (line 34) | def __call__(self, x):
FILE: chainer_chemistry/links/normalization/graph_batch_normalization.py
class GraphBatchNormalization (line 4) | class GraphBatchNormalization(chainer.links.BatchNormalization):
method __call__ (line 10) | def __call__(self, x):
FILE: chainer_chemistry/links/readout/cgcnn_readout.py
class CGCNNReadout (line 5) | class CGCNNReadout(chainer.Chain):
method __init__ (line 12) | def __init__(self, out_dim=128):
method __call__ (line 17) | def __call__(self, atom_feat, atom_idx):
FILE: chainer_chemistry/links/readout/general_readout.py
class GeneralReadout (line 5) | class GeneralReadout(chainer.Link):
method __init__ (line 19) | def __init__(self, mode='sum', activation=None, **kwargs):
method __call__ (line 24) | def __call__(self, h, axis=1, **kwargs):
class ScatterGeneralReadout (line 43) | class ScatterGeneralReadout(chainer.Link):
method __init__ (line 53) | def __init__(self, mode='sum', activation=None, **kwargs):
method __call__ (line 58) | def __call__(self, h, batch, **kwargs):
FILE: chainer_chemistry/links/readout/ggnn_readout.py
class GGNNReadout (line 7) | class GGNNReadout(chainer.Chain):
method __init__ (line 24) | def __init__(self, out_dim, in_channels=None, nobias=False,
method __call__ (line 37) | def __call__(self, h, h0=None, is_real_node=None):
FILE: chainer_chemistry/links/readout/megnet_readout.py
class MEGNetReadout (line 9) | class MEGNetReadout(chainer.Chain):
method __init__ (line 24) | def __init__(self, out_dim=32, in_channels=32, n_layers=1,
method __call__ (line 42) | def __call__(self, atoms_feat, pair_feat, global_feat):
FILE: chainer_chemistry/links/readout/mpnn_readout.py
class MPNNReadout (line 8) | class MPNNReadout(chainer.Chain):
method __init__ (line 19) | def __init__(self, out_dim, in_channels, n_layers=1, processing_steps=3):
method __call__ (line 34) | def __call__(self, h, **kwargs):
FILE: chainer_chemistry/links/readout/nfp_readout.py
class NFPReadout (line 7) | class NFPReadout(chainer.Chain):
method __init__ (line 17) | def __init__(self, out_dim, in_channels):
method __call__ (line 24) | def __call__(self, h, is_real_node=None, **kwargs):
FILE: chainer_chemistry/links/readout/scatter_ggnn_readout.py
class ScatterGGNNReadout (line 7) | class ScatterGGNNReadout(chainer.Chain):
method __init__ (line 26) | def __init__(self, out_dim, in_channels=None, nobias=False,
method __call__ (line 45) | def __call__(self, h, batch, h0=None, is_real_node=None):
FILE: chainer_chemistry/links/readout/schnet_readout.py
class SchNetReadout (line 8) | class SchNetReadout(chainer.Chain):
method __init__ (line 17) | def __init__(self, out_dim=1, in_channels=None,
method __call__ (line 26) | def __call__(self, h, **kwargs):
FILE: chainer_chemistry/links/readout/set2set.py
class Set2Set (line 10) | class Set2Set(chainer.Chain):
method __init__ (line 26) | def __init__(self, in_channels, n_layers=1):
method __call__ (line 41) | def __call__(self, h):
method reset_state (line 64) | def reset_state(self):
FILE: chainer_chemistry/links/scaler/base.py
function to_array (line 4) | def to_array(x):
class BaseScaler (line 11) | class BaseScaler(chainer.Link):
method fit (line 17) | def fit(self, x, **kwargs):
method transform (line 24) | def transform(self, x, **kwargs):
method inverse_transform (line 31) | def inverse_transform(self, x, **kwargs):
method fit_transform (line 38) | def fit_transform(self, x, **kwargs):
method forward (line 42) | def forward(self, x, **kwargs):
FILE: chainer_chemistry/links/scaler/flow_scaler.py
function _sigmoid_derivative (line 8) | def _sigmoid_derivative(x):
function format_x (line 13) | def format_x(x):
class FlowScaler (line 26) | class FlowScaler(BaseScaler):
method __init__ (line 41) | def __init__(self, hidden_num=20):
method _initialize_params (line 58) | def _initialize_params(self, in_size):
method W1 (line 65) | def W1(self):
method W2 (line 69) | def W2(self):
method _forward (line 72) | def _forward(self, x):
method _derivative (line 81) | def _derivative(self, x):
method _loss (line 91) | def _loss(self, x):
method fit (line 110) | def fit(self, x, batch_size=100, iteration=3000):
method transform (line 163) | def transform(self, x, batch_size=100):
FILE: chainer_chemistry/links/scaler/max_abs_scaler.py
function format_x (line 11) | def format_x(x):
class MaxAbsScaler (line 20) | class MaxAbsScaler(BaseScaler):
method __init__ (line 22) | def __init__(self):
method fit (line 29) | def fit(self, x, indices=None, axis=1):
method _compute_max_abs_all (line 67) | def _compute_max_abs_all(self, input_dim):
method transform (line 78) | def transform(self, x, axis=1):
method inverse_transform (line 93) | def inverse_transform(self, x, axis=1):
FILE: chainer_chemistry/links/scaler/min_max_scaler.py
function format_x (line 11) | def format_x(x):
class MinMaxScaler (line 20) | class MinMaxScaler(BaseScaler):
method __init__ (line 22) | def __init__(self):
method fit (line 31) | def fit(self, x, indices=None, axis=1):
method _compute_min_diff_all (line 70) | def _compute_min_diff_all(self, input_dim):
method transform (line 85) | def transform(self, x, axis=1):
method inverse_transform (line 100) | def inverse_transform(self, x, axis=1):
FILE: chainer_chemistry/links/scaler/standard_scaler.py
function format_x (line 11) | def format_x(x):
class StandardScaler (line 20) | class StandardScaler(BaseScaler):
method __init__ (line 22) | def __init__(self):
method fit (line 31) | def fit(self, x, indices=None, axis=1):
method _compute_mean_std_all (line 76) | def _compute_mean_std_all(self, input_dim):
method transform (line 89) | def transform(self, x, axis=1):
method inverse_transform (line 103) | def inverse_transform(self, x, axis=1):
FILE: chainer_chemistry/links/update/cgcnn_update.py
class CGCNNUpdate (line 5) | class CGCNNUpdate(chainer.Chain):
method __init__ (line 13) | def __init__(self, n_site_features=64):
method __call__ (line 20) | def __call__(self, site_feat, nbr_feat, nbr_feat_idx):
FILE: chainer_chemistry/links/update/ggnn_update.py
class GGNNUpdate (line 10) | class GGNNUpdate(chainer.Chain):
method __init__ (line 21) | def __init__(self, in_channels=None, hidden_channels=16,
method __call__ (line 39) | def __call__(self, h, adj, **kwargs):
method reset_state (line 76) | def reset_state(self):
FILE: chainer_chemistry/links/update/gin_update.py
class GINUpdate (line 8) | class GINUpdate(chainer.Chain):
method __init__ (line 32) | def __init__(self, in_channels=None, hidden_channels=16, out_channels=...
method __call__ (line 45) | def __call__(self, h, adj, **kwargs):
class GINSparseUpdate (line 92) | class GINSparseUpdate(chainer.Chain):
method __init__ (line 95) | def __init__(self, in_channels=None, hidden_channels=16, out_channels=...
method __call__ (line 110) | def __call__(self, h, edge_index):
FILE: chainer_chemistry/links/update/gnn_film_update.py
class GNNFiLMUpdate (line 8) | class GNNFiLMUpdate(chainer.Chain):
method __init__ (line 17) | def __init__(self, hidden_channels=16, n_edge_types=5,
method forward (line 31) | def forward(self, h, adj):
FILE: chainer_chemistry/links/update/megnet_update.py
class DenseLayer (line 8) | class DenseLayer(chainer.Chain):
method __init__ (line 9) | def __init__(self, hidden_dim=[64, 32], activation=megnet_softplus):
method __call__ (line 18) | def __call__(self, v):
class UpdateLayer (line 24) | class UpdateLayer(chainer.Chain):
method __init__ (line 25) | def __init__(self, hidden_dim=[64, 64, 32], activation=megnet_softplus):
method __call__ (line 34) | def __call__(self, v):
function get_mean_feat (line 43) | def get_mean_feat(feat, idx, out_shape, xp):
class MEGNetUpdate (line 56) | class MEGNetUpdate(chainer.Chain):
method __init__ (line 73) | def __init__(self, dim_for_dense=[64, 32], dim_for_update=[64, 64, 32],
method __call__ (line 95) | def __call__(self, atoms_feat, pair_feat, global_feat,
FILE: chainer_chemistry/links/update/mpnn_update.py
class MPNNUpdate (line 8) | class MPNNUpdate(chainer.Chain):
method __init__ (line 24) | def __init__(self, in_channels=None, hidden_channels=16, out_channels=...
method __call__ (line 40) | def __call__(self, h, adj, **kwargs):
method reset_state (line 50) | def reset_state(self):
class EdgeNet (line 54) | class EdgeNet(chainer.Chain):
method __init__ (line 66) | def __init__(self, out_channels, nn=None):
method __call__ (line 79) | def __call__(self, h, adj):
FILE: chainer_chemistry/links/update/nfp_update.py
class NFPUpdate (line 9) | class NFPUpdate(chainer.Chain):
method __init__ (line 18) | def __init__(self, in_channels, out_channels, max_degree=6,
method __call__ (line 30) | def __call__(self, h, adj, deg_conds):
FILE: chainer_chemistry/links/update/relgat_update.py
class RelGATUpdate (line 7) | class RelGATUpdate(chainer.Chain):
method __init__ (line 24) | def __init__(self, in_channels, out_channels, n_heads=3, n_edge_types=4,
method __call__ (line 42) | def __call__(self, h, adj, **kwargs):
FILE: chainer_chemistry/links/update/relgcn_update.py
class RelGCNUpdate (line 7) | class RelGCNUpdate(chainer.Chain):
method __init__ (line 16) | def __init__(self, in_channels, out_channels, n_edge_types=4,
method __call__ (line 27) | def __call__(self, h, adj, **kwargs):
class RelGCNSparseUpdate (line 57) | class RelGCNSparseUpdate(chainer.Chain):
method __init__ (line 60) | def __init__(self, in_channels, out_channels, n_edge_types):
method __call__ (line 69) | def __call__(self, h, edge_index, edge_attr):
FILE: chainer_chemistry/links/update/rsgcn_update.py
class RSGCNUpdate (line 7) | class RSGCNUpdate(chainer.Chain):
method __init__ (line 15) | def __init__(self, in_channels, out_channels, **kwargs):
method __call__ (line 23) | def __call__(self, h, adj, **kwargs):
FILE: chainer_chemistry/links/update/schnet_update.py
class CFConv (line 18) | class CFConv(chainer.Chain):
method __init__ (line 29) | def __init__(self, num_rbf=300, radius_resolution=0.1, gamma=10.0,
method __call__ (line 40) | def __call__(self, h, dist):
class SchNetUpdate (line 71) | class SchNetUpdate(chainer.Chain):
method __init__ (line 84) | def __init__(self, hidden_channels=64, num_rbf=300,
method __call__ (line 95) | def __call__(self, h, adj, **kwargs):
FILE: chainer_chemistry/models/cgcnn.py
class CGCNN (line 8) | class CGCNN(chainer.Chain):
method __init__ (line 22) | def __init__(self, out_dim=128, n_update_layers=3, n_atom_features=64):
method __call__ (line 31) | def __call__(self, atom_feat, nbr_feat, atom_idx, feat_idx):
FILE: chainer_chemistry/models/cwle/cwle_graph_conv_model.py
function to_array (line 17) | def to_array(x):
class CWLEGraphConvModel (line 24) | class CWLEGraphConvModel(chainer.Chain):
method __init__ (line 56) | def __init__(self, hidden_channels, out_dim, update_layer, readout_layer,
method __call__ (line 164) | def __call__(self, atom_array, adj, wle_array=None, is_real_node=None):
method reset_state (line 219) | def reset_state(self):
method preprocess_addtional_kwargs (line 224) | def preprocess_addtional_kwargs(self, *args, **kwargs):
FILE: chainer_chemistry/models/cwle/cwle_net.py
class GGNN_CWLE (line 18) | class GGNN_CWLE(CWLEGraphConvModel):
method __init__ (line 19) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
class RelGCN_CWLE (line 35) | class RelGCN_CWLE(CWLEGraphConvModel):
method __init__ (line 36) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
class RelGAT_CWLE (line 52) | class RelGAT_CWLE(CWLEGraphConvModel):
method __init__ (line 53) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
class GIN_CWLE (line 69) | class GIN_CWLE(CWLEGraphConvModel):
method __init__ (line 70) | def __init__(self, out_dim, hidden_channels=16,
class NFP_CWLE (line 88) | class NFP_CWLE(CWLEGraphConvModel):
method __init__ (line 89) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
method preprocess_addtional_kwargs (line 104) | def preprocess_addtional_kwargs(self, *args, **kwargs):
class RSGCN_CWLE (line 123) | class RSGCN_CWLE(CWLEGraphConvModel):
method __init__ (line 124) | def __init__(self, out_dim, hidden_channels=32, n_update_layers=4,
FILE: chainer_chemistry/models/ggnn.py
class GGNN (line 11) | class GGNN(chainer.Chain):
method __init__ (line 31) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
method __call__ (line 58) | def __call__(self, atom_array, adj, is_real_node=None):
method reset_state (line 95) | def reset_state(self):
class SparseGGNN (line 99) | class SparseGGNN(GGNN):
method __init__ (line 106) | def __init__(self, *args, **kwargs):
method __call__ (line 109) | def __call__(self, atom_array, data, row, col, edge_type,
FILE: chainer_chemistry/models/gin.py
class GIN (line 11) | class GIN(chainer.Chain):
method __init__ (line 33) | def __init__(self, out_dim, node_embedding=False, hidden_channels=16,
method __call__ (line 77) | def __call__(self, atom_array, adj, is_real_node=None):
class GINSparse (line 122) | class GINSparse(chainer.Chain):
method __init__ (line 125) | def __init__(self, out_dim, node_embedding=False, hidden_channels=16,
method __call__ (line 168) | def __call__(self, sparse_batch, is_real_node=None):
FILE: chainer_chemistry/models/gnn_film.py
class GNNFiLM (line 11) | class GNNFiLM(chainer.Chain):
method __init__ (line 34) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
method __call__ (line 65) | def __call__(self, atom_array, adj, is_real_node=None):
method reset_state (line 103) | def reset_state(self):
FILE: chainer_chemistry/models/gwle/gwle_graph_conv_model.py
function to_array (line 17) | def to_array(x):
class GWLEGraphConvModel (line 24) | class GWLEGraphConvModel(chainer.Chain):
method __init__ (line 56) | def __init__(self, hidden_channels, out_dim, update_layer, readout_layer,
method __call__ (line 166) | def __call__(self, atom_array, adj, wle_array=None, is_real_node=None):
method reset_state (line 224) | def reset_state(self):
method preprocess_addtional_kwargs (line 229) | def preprocess_addtional_kwargs(self, *args, **kwargs):
FILE: chainer_chemistry/models/gwle/gwle_net.py
class GGNN_GWLE (line 18) | class GGNN_GWLE(GWLEGraphConvModel):
method __init__ (line 19) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
class RelGCN_GWLE (line 35) | class RelGCN_GWLE(GWLEGraphConvModel):
method __init__ (line 36) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
class RelGAT_GWLE (line 52) | class RelGAT_GWLE(GWLEGraphConvModel):
method __init__ (line 53) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
class GIN_GWLE (line 69) | class GIN_GWLE(GWLEGraphConvModel):
method __init__ (line 70) | def __init__(self, out_dim, hidden_channels=16,
class NFP_GWLE (line 88) | class NFP_GWLE(GWLEGraphConvModel):
method __init__ (line 89) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
method preprocess_addtional_kwargs (line 104) | def preprocess_addtional_kwargs(self, *args, **kwargs):
class RSGCN_GWLE (line 123) | class RSGCN_GWLE(GWLEGraphConvModel):
method __init__ (line 124) | def __init__(self, out_dim, hidden_channels=32, n_update_layers=4,
FILE: chainer_chemistry/models/gwm/gwm.py
class WarpGateUnit (line 8) | class WarpGateUnit(chainer.Chain):
method __init__ (line 24) | def __init__(self, output_type='graph', hidden_dim=16,
method __call__ (line 45) | def __call__(self, h, g):
class SuperNodeTransmitterUnit (line 57) | class SuperNodeTransmitterUnit(chainer.Chain):
method __init__ (line 68) | def __init__(self, hidden_dim_super=16, hidden_dim=16, dropout_ratio=-1):
method __call__ (line 77) | def __call__(self, g, n_nodes):
class GraphTransmitterUnit (line 100) | class GraphTransmitterUnit(chainer.Chain):
method __init__ (line 112) | def __init__(self, hidden_dim_super=16, hidden_dim=16, n_heads=8,
method __call__ (line 126) | def __call__(self, h, g, step=0):
class GWM (line 185) | class GWM(chainer.Chain):
method __init__ (line 206) | def __init__(self, hidden_dim=16, hidden_dim_super=16, n_layers=4,
method __call__ (line 259) | def __call__(self, h, h_new, g, step=0):
method reset_state (line 300) | def reset_state(self):
FILE: chainer_chemistry/models/gwm/gwm_graph_conv_model.py
function to_array (line 14) | def to_array(x):
class GWMGraphConvModel (line 21) | class GWMGraphConvModel(chainer.Chain):
method __init__ (line 52) | def __init__(self, hidden_channels, out_dim, update_layer, readout_layer,
method __call__ (line 165) | def __call__(self, atom_array, adj, super_node=None, is_real_node=None):
method reset_state (line 221) | def reset_state(self):
method preprocess_addtional_kwargs (line 228) | def preprocess_addtional_kwargs(self, *args, **kwargs):
FILE: chainer_chemistry/models/gwm/gwm_net.py
class GGNN_GWM (line 11) | class GGNN_GWM(GWMGraphConvModel):
method __init__ (line 12) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
class GIN_GWM (line 27) | class GIN_GWM(GWMGraphConvModel):
method __init__ (line 28) | def __init__(self, out_dim, hidden_channels=16,
class NFP_GWM (line 46) | class NFP_GWM(GWMGraphConvModel):
method __init__ (line 47) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
method preprocess_addtional_kwargs (line 62) | def preprocess_addtional_kwargs(self, *args, **kwargs):
class RSGCN_GWM (line 81) | class RSGCN_GWM(GWMGraphConvModel):
method __init__ (line 82) | def __init__(self, out_dim, hidden_channels=32, n_update_layers=4,
FILE: chainer_chemistry/models/megnet.py
function reshaped_feat (line 10) | def reshaped_feat(feat, idx):
class MEGNet (line 23) | class MEGNet(chainer.Chain):
method __init__ (line 40) | def __init__(self, out_dim=32, n_update_layers=3, dropout_ratio=-1,
method __call__ (line 60) | def __call__(self, atoms_feat, pair_feat, global_feat, *args):
FILE: chainer_chemistry/models/mlp.py
class MLP (line 6) | class MLP(chainer.Chain):
method __init__ (line 18) | def __init__(self, out_dim, hidden_dim=16, n_layers=2, activation=relu):
method __call__ (line 29) | def __call__(self, x):
FILE: chainer_chemistry/models/mpnn.py
class MPNN (line 15) | class MPNN(chainer.Chain):
method __init__ (line 36) | def __init__(
method __call__ (line 99) | def __call__(self, atom_array, adj):
method reset_state (line 141) | def reset_state(self):
FILE: chainer_chemistry/models/nfp.py
class NFP (line 10) | class NFP(chainer.Chain):
method __init__ (line 28) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
method __call__ (line 50) | def __call__(self, atom_array, adj, is_real_node=None):
FILE: chainer_chemistry/models/prediction/base.py
function _to_tuple (line 13) | def _to_tuple(x):
function _extract_numpy (line 19) | def _extract_numpy(x):
class BaseForwardModel (line 25) | class BaseForwardModel(link.Chain):
method __init__ (line 32) | def __init__(self):
method initialize (line 37) | def initialize(self, device=-1):
method update_device (line 51) | def update_device(self, device=-1):
method _forward (line 62) | def _forward(self, data, fn, batchsize=16,
method save_pickle (line 126) | def save_pickle(self, filepath, protocol=None):
method load_pickle (line 181) | def load_pickle(filepath, device=-1):
FILE: chainer_chemistry/models/prediction/classifier.py
function _argmax (line 14) | def _argmax(*args):
class Classifier (line 19) | class Classifier(BaseForwardModel):
method __init__ (line 79) | def __init__(self, predictor,
method _convert_to_scalar (line 116) | def _convert_to_scalar(self, value):
method __call__ (line 129) | def __call__(self, *args, **kwargs):
method predict_proba (line 186) | def predict_proba(
method predict (line 220) | def predict(
method compute_accuracy (line 252) | def compute_accuracy(self):
method compute_accuracy (line 258) | def compute_accuracy(self, value):
method accuracy (line 264) | def accuracy(self):
method accuracy (line 270) | def accuracy(self, value):
method accfun (line 276) | def accfun(self):
method accfun (line 282) | def accfun(self, value):
FILE: chainer_chemistry/models/prediction/graph_conv_predictor.py
class GraphConvPredictor (line 7) | class GraphConvPredictor(chainer.Chain):
method __init__ (line 10) | def __init__(
method __call__ (line 44) | def __call__(self, *args, **kwargs):
method predict (line 52) | def predict(self, atoms, adjs):
FILE: chainer_chemistry/models/prediction/node_classifier.py
class NodeClassifier (line 5) | class NodeClassifier(Classifier):
method __call__ (line 8) | def __call__(self, data, train_mask, valid_mask, *args, **kwargs):
FILE: chainer_chemistry/models/prediction/regressor.py
class Regressor (line 12) | class Regressor(BaseForwardModel):
method __init__ (line 42) | def __init__(self, predictor,
method _convert_to_scalar (line 72) | def _convert_to_scalar(self, value):
method __call__ (line 85) | def __call__(self, *args, **kwargs):
method predict (line 152) | def predict(
FILE: chainer_chemistry/models/prediction/set_up_predictor.py
function set_up_predictor (line 45) | def set_up_predictor(
FILE: chainer_chemistry/models/relgat.py
class RelGAT (line 11) | class RelGAT(chainer.Chain):
method __init__ (line 44) | def __init__(self, out_dim, hidden_channels=16, n_update_layers=4,
method __call__ (line 90) | def __call__(self, atom_array, adj):
FILE: chainer_chemistry/models/relgcn.py
function rescale_adj (line 12) | def rescale_adj(adj):
class RelGCN (line 35) | class RelGCN(chainer.Chain):
method __init__ (line 56) | def __init__(self, out_dim=64, hidden_channels=None, n_update_layers=N...
method __call__ (line 87) | def __call__(self, x, adj):
class RelGCNSparse (line 109) | class RelGCNSparse(chainer.Chain):
method __init__ (line 130) | def __init__(self, out_dim=64, hidden_channels=None, n_update_layers=N...
method __call__ (line 161) | def __call__(self, sparse_batch):
FILE: chainer_chemistry/models/rsgcn.py
class RSGCN (line 10) | class RSGCN(chainer.Chain):
method __init__ (line 40) | def __init__(self, out_dim, hidden_channels=32, n_update_layers=4,
method __call__ (line 70) | def __call__(self, atom_array, adj, **kwargs):
FILE: chainer_chemistry/models/schnet.py
class SchNet (line 10) | class SchNet(chainer.Chain):
method __init__ (line 34) | def __init__(self, out_dim=1, hidden_channels=64, n_update_layers=3,
method __call__ (line 55) | def __call__(self, atom_features, dist_features):
FILE: chainer_chemistry/models/weavenet.py
class LinearLayer (line 14) | class LinearLayer(chainer.Chain):
method __init__ (line 16) | def __init__(self, n_channel, n_layer):
method forward (line 24) | def forward(self, x):
class AtomToPair (line 34) | class AtomToPair(chainer.Chain):
method __init__ (line 35) | def __init__(self, n_channel, n_layer, n_atom):
method forward (line 44) | def forward(self, x):
class PairToAtom (line 78) | class PairToAtom(chainer.Chain):
method __init__ (line 79) | def __init__(self, n_channel, n_layer, n_atom, mode='sum'):
method forward (line 90) | def forward(self, x):
class WeaveModule (line 103) | class WeaveModule(chainer.Chain):
method __init__ (line 105) | def __init__(self, n_atom, output_channel, n_sub_layer,
method forward (line 120) | def forward(self, atom_x, pair_x, atom_only=False):
class WeaveNet (line 137) | class WeaveNet(chainer.Chain):
method __init__ (line 151) | def __init__(self, weave_channels=None, hidden_dim=16,
method __call__ (line 168) | def __call__(self, atom_x, pair_x, train=True):
FILE: chainer_chemistry/saliency/calculator/base_calculator.py
function _to_tuple (line 20) | def _to_tuple(x):
function _to_variable (line 26) | def _to_variable(x):
function _extract_numpy (line 32) | def _extract_numpy(x):
function _concat (line 38) | def _concat(batch_list):
function add_linkhook (line 49) | def add_linkhook(linkhook, prefix='', logger=None):
function delete_linkhook (line 62) | def delete_linkhook(linkhook, prefix='', logger=None):
class BaseCalculator (line 73) | class BaseCalculator(object):
method __init__ (line 104) | def __init__(self, model, target_extractor=None, output_extractor=None,
method compute (line 115) | def compute(self, data, M=1, batchsize=16,
method aggregate (line 157) | def aggregate(self, saliency_arrays, method='raw', ch_axis=None):
method _compute_core (line 188) | def _compute_core(self, *inputs):
method get_target_var (line 195) | def get_target_var(self, inputs):
method get_output_var (line 211) | def get_output_var(self, outputs):
method _forward (line 223) | def _forward(self, data, batchsize=16,
FILE: chainer_chemistry/saliency/calculator/calculator_utils.py
class GaussianNoiseSampler (line 4) | class GaussianNoiseSampler(object):
method __init__ (line 7) | def __init__(self, mode='relative', scale=0.15):
method sample (line 11) | def sample(self, target_array):
FILE: chainer_chemistry/saliency/calculator/gradient_calculator.py
class GradientCalculator (line 6) | class GradientCalculator(BaseCalculator):
method __init__ (line 37) | def __init__(self, model, target_extractor=None, output_extractor=None,
method _compute_core (line 45) | def _compute_core(self, *inputs):
FILE: chainer_chemistry/saliency/calculator/integrated_gradients_calculator.py
class IntegratedGradientsCalculator (line 6) | class IntegratedGradientsCalculator(GradientCalculator):
method __init__ (line 32) | def __init__(self, model, target_extractor=None, output_extractor=None,
method _compute_core (line 42) | def _compute_core(self, *inputs):
FILE: chainer_chemistry/saliency/calculator/occlusion_calculator.py
function _to_tuple (line 10) | def _to_tuple(x):
class OcclusionCalculator (line 20) | class OcclusionCalculator(BaseCalculator):
method __init__ (line 48) | def __init__(self, model, target_extractor=None, output_extractor=None,
method _compute_core (line 63) | def _compute_core(self, *inputs):
FILE: chainer_chemistry/saliency/visualizer/base_visualizer.py
class BaseVisualizer (line 1) | class BaseVisualizer(object):
method visualize (line 5) | def visualize(self, *args, **kwargs):
FILE: chainer_chemistry/saliency/visualizer/image_visualizer.py
class ImageVisualizer (line 13) | class ImageVisualizer(BaseVisualizer):
method __init__ (line 21) | def __init__(self, logger=None):
method visualize (line 24) | def visualize(self, saliency, image=None, save_filepath=None,
FILE: chainer_chemistry/saliency/visualizer/mol_visualizer.py
function _convert_to_2d (line 14) | def _convert_to_2d(axes, nrows, ncols):
function is_visible (line 27) | def is_visible(begin, end):
class MolVisualizer (line 36) | class MolVisualizer(BaseVisualizer):
method __init__ (line 44) | def __init__(self, logger=None):
method visualize (line 47) | def visualize(self, saliency, mol, save_filepath=None,
class SmilesVisualizer (line 151) | class SmilesVisualizer(MolVisualizer):
method visualize (line 153) | def visualize(self, saliency, smiles, save_filepath=None,
FILE: chainer_chemistry/saliency/visualizer/table_visualizer.py
class TableVisualizer (line 8) | class TableVisualizer(BaseVisualizer):
method visualize (line 12) | def visualize(self, saliency, feature_names=None, save_filepath=None,
FILE: chainer_chemistry/saliency/visualizer/visualizer_utils.py
function red_blue_cmap (line 7) | def red_blue_cmap(x):
function min_max_scaler (line 26) | def min_max_scaler(saliency, logger=None):
function abs_max_scaler (line 48) | def abs_max_scaler(saliency, logger=None):
function normalize_scaler (line 68) | def normalize_scaler(saliency, axis=None, logger=None):
FILE: chainer_chemistry/training/extensions/auto_print_report.py
function create_header_and_templates (line 10) | def create_header_and_templates(entries):
function filter_and_sort_entries (line 22) | def filter_and_sort_entries(all_entries, unit='epoch'):
class AutoPrintReport (line 43) | class AutoPrintReport(extension.Extension):
method __init__ (line 59) | def __init__(self, log_report='LogReport', out=sys.stdout):
method get_log_report (line 71) | def get_log_report(self, trainer):
method __call__ (line 82) | def __call__(self, trainer):
method serialize (line 125) | def serialize(self, serializer):
method _print (line 130) | def _print(self, observation):
FILE: chainer_chemistry/training/extensions/batch_evaluator.py
function _get_1d_numpy_array (line 13) | def _get_1d_numpy_array(v):
class BatchEvaluator (line 28) | class BatchEvaluator(Evaluator):
method __init__ (line 30) | def __init__(self, iterator, target, converter=convert.concat_examples,
method evaluate (line 48) | def evaluate(self):
FILE: chainer_chemistry/training/extensions/prc_auc_evaluator.py
function _to_list (line 9) | def _to_list(a):
class PRCAUCEvaluator (line 25) | class PRCAUCEvaluator(BatchEvaluator):
method __init__ (line 72) | def __init__(self, iterator, target, converter=convert.concat_examples,
method prc_auc_score (line 86) | def prc_auc_score(self, y_total, t_total):
FILE: chainer_chemistry/training/extensions/r2_score_evaluator.py
class R2ScoreEvaluator (line 7) | class R2ScoreEvaluator(BatchEvaluator):
method __init__ (line 60) | def __init__(self, iterator, target, converter=convert.concat_examples,
method r2_score (line 78) | def r2_score(self, pred, true, sample_weight=None,
FILE: chainer_chemistry/training/extensions/roc_auc_evaluator.py
function _to_list (line 9) | def _to_list(a):
class ROCAUCEvaluator (line 25) | class ROCAUCEvaluator(BatchEvaluator):
method __init__ (line 72) | def __init__(self, iterator, target, converter=convert.concat_examples,
method roc_auc_score (line 86) | def roc_auc_score(self, y_total, t_total):
FILE: chainer_chemistry/utils/extend.py
function _to_list (line 8) | def _to_list(a):
function extend_node (line 16) | def extend_node(node, out_size, axis=-1, value=0):
function extend_adj (line 38) | def extend_adj(adj, out_size, axis=None, value=0):
function extend_arrays_to_size (line 61) | def extend_arrays_to_size(arrays, out_size, axis=-1, value=0):
function extend_arrays_to_shape (line 94) | def extend_arrays_to_shape(arrays, out_shape, value=0):
FILE: chainer_chemistry/utils/json_utils.py
class JSONEncoderEX (line 13) | class JSONEncoderEX(json.JSONEncoder):
method default (line 16) | def default(self, obj):
function save_json (line 33) | def save_json(filepath, params, ignore_error=False, indent=4, logger=None):
function load_json (line 62) | def load_json(filepath):
FILE: chainer_chemistry/utils/permutation.py
function permute_node (line 4) | def permute_node(node, permutation_index, axis=-1):
function permute_adj (line 24) | def permute_adj(adj, permutation_index, axis=None):
FILE: chainer_chemistry/utils/sparse_utils.py
function _flatten (line 12) | def _flatten(x):
function sparse_utils_available (line 19) | def sparse_utils_available():
function is_sparse (line 25) | def is_sparse(x):
function convert_sparse_with_edge_type (line 32) | def convert_sparse_with_edge_type(data, row, col, num_nodes,
function _convert_to_sparse (line 104) | def _convert_to_sparse(dense_adj):
FILE: chainer_chemistry/utils/train_utils.py
function run_train (line 11) | def run_train(model, train, valid=None,
function run_node_classification_train (line 88) | def run_node_classification_train(model, data,
FILE: docs/source/_autosummary_check.py
function _is_rst_exists (line 10) | def _is_rst_exists(entity):
function check (line 14) | def check(app, exception):
function _list_chainer_functions (line 36) | def _list_chainer_functions():
function _list_chainer_links (line 43) | def _list_chainer_links():
function _list_chainer_models (line 50) | def _list_chainer_models():
FILE: docs/source/conf.py
function setup (line 189) | def setup(app):
function _build_finished (line 192) | def _build_finished(app, exception):
FILE: examples/molnet/predict_molnet.py
function parse_arguments (line 30) | def parse_arguments():
function main (line 63) | def main():
FILE: examples/molnet/summary_eval_molnet.py
function save_evaluation_plot (line 17) | def save_evaluation_plot(x, y_mean, metric, dataset_name, filename):
function main (line 38) | def main():
FILE: examples/molnet/train_molnet.py
function parse_arguments (line 29) | def parse_arguments():
function dataset_part_filename (line 71) | def dataset_part_filename(dataset_part, num_data):
function download_entire_dataset (line 84) | def download_entire_dataset(dataset_name, num_data, labels, method, cach...
function fit_scaler (line 116) | def fit_scaler(datasets):
function main (line 140) | def main():
FILE: examples/molnet_wle/predict_molnet_wle.py
function parse_arguments (line 33) | def parse_arguments():
function main (line 69) | def main():
FILE: examples/molnet_wle/train_molnet_wle.py
function dict_for_wles (line 33) | def dict_for_wles():
function parse_arguments (line 65) | def parse_arguments():
function dataset_part_filename (line 116) | def dataset_part_filename(dataset_part, num_data):
function download_entire_dataset (line 129) | def download_entire_dataset(dataset_name, num_data, labels, method, cach...
function fit_scaler (line 252) | def fit_scaler(datasets):
function main (line 276) | def main():
FILE: examples/network_graph/padding_model_wrapper.py
class PaddingModelWrapper (line 5) | class PaddingModelWrapper(chainer.Chain):
method __init__ (line 6) | def __init__(self, predictor):
method forward (line 11) | def forward(self, data):
FILE: examples/network_graph/train_network_graph.py
function get_cora (line 21) | def get_cora():
function get_citeseer (line 25) | def get_citeseer():
function get_reddit (line 29) | def get_reddit():
function parse_arguments (line 48) | def parse_arguments():
function generate_random_mask (line 84) | def generate_random_mask(n, train_num, seed=777):
FILE: examples/own_dataset/plot.py
function save_evaluation_plot (line 10) | def save_evaluation_plot(x, y, metric, filename):
function main (line 31) | def main():
FILE: examples/own_dataset/predict_own_dataset.py
function parse_arguments (line 26) | def parse_arguments():
function main (line 68) | def main():
FILE: examples/own_dataset/train_own_dataset.py
function rmse (line 23) | def rmse(x0, x1):
function parse_arguments (line 27) | def parse_arguments():
function main (line 71) | def main():
FILE: examples/qm9/plot.py
function save_evaluation_plot (line 12) | def save_evaluation_plot(x, y, metric, filename):
function main (line 34) | def main():
FILE: examples/qm9/predict_qm9.py
function parse_arguments (line 28) | def parse_arguments():
function main (line 66) | def main():
FILE: examples/qm9/train_qm9.py
function rmse (line 23) | def rmse(x0, x1):
function parse_arguments (line 27) | def parse_arguments():
function main (line 75) | def main():
FILE: examples/tox21/data.py
class _CacheNamePolicy (line 10) | class _CacheNamePolicy(object):
method _get_cache_directory_path (line 16) | def _get_cache_directory_path(self, method, labels, prefix, num_data):
method __init__ (line 25) | def __init__(self, method, labels, prefix='input', num_data=-1):
method get_train_file_path (line 33) | def get_train_file_path(self):
method get_val_file_path (line 36) | def get_val_file_path(self):
method get_test_file_path (line 39) | def get_test_file_path(self):
method create_cache_directory (line 42) | def create_cache_directory(self):
function load_dataset (line 50) | def load_dataset(method, labels, prefix='input', num_data=-1):
FILE: examples/tox21/predict_tox21_with_classifier.py
function main (line 28) | def main():
FILE: examples/tox21/train_tox21.py
function main (line 33) | def main():
FILE: tests/dataset_tests/parsers_tests/test_csv_file_parser.py
function mol_smiles (line 14) | def mol_smiles():
function mols (line 22) | def mols(mol_smiles):
function label_a (line 27) | def label_a():
function csv_file (line 32) | def csv_file(tmpdir, mol_smiles, label_a):
function csv_file_invalid (line 43) | def csv_file_invalid(tmpdir):
function check_input_features (line 54) | def check_input_features(actual, expect):
function check_features (line 60) | def check_features(actual, expect_input_features, expect_label):
function test_csv_file_parser_not_return_smiles (line 69) | def test_csv_file_parser_not_return_smiles(csv_file, mols):
function test_csv_file_parser_return_smiles (line 88) | def test_csv_file_parser_return_smiles(csv_file, mols, label_a):
function test_csv_file_parser_target_index (line 112) | def test_csv_file_parser_target_index(csv_file_invalid, mols, label_a):
function test_csv_file_parser_extract_total_num (line 141) | def test_csv_file_parser_extract_total_num(csv_file):
function test_csv_parser_return_is_successful (line 148) | def test_csv_parser_return_is_successful(csv_file_invalid, mols, label_a):
FILE: tests/dataset_tests/parsers_tests/test_data_frame_parser.py
function mol_smiles (line 12) | def mol_smiles():
function mols (line 20) | def mols(mol_smiles):
function label_a (line 25) | def label_a():
function data_frame (line 30) | def data_frame(mol_smiles, label_a):
function check_input_features (line 38) | def check_input_features(actual, expect):
function check_features (line 44) | def check_features(actual, expect_input_features, expect_label):
function test_data_frame_parser_not_return_smiles (line 53) | def test_data_frame_parser_not_return_smiles(data_frame, mols):
function test_data_frame_parser_return_smiles (line 73) | def test_data_frame_parser_return_smiles(data_frame, mols, label_a):
function test_data_frame_parser_target_index (line 97) | def test_data_frame_parser_target_index(data_frame, mols, label_a):
function test_data_frame_parser_return_is_successful (line 126) | def test_data_frame_parser_return_is_successful(mols, label_a):
function test_data_frame_parser_extract_total_num (line 152) | def test_data_frame_parser_extract_total_num(data_frame):
FILE: tests/dataset_tests/parsers_tests/test_sdf_file_parser.py
function mols (line 13) | def mols():
function sdf_file (line 21) | def sdf_file(tmpdir, mols):
function sdf_file_long (line 31) | def sdf_file_long(tmpdir):
function check_input_features (line 42) | def check_input_features(actual, expect):
function test_sdf_file_parser_not_return_smiles (line 48) | def test_sdf_file_parser_not_return_smiles(sdf_file, mols):
function test_sdf_file_parser_return_smiles (line 66) | def test_sdf_file_parser_return_smiles(sdf_file, mols):
function test_sdf_file_parser_target_index (line 89) | def test_sdf_file_parser_target_index(sdf_file, mols):
function test_sdf_file_parser_return_is_successful (line 117) | def test_sdf_file_parser_return_is_successful(sdf_file_long, mols):
function test_sdf_file_parser_extract_total_num (line 138) | def test_sdf_file_parser_extract_total_num(sdf_file):
FILE: tests/dataset_tests/parsers_tests/test_smiles_parser.py
function mol_smiles (line 11) | def mol_smiles():
function mols (line 19) | def mols(mol_smiles):
function check_input_features (line 23) | def check_input_features(actual, expect):
function test_smiles_parser_not_return_smiles (line 29) | def test_smiles_parser_not_return_smiles(mol_smiles, mols):
function test_smiles_parser_return_smiles (line 47) | def test_smiles_parser_return_smiles(mol_smiles, mols):
function test_smiles_parser_target_index (line 71) | def test_smiles_parser_target_index(mol_smiles, mols):
function test_smiles_parser_return_is_successful (line 100) | def test_smiles_parser_return_is_successful(mols):
function test_smiles_parser_extract_total_num (line 122) | def test_smiles_parser_extract_total_num(mol_smiles):
FILE: tests/dataset_tests/preprocessor_tests/test_common.py
function sample_molecule (line 11) | def sample_molecule():
function sample_molecule_2 (line 16) | def sample_molecule_2():
class TestGetAtomicNumbers (line 20) | class TestGetAtomicNumbers(object):
method test_normal (line 22) | def test_normal(self, sample_molecule):
method test_padding (line 29) | def test_padding(self, sample_molecule):
method test_normal_truncated (line 36) | def test_normal_truncated(self, sample_molecule):
class TestGetAdjMatrix (line 41) | class TestGetAdjMatrix(object):
method test_normal (line 43) | def test_normal(self, sample_molecule_2):
method test_normal_no_self_connection (line 58) | def test_normal_no_self_connection(self, sample_molecule_2):
method test_normal_padding (line 74) | def test_normal_padding(self, sample_molecule_2):
method test_normal_truncated (line 90) | def test_normal_truncated(self, sample_molecule_2):
class TestConstructDiscreteEdgeMatrix (line 95) | class TestConstructDiscreteEdgeMatrix(object):
method test_default (line 127) | def test_default(self, sample_molecule_2):
method test_add_self_connection_channel (line 132) | def test_add_self_connection_channel(self, sample_molecule_2):
method test_padding (line 139) | def test_padding(self, sample_molecule_2):
method test_truncated (line 146) | def test_truncated(self, sample_molecule_2):
function test_construct_super_node_feature_adj_ndim2 (line 151) | def test_construct_super_node_feature_adj_ndim2(sample_molecule):
function test_construct_super_node_feature_adj_ndim3 (line 171) | def test_construct_super_node_feature_adj_ndim3(sample_molecule):
FILE: tests/dataset_tests/preprocessors_tests/test_atomic_number_preprocessor.py
function mol (line 11) | def mol():
function test_atomic_number_default_preprocessor (line 16) | def test_atomic_number_default_preprocessor(mol):
function test_atomic_number_non_default_padding_preprocessor (line 23) | def test_atomic_number_non_default_padding_preprocessor(mol):
function test_atomic_number_non_default_max_atoms_preprocessor (line 31) | def test_atomic_number_non_default_max_atoms_preprocessor(mol):
function test_atomic_number_preprocessor (line 43) | def test_atomic_number_preprocessor(mol):
function test_atomic_number_preprocessor_default (line 51) | def test_atomic_number_preprocessor_default():
function test_atomic_number_preprocessor_assert_raises (line 62) | def test_atomic_number_preprocessor_assert_raises():
FILE: tests/dataset_tests/preprocessors_tests/test_cgcnn_preprocessor.py
function test_cgcnn_preprocessor_init (line 6) | def test_cgcnn_preprocessor_init():
FILE: tests/dataset_tests/preprocessors_tests/test_gat_preprocessor.py
function test_gat_preprocessor (line 10) | def test_gat_preprocessor():
function test_gat_preprocessor_assert_raises (line 31) | def test_gat_preprocessor_assert_raises():
FILE: tests/dataset_tests/preprocessors_tests/test_ggnn_preprocessor.py
function test_ggnn_preprocessor (line 8) | def test_ggnn_preprocessor():
function test_ggnn_preprocessor_kekulize (line 79) | def test_ggnn_preprocessor_kekulize():
function test_ggnn_preprocessor_assert_raises (line 128) | def test_ggnn_preprocessor_assert_raises():
FILE: tests/dataset_tests/preprocessors_tests/test_gwm_preprocessor.py
function mol (line 10) | def mol():
function test_gwm_preprocessor (line 18) | def test_gwm_preprocessor(mol, pp_type):
FILE: tests/dataset_tests/preprocessors_tests/test_mol_preprocessor.py
function mol (line 8) | def mol():
function pp (line 16) | def pp():
class TestGetLabel (line 20) | class TestGetLabel(object):
method test_default (line 22) | def test_default(self, mol, pp):
method test_empty (line 26) | def test_empty(self, mol, pp):
method test_one_label (line 30) | def test_one_label(self, mol, pp):
method test_two_labels (line 34) | def test_two_labels(self, mol, pp):
method test_non_existent_label (line 38) | def test_non_existent_label(self, mol, pp):
FILE: tests/dataset_tests/preprocessors_tests/test_nfp_preprocessor.py
function mol (line 10) | def mol():
function pp (line 16) | def pp():
function test_nfp_preprocessor (line 20) | def test_nfp_preprocessor(mol, pp):
function test_nfp_preprocessor_default (line 35) | def test_nfp_preprocessor_default():
function test_nfp_preprocessor_assert_raises (line 51) | def test_nfp_preprocessor_assert_raises():
FILE: tests/dataset_tests/preprocessors_tests/test_relgcn_preprocessor.py
function test_relgcn_preprocessor (line 8) | def test_relgcn_preprocessor():
function test_relgcn_preprocessor_kekulize (line 79) | def test_relgcn_preprocessor_kekulize():
function test_relgcn_preprocessor_assert_raises (line 128) | def test_relgcn_preprocessor_assert_raises():
FILE: tests/dataset_tests/preprocessors_tests/test_rsgcn_preprocessor.py
function mol (line 11) | def mol():
function test_rsgcn_default_preprocessor (line 15) | def test_rsgcn_default_preprocessor(mol):
function test_rsgcn_non_default_padding_preprocessor (line 29) | def test_rsgcn_non_default_padding_preprocessor(mol):
function test_rsgcn_non_default_max_atoms_preprocessor (line 44) | def test_rsgcn_non_default_max_atoms_preprocessor(mol):
function test_rsgcn_preprocessor (line 62) | def test_rsgcn_preprocessor(mol):
function test_rsgcn_preprocessor_default (line 76) | def test_rsgcn_preprocessor_default():
function test_rsgcn_preprocessor_assert_raises (line 91) | def test_rsgcn_preprocessor_assert_raises():
FILE: tests/dataset_tests/preprocessors_tests/test_schnet_preprocessor.py
function mol (line 10) | def mol():
function pp (line 16) | def pp():
function test_schnet_preprocessor (line 20) | def test_schnet_preprocessor(mol, pp):
function test_schnet_preprocessor_default (line 37) | def test_schnet_preprocessor_default():
function test_schnet_preprocessor_assert_raises (line 53) | def test_schnet_preprocessor_assert_raises():
FILE: tests/dataset_tests/preprocessors_tests/test_weavenet_preprocessor.py
function test_weave_preprocessor (line 10) | def test_weave_preprocessor(max_atoms, use_fixed_atom_feature):
FILE: tests/dataset_tests/preprocessors_tests/test_wle.py
function small_datasets (line 9) | def small_datasets():
function _get_elements (line 53) | def _get_elements(datasets, idx):
function _get_atom_arrays (line 57) | def _get_atom_arrays(datasets):
function _get_adj_arrays (line 61) | def _get_adj_arrays(datasets):
function _get_wle_arrays (line 65) | def _get_wle_arrays(datasets):
function _get_teach_signals (line 69) | def _get_teach_signals(datasets, is_cwle=False):
function _check_np_array (line 76) | def _check_np_array(actuals, expects):
function test_wle (line 84) | def test_wle(small_datasets):
function test_2_hop_wle (line 120) | def test_2_hop_wle(small_datasets):
function test_cwle (line 163) | def test_cwle(small_datasets):
function test_findmaxidx_atom_label (line 206) | def test_findmaxidx_atom_label(small_datasets):
function cwle_datasets (line 213) | def cwle_datasets():
function test_findmaxidx_wle (line 235) | def test_findmaxidx_wle(cwle_datasets):
FILE: tests/dataset_tests/preprocessors_tests/test_wle_atom_array_update.py
function k3_datasets (line 11) | def k3_datasets():
function _is_all_same (line 23) | def _is_all_same(arr):
function _is_all_different (line 29) | def _is_all_different(arr):
function test_update_atom_array (line 37) | def test_update_atom_array(k3_datasets, cutoff):
function single_atom_datasets (line 57) | def single_atom_datasets():
function test_update_atom_array_2 (line 70) | def test_update_atom_array_2(single_atom_datasets, cutoff):
function different_sample_size_datasets (line 102) | def different_sample_size_datasets():
function test_update_atom_array_with_diffent_sample_sizes (line 114) | def test_update_atom_array_with_diffent_sample_sizes(
function different_graph_size_datasets (line 128) | def different_graph_size_datasets():
function test_update_atom_array_with_different_graph_size (line 143) | def test_update_atom_array_with_different_graph_size(
function line_graph_datasets (line 158) | def line_graph_datasets():
function test_update_atom_array_twice (line 175) | def test_update_atom_array_twice(line_graph_datasets):
function small_datasets (line 190) | def small_datasets():
function test_list_all_expanded_labels_with_focus_atom (line 232) | def test_list_all_expanded_labels_with_focus_atom(small_datasets):
function test_list_all_expanded_labels_without_focus_atom (line 257) | def test_list_all_expanded_labels_without_focus_atom(small_datasets):
FILE: tests/dataset_tests/preprocessors_tests/test_wle_util.py
function test_to_index (line 7) | def test_to_index():
function test_to_index_non_existence (line 20) | def test_to_index_non_existence():
function test_compress_relation_axis_2_dim (line 28) | def test_compress_relation_axis_2_dim():
function test_compress_relation_axis_3_dim (line 34) | def test_compress_relation_axis_3_dim():
function test_compress_relation_axis_invalid_ndim (line 57) | def test_compress_relation_axis_invalid_ndim():
function small_molecule (line 68) | def small_molecule():
function test_get_neighbor_representation_with_focus_atom (line 80) | def test_get_neighbor_representation_with_focus_atom(small_molecule):
function test_get_neighbor_representation_without_focus_atom (line 89) | def test_get_neighbor_representation_without_focus_atom(small_molecule):
function test_get_focus_node_label (line 105) | def test_get_focus_node_label(label, expect):
function test_get_focus_node_label_invalid (line 111) | def test_get_focus_node_label_invalid(label):
FILE: tests/dataset_tests/splitters_tests/test_deepchem_scaffold_splitter.py
function smiles_list (line 13) | def smiles_list():
function dataset (line 30) | def dataset(smiles_list):
function test_generate_scaffold (line 39) | def test_generate_scaffold():
function test_split (line 46) | def test_split(dataset):
function test_split_fix_seed (line 64) | def test_split_fix_seed(dataset):
function test_split_fail (line 76) | def test_split_fail(dataset):
function test_train_valid_test_split (line 84) | def test_train_valid_test_split(dataset):
function test_train_valid_test_split_return_dataset (line 95) | def test_train_valid_test_split_return_dataset(dataset):
function test_train_valid_split (line 109) | def test_train_valid_split(dataset):
function test_train_valid_split_return_dataset (line 119) | def test_train_valid_split_return_dataset(dataset):
FILE: tests/dataset_tests/splitters_tests/test_random_splitter.py
function dataset (line 9) | def dataset():
function ndarray_dataset (line 17) | def ndarray_dataset():
function test_split (line 22) | def test_split(dataset):
function test_split_fix_seed (line 40) | def test_split_fix_seed(dataset):
function test_split_fail (line 50) | def test_split_fail(dataset):
function test_train_valid_test_split (line 59) | def test_train_valid_test_split(dataset):
function test_train_valid_test_split_return_dataset (line 68) | def test_train_valid_test_split_return_dataset(dataset):
function test_train_valid_test_split_ndarray_return_dataset (line 80) | def test_train_valid_test_split_ndarray_return_dataset(ndarray_dataset):
function test_train_valid_split (line 92) | def test_train_valid_split(dataset):
function test_train_valid_split_return_dataset (line 100) | def test_train_valid_split_return_dataset(dataset):
FILE: tests/dataset_tests/splitters_tests/test_scaffold_splitter.py
function smiles_list (line 13) | def smiles_list():
function dataset (line 30) | def dataset(smiles_list):
function test_generate_scaffold (line 39) | def test_generate_scaffold():
function test_split (line 46) | def test_split(dataset):
function test_split_fix_seed (line 64) | def test_split_fix_seed(dataset):
function test_split_fail (line 76) | def test_split_fail(dataset):
function test_train_valid_test_split (line 84) | def test_train_valid_test_split(dataset):
function test_train_valid_test_split_return_dataset (line 95) | def test_train_valid_test_split_return_dataset(dataset):
function test_train_valid_split (line 109) | def test_train_valid_split(dataset):
function test_train_valid_split_return_dataset (line 119) | def test_train_valid_split_return_dataset(dataset):
FILE: tests/dataset_tests/splitters_tests/test_stratified_splitter.py
function cls_dataset (line 9) | def cls_dataset():
function cls_label (line 17) | def cls_label():
function cls_ndarray_dataset (line 23) | def cls_ndarray_dataset():
function reg_dataset (line 30) | def reg_dataset():
function test_classification_split (line 37) | def test_classification_split(cls_dataset):
function test_classification_split_by_labels_ndarray (line 69) | def test_classification_split_by_labels_ndarray(cls_dataset, cls_label):
function test_classification_split_by_labels_list (line 103) | def test_classification_split_by_labels_list(cls_dataset, cls_label):
function test_regression_split (line 138) | def test_regression_split(reg_dataset):
function test_classification_split_fix_seed (line 170) | def test_classification_split_fix_seed(cls_dataset):
function test_split_fail_by_frac_ratio (line 180) | def test_split_fail_by_frac_ratio(cls_dataset):
function test_split_fail_by_invalid_task_type (line 189) | def test_split_fail_by_invalid_task_type(cls_dataset):
function test_regression_split_fix_seed (line 199) | def test_regression_split_fix_seed(reg_dataset):
function test_train_valid_test_classification_split (line 209) | def test_train_valid_test_classification_split(cls_dataset):
function test_train_valid_test_classification_split_return_dataset (line 226) | def test_train_valid_test_classification_split_return_dataset(cls_dataset):
function test_train_valid_test_classification_split_ndarray_return_dataset (line 241) | def test_train_valid_test_classification_split_ndarray_return_dataset(
function test_train_valid_test_regression_split (line 259) | def test_train_valid_test_regression_split(reg_dataset):
function test_train_valid_test_regression_split_return_dataset (line 276) | def test_train_valid_test_regression_split_return_dataset(reg_dataset):
function test_train_valid_classification_split (line 291) | def test_train_valid_classification_split(cls_dataset):
function test_train_valid_classification_split_return_dataset (line 304) | def test_train_valid_classification_split_return_dataset(cls_dataset):
function test_train_valid_classification_split_ndarray_return_dataset (line 315) | def test_train_valid_classification_split_ndarray_return_dataset(
function test_train_valid_test_cls_split_by_labels_return_dataset (line 329) | def test_train_valid_test_cls_split_by_labels_return_dataset(cls_dataset,
function test_train_valid_cls_split_by_labels_return_dataset (line 346) | def test_train_valid_cls_split_by_labels_return_dataset(cls_dataset,
function test_train_valid_regression_split (line 359) | def test_train_valid_regression_split(reg_dataset):
function test_train_valid_regression_split_return_dataset (line 372) | def test_train_valid_regression_split_return_dataset(reg_dataset):
FILE: tests/dataset_tests/splitters_tests/test_time_splitter.py
function time_list (line 9) | def time_list():
function dataset (line 26) | def dataset():
function test_split (line 33) | def test_split(dataset, time_list):
function test_split_fail (line 57) | def test_split_fail(dataset, time_list):
function test_train_valid_test_split (line 65) | def test_train_valid_test_split(dataset, time_list):
function test_train_valid_test_split_return_dataset (line 78) | def test_train_valid_test_split_return_dataset(dataset, time_list):
function test_train_valid_split (line 90) | def test_train_valid_split(dataset, time_list):
function test_train_split_return_dataset (line 101) | def test_train_split_return_dataset(dataset, time_list):
FILE: tests/dataset_tests/test_converters.py
function data_1d (line 9) | def data_1d():
function data_1d_expect (line 16) | def data_1d_expect():
function data_2d (line 23) | def data_2d():
function data_2d_expect (line 30) | def data_2d_expect():
function test_concat_mols_1d_cpu (line 36) | def test_concat_mols_1d_cpu(data_1d, data_1d_expect):
function test_concat_mols_2d_cpu (line 42) | def test_concat_mols_2d_cpu(data_2d, data_2d_expect):
function test_concat_mols_1d_gpu (line 49) | def test_concat_mols_1d_gpu(data_1d, data_1d_expect):
function test_concat_mols_2d_gpu (line 60) | def test_concat_mols_2d_gpu(data_2d, data_2d_expect):
FILE: tests/dataset_tests/test_numpy_tuple_feature_indexer.py
function data (line 10) | def data():
function indexer (line 18) | def indexer(data):
class TestNumpyTupleDatasetFeatureIndexer (line 24) | class TestNumpyTupleDatasetFeatureIndexer(object):
method test_feature_length (line 26) | def test_feature_length(self, indexer):
method test_extract_feature_by_slice (line 32) | def test_extract_feature_by_slice(self, indexer, data, slice_index, j):
method test_extract_feature_by_ndarray (line 46) | def test_extract_feature_by_ndarray(self, indexer, data, ndarray_index...
FILE: tests/datasets_tests/molnet_tests/test_molnet.py
function test_get_molnet_filepath_without_download (line 19) | def test_get_molnet_filepath_without_download():
function test_get_molnet_filepath_with_download (line 30) | def test_get_molnet_filepath_with_download():
function test_get_grid_featurized_pdbbind_dataset (line 40) | def test_get_grid_featurized_pdbbind_dataset():
function test_get_molnet_bbbp_dataset (line 71) | def test_get_molnet_bbbp_dataset():
function test_get_molnet_bbbp_dataset_change_split_ratio (line 100) | def test_get_molnet_bbbp_dataset_change_split_ratio():
function test_get_molnet_bbbp_dataset_with_smiles (line 130) | def test_get_molnet_bbbp_dataset_with_smiles():
function test_get_molnet_clearance_dataset (line 160) | def test_get_molnet_clearance_dataset():
function test_get_molnet_clearance_dataset_with_return_smiles_enabled (line 187) | def test_get_molnet_clearance_dataset_with_return_smiles_enabled():
function test_get_molnet_pdbbind_dataset (line 218) | def test_get_molnet_pdbbind_dataset():
function test_get_molnet_pdbbind_dataset_with_pdb_id (line 252) | def test_get_molnet_pdbbind_dataset_with_pdb_id():
function test_get_molnet_grid_featurized_pdbbind_dataset (line 287) | def test_get_molnet_grid_featurized_pdbbind_dataset():
function test_get_molnet_qm7_dataset (line 317) | def test_get_molnet_qm7_dataset():
function test_get_molnet_qm7_dataset_with_smiles (line 348) | def test_get_molnet_qm7_dataset_with_smiles():
function test_get_molnet_bbbp_dataframe (line 381) | def test_get_molnet_bbbp_dataframe():
function test_get_molnet_pdbbind_smiles_dataframe (line 387) | def test_get_molnet_pdbbind_smiles_dataframe():
function test_get_molnet_pdbbind_grid_dataframe (line 394) | def test_get_molnet_pdbbind_grid_dataframe():
FILE: tests/datasets_tests/molnet_tests/test_pdbbind_time.py
function test_get_pdbbind_time_filepath (line 9) | def test_get_pdbbind_time_filepath():
function test_get_pdbbind_time (line 21) | def test_get_pdbbind_time():
FILE: tests/datasets_tests/test_numpy_tuple_dataset.py
function data (line 12) | def data():
function long_data (line 20) | def long_data():
class TestNumpyTupleDataset (line 27) | class TestNumpyTupleDataset(object):
method test_len (line 29) | def test_len(self, data):
method test_get_item_integer_index (line 34) | def test_get_item_integer_index(self, data, index):
method test_get_item_slice_index (line 43) | def test_get_item_slice_index(self, data, index):
method test_get_item_ndarray_index (line 61) | def test_get_item_ndarray_index(self, long_data, index):
method test_get_item_list_index (line 77) | def test_get_item_list_index(self, long_data, index):
method test_invalid_datasets (line 92) | def test_invalid_datasets(self):
method test_save_load (line 98) | def test_save_load(self, data):
method test_get_datasets (line 110) | def test_get_datasets(self, data):
FILE: tests/datasets_tests/test_qm9.py
function test_get_qm9_filepath_without_download (line 14) | def test_get_qm9_filepath_without_download():
function test_get_qm9_filepath_with_download (line 25) | def test_get_qm9_filepath_with_download():
function test_get_qm9 (line 37) | def test_get_qm9():
function test_get_qm9_smiles (line 58) | def test_get_qm9_smiles():
function test_get_qm9_label_names (line 95) | def test_get_qm9_label_names():
FILE: tests/datasets_tests/test_tox21.py
function test_get_tox21_filepath_without_download (line 19) | def test_get_tox21_filepath_without_download(dataset_type):
function test_get_tox21_filepath_with_download (line 33) | def test_get_tox21_filepath_with_download(dataset_type):
function test_get_tox21 (line 47) | def test_get_tox21():
function test_get_tox21_label_names (line 64) | def test_get_tox21_label_names():
function test_get_tox21_filepath_assert_raises (line 71) | def test_get_tox21_filepath_assert_raises():
FILE: tests/datasets_tests/test_zinc.py
function test_get_zinc_filepath_without_download (line 14) | def test_get_zinc_filepath_without_download():
function test_get_zinc_filepath_with_download (line 25) | def test_get_zinc_filepath_with_download():
function test_get_zinc (line 37) | def test_get_zinc():
function test_get_zinc_smiles (line 57) | def test_get_zinc_smiles():
function test_get_zinc_label_names (line 106) | def test_get_zinc_label_names():
FILE: tests/functions_tests/activation/test_megnet_softplus.py
function test_forward_cpu (line 10) | def test_forward_cpu():
function test_forward_zero_cpu (line 19) | def test_forward_zero_cpu():
function test_forward_avoid_overflow_cpu (line 26) | def test_forward_avoid_overflow_cpu():
function test_forward_gpu (line 34) | def test_forward_gpu():
function test_forward_zero_gpu (line 44) | def test_forward_zero_gpu():
function test_forward_avoid_overflow_gpu (line 52) | def test_forward_avoid_overflow_gpu():
FILE: tests/functions_tests/activation/test_shifted_softplus.py
function test_forward_cpu (line 9) | def test_forward_cpu():
function test_forward_zero_cpu (line 18) | def test_forward_zero_cpu():
function test_forward_avoid_overflow_cpu (line 25) | def test_forward_avoid_overflow_cpu():
function test_forward_gpu (line 33) | def test_forward_gpu():
function test_forward_zero_gpu (line 43) | def test_forward_zero_gpu():
function test_forward_avoid_overflow_gpu (line 51) | def test_forward_avoid_overflow_gpu():
FILE: tests/functions_tests/activation/test_softmax.py
function test_forward_cpu (line 9) | def test_forward_cpu():
function test_forward_cpu_with_mask (line 18) | def test_forward_cpu_with_mask():
function test_forward_gpu (line 29) | def test_forward_gpu():
function test_forward_gpu_with_mask (line 39) | def test_forward_gpu_with_mask():
FILE: tests/functions_tests/evaluation/test_r2_score.py
function r2_score (line 9) | def r2_score(pred, true, sample_weight=None, multioutput="uniform_average",
function inputs (line 40) | def inputs():
function check_forward (line 54) | def check_forward(inputs):
function check_forward_ignore_nan (line 64) | def check_forward_ignore_nan(inputs):
function check_forward_ignore_nan_with_nonnan_value (line 74) | def check_forward_ignore_nan_with_nonnan_value(inputs):
function test_forward_cpu (line 84) | def test_forward_cpu(inputs):
function test_forward_gpu (line 91) | def test_forward_gpu(inputs):
FILE: tests/functions_tests/loss/test_mean_absolute_error.py
function inputs (line 12) | def inputs():
function grads (line 27) | def grads():
function check_forward (line 35) | def check_forward(inputs):
function check_forward_ignore_nan (line 53) | def check_forward_ignore_nan(inputs):
function check_forward_ignore_nan_with_nonnan_value (line 74) | def check_forward_ignore_nan_with_nonnan_value(inputs):
function test_forward_cpu (line 95) | def test_forward_cpu(inputs):
function test_forward_gpu (line 102) | def test_forward_gpu(inputs):
function check_backward (line 108) | def check_backward(inputs):
function check_backward_ignore_nan (line 115) | def check_backward_ignore_nan(inputs):
function check_backward_ignore_nan_with_nonnan_value (line 125) | def check_backward_ignore_nan_with_nonnan_value(inputs):
function test_backward_cpu (line 134) | def test_backward_cpu(inputs):
function test_backward_gpu (line 141) | def test_backward_gpu(inputs):
function check_double_backward (line 149) | def check_double_backward(inputs, grads):
function check_double_backward_ignore_nan (line 159) | def check_double_backward_ignore_nan(inputs, grads):
function check_double_backward_ignore_nan_with_nonnan_value (line 170) | def check_double_backward_ignore_nan_with_nonnan_value(inputs, grads):
function test_double_backward_cpu (line 181) | def test_double_backward_cpu(inputs, grads):
function test_double_backward_gpu (line 188) | def test_double_backward_gpu(inputs, grads):
FILE: tests/functions_tests/loss/test_mean_squared_error.py
function inputs (line 12) | def inputs():
function grads (line 24) | def grads():
function check_forward (line 32) | def check_forward(inputs):
function check_forward_ignore_nan (line 50) | def check_forward_ignore_nan(inputs):
function check_forward_ignore_nan_with_nonnan_value (line 71) | def check_forward_ignore_nan_with_nonnan_value(inputs):
function test_forward_cpu (line 92) | def test_forward_cpu(inputs):
function test_forward_gpu (line 99) | def test_forward_gpu(inputs):
function check_backward (line 105) | def check_backward(inputs):
function check_backward_ignore_nan (line 112) | def check_backward_ignore_nan(inputs):
function check_backward_ignore_nan_with_nonnan_value (line 121) | def check_backward_ignore_nan_with_nonnan_value(inputs):
function test_backward_cpu (line 130) | def test_backward_cpu(inputs):
function test_backward_gpu (line 137) | def test_backward_gpu(inputs):
function check_double_backward (line 145) | def check_double_backward(inputs, grads):
function check_double_backward_ignore_nan (line 153) | def check_double_backward_ignore_nan(inputs, grads):
function check_double_backward_ignore_nan_with_nonnan_value (line 163) | def check_double_backward_ignore_nan_with_nonnan_value(inputs, grads):
function test_double_backward_cpu (line 173) | def test_double_backward_cpu(inputs, grads):
function test_double_backward_gpu (line 180) | def test_double_backward_gpu(inputs, grads):
FILE: tests/iterators_tests/test_balanced_serial_iterator.py
class DummySerializer (line 10) | class DummySerializer(serializer.Serializer):
method __init__ (line 12) | def __init__(self, target):
method __getitem__ (line 16) | def __getitem__(self, key):
method __call__ (line 21) | def __call__(self, key, value):
class DummyDeserializer (line 26) | class DummyDeserializer(serializer.Deserializer):
method __init__ (line 28) | def __init__(self, target):
method __getitem__ (line 32) | def __getitem__(self, key):
method __call__ (line 36) | def __call__(self, key, value):
function test_balanced_serial_iterator (line 46) | def test_balanced_serial_iterator():
function _test_balanced_serial_iterator_no_batch_balancing (line 51) | def _test_balanced_serial_iterator_no_batch_balancing():
function _test_balanced_serial_iterator_with_batch_balancing (line 76) | def _test_balanced_serial_iterator_with_batch_balancing():
function test_balanced_serial_iterator_serialization (line 95) | def test_balanced_serial_iterator_serialization():
function _test_balanced_serial_iterator_serialization_no_batch_balancing (line 100) | def _test_balanced_serial_iterator_serialization_no_batch_balancing():
function _test_balanced_serial_iterator_serialization_with_batch_balancing (line 135) | def _test_balanced_serial_iterator_serialization_with_batch_balancing():
FILE: tests/iterators_tests/test_index_iterator.py
class DummySerializer (line 9) | class DummySerializer(serializer.Serializer):
method __init__ (line 11) | def __init__(self, target):
method __getitem__ (line 15) | def __getitem__(self, key):
method __call__ (line 20) | def __call__(self, key, value):
class DummyDeserializer (line 25) | class DummyDeserializer(serializer.Deserializer):
method __init__ (line 27) | def __init__(self, target):
method __getitem__ (line 31) | def __getitem__(self, key):
method __call__ (line 35) | def __call__(self, key, value):
function test_index_iterator (line 45) | def test_index_iterator():
function _test_index_iterator_no_shuffle (line 50) | def _test_index_iterator_no_shuffle():
function _test_index_iterator_with_shuffle (line 77) | def _test_index_iterator_with_shuffle():
function test_index_iterator_serialization (line 96) | def test_index_iterator_serialization():
function _test_index_iterator_serialization_no_shuffle (line 101) | def _test_index_iterator_serialization_no_shuffle():
function _test_index_iterator_serialization_with_shuffle (line 123) | def _test_index_iterator_serialization_with_shuffle():
FILE: tests/link_hooks_tests/test_variable_monitor_link_hook.py
class DummyModel (line 13) | class DummyModel(chainer.Chain):
method __init__ (line 14) | def __init__(self):
method forward (line 22) | def forward(self, x):
function model (line 29) | def model():
function test_variable_monitor_link_hook_pre (line 35) | def test_variable_monitor_link_hook_pre(model):
function test_variable_monitor_link_hook_post (line 47) | def test_variable_monitor_link_hook_post(model):
function test_variable_monitor_link_hook_process (line 59) | def test_variable_monitor_link_hook_process(model):
function test_variable_monitor_link_hook_assert_raises (line 82) | def test_variable_monitor_link_hook_assert_raises(model):
FILE: tests/links_tests/array_tests/test_shape_transformer_to_2d.py
function test_shape_transformer_2d_2d_array (line 8) | def test_shape_transformer_2d_2d_array(axis):
function test_shape_transformer_2d_3d_array (line 22) | def test_shape_transformer_2d_3d_array(axis):
function test_shape_transformer_2d_error (line 41) | def test_shape_transformer_2d_error():
FILE: tests/links_tests/connection_tests/test_embed_atom_id.py
function model (line 15) | def model():
function data (line 22) | def data():
function check_forward (line 30) | def check_forward(model, x_data):
function test_forward_cpu (line 41) | def test_forward_cpu(model, data):
function test_forward_gpu (line 47) | def test_forward_gpu(model, data):
function test_backward_cpu (line 53) | def test_backward_cpu(model, data):
function test_backward_gpu (line 60) | def test_backward_gpu(model, data):
FILE: tests/links_tests/connection_tests/test_graph_linear.py
function model (line 15) | def model():
function data (line 22) | def data():
function test_forward_cpu (line 30) | def test_forward_cpu(model, data):
function test_forward_gpu (line 38) | def test_forward_gpu(model, data):
function test_backward_cpu (line 45) | def test_backward_cpu(model, data):
function test_backward_gpu (line 52) | def test_backward_gpu(model, data):
FILE: tests/links_tests/connection_tests/test_graph_mlp.py
function model (line 16) | def model():
function data (line 23) | def data():
function test_forward_cpu (line 31) | def test_forward_cpu(model, data):
function test_forward_gpu (line 40) | def test_forward_gpu(model, data):
function test_backward_cpu (line 48) | def test_backward_cpu(model, data):
function test_backward_gpu (line 55) | def test_backward_gpu(model, data):
FILE: tests/links_tests/readout_tests/test_cgcnn_readout.py
function readout (line 18) | def readout():
function data (line 23) | def data():
function check_forward (line 45) | def check_forward(readout, data):
function test_forward_cpu (line 50) | def test_forward_cpu(readout, data):
function test_forward_gpu (line 56) | def test_forward_gpu(readout, data):
FILE: tests/links_tests/readout_tests/test_general_readout.py
function readouts (line 17) | def readouts():
function data (line 23) | def data():
function check_forward (line 32) | def check_forward(readout, atom_data):
function test_forward_cpu (line 40) | def test_forward_cpu(readouts, data):
function test_forward_gpu (line 47) | def test_forward_gpu(readouts, data):
function test_forward_cpu_assert_raises (line 54) | def test_forward_cpu_assert_raises(data):
function test_backward_cpu (line 61) | def test_backward_cpu(readouts, data):
function test_backward_gpu (line 71) | def test_backward_gpu(readouts, data):
function test_forward_cpu_graph_invariant (line 82) | def test_forward_cpu_graph_invariant(readouts, data):
FILE: tests/links_tests/readout_tests/test_ggnn_readout.py
function readout (line 18) | def readout():
function data (line 23) | def data():
function check_forward (line 35) | def check_forward(readout, atom_data, atom_data0):
function test_forward_cpu (line 40) | def test_forward_cpu(readout, data):
function test_forward_gpu (line 46) | def test_forward_gpu(readout, data):
function test_backward_cpu (line 52) | def test_backward_cpu(readout, data):
function test_backward_gpu (line 59) | def test_backward_gpu(readout, data):
function test_forward_cpu_graph_invariant (line 66) | def test_forward_cpu_graph_invariant(readout, data):
FILE: tests/links_tests/readout_tests/test_megnet_readout.py
function readout (line 19) | def readout():
function data (line 24) | def data():
function check_forward (line 38) | def check_forward(readout, data):
function test_forward_cpu (line 43) | def test_forward_cpu(readout, data):
function test_forward_gpu (line 49) | def test_forward_gpu(readout, data):
function test_backward_cpu (line 55) | def test_backward_cpu(readout, data):
function test_backward_gpu (line 62) | def test_backward_gpu(readout, data):
FILE: tests/links_tests/readout_tests/test_mpnn_readout.py
function readout (line 20) | def readout():
function data (line 26) | def data():
function check_forward (line 36) | def check_forward(readout, atom_data):
function test_foward_cpu (line 42) | def test_foward_cpu(readout, data):
function test_foward_gpu (line 49) | def test_foward_gpu(readout, data):
function test_backward_cpu (line 56) | def test_backward_cpu(readout, data):
function test_backward_gpu (line 64) | def test_backward_gpu(readout, data):
function test_foward_cpu_graph_invariant (line 72) | def test_foward_cpu_graph_invariant(readout, data):
FILE: tests/links_tests/readout_tests/test_nfp_readout.py
function readout (line 17) | def readout():
function data (line 22) | def data():
function check_forward (line 31) | def check_forward(readout, atom_data):
function test_forward_cpu (line 36) | def test_forward_cpu(readout, data):
function test_forward_gpu (line 42) | def test_forward_gpu(readout, data):
function test_backward_cpu (line 48) | def test_backward_cpu(readout, data):
function test_backward_gpu (line 55) | def test_backward_gpu(readout, data):
function test_forward_cpu_graph_invariant (line 62) | def test_forward_cpu_graph_invariant(readout, data):
FILE: tests/links_tests/readout_tests/test_schnet_readout.py
function readout (line 17) | def readout():
function data (line 22) | def data():
function check_forward (line 31) | def check_forward(readout, atom_data):
function test_forward_cpu (line 36) | def test_forward_cpu(readout, data):
function test_forward_gpu (line 42) | def test_forward_gpu(readout, data):
function test_backward_cpu (line 48) | def test_backward_cpu(readout, data):
function test_backward_gpu (line 55) | def test_backward_gpu(readout, data):
function test_forward_cpu_graph_invariant (line 62) | def test_forward_cpu_graph_invariant(readout, data):
FILE: tests/links_tests/readout_tests/test_set2set.py
function readout (line 19) | def readout():
function data (line 25) | def data():
function check_forward (line 36) | def check_forward(readout, atom_data):
function test_forward_cpu (line 43) | def test_forward_cpu(readout, data):
function test_forward_gpu (line 50) | def test_forward_gpu(readout, data):
function check_backward (line 57) | def check_backward(readout, atom_data, y_grad):
function test_backward_cpu (line 78) | def test_backward_cpu(readout, data):
function test_backward_gpu (line 84) | def test_backward_gpu(readout, data):
function test_forward_cpu_graph_invariant (line 91) | def test_forward_cpu_graph_invariant(readout, data):
FILE: tests/links_tests/scaler_tests/test_flow_scaler.py
function test_flow_scaler_transform_uniform (line 13) | def test_flow_scaler_transform_uniform():
function test_flow_scaler_transform_mix_gaussian (line 25) | def test_flow_scaler_transform_mix_gaussian():
function test_flow_scaler_transform_variable (line 40) | def test_flow_scaler_transform_variable():
function test_flow_scaler_transform_gpu (line 54) | def test_flow_scaler_transform_gpu():
function test_flow_scaler_serialize (line 69) | def test_flow_scaler_serialize(tmpdir):
function test_flow_scaler_pipeline (line 90) | def test_flow_scaler_pipeline():
function test_flow_scaler_pipeline_gpu (line 103) | def test_flow_scaler_pipeline_gpu():
FILE: tests/links_tests/scaler_tests/test_max_abs_scaler.py
function data (line 11) | def data():
function test_max_abs_scaler_transform (line 28) | def test_max_abs_scaler_transform(data, indices):
function test_max_abs_scaler_transform_variable (line 48) | def test_max_abs_scaler_transform_variable(data):
function test_max_abs_scaler_transform_gpu (line 60) | def test_max_abs_scaler_transform_gpu(data):
function test_max_abs_scaler_inverse_transform (line 73) | def test_max_abs_scaler_inverse_transform(data, indices):
function test_max_abs_scaler_3darray (line 90) | def test_max_abs_scaler_3darray(data, axis):
function test_max_abs_scaler_fit_transform (line 117) | def test_max_abs_scaler_fit_transform(data):
function test_max_abs_scaler_serialize (line 131) | def test_max_abs_scaler_serialize(tmpdir, data, indices):
function test_max_abs_scaler_assert_raises (line 147) | def test_max_abs_scaler_assert_raises():
function test_max_abs_scaler_transform_zero_max (line 159) | def test_max_abs_scaler_transform_zero_max():
FILE: tests/links_tests/scaler_tests/test_min_max_scaler.py
function data (line 11) | def data():
function test_min_max_scaler_transform (line 28) | def test_min_max_scaler_transform(data, indices):
function test_min_max_scaler_transform_variable (line 49) | def test_min_max_scaler_transform_variable(data):
function test_min_max_scaler_transform_gpu (line 61) | def test_min_max_scaler_transform_gpu(data):
function test_min_max_scaler_inverse_transform (line 74) | def test_min_max_scaler_inverse_transform(data, indices):
function test_min_max_scaler_3darray (line 91) | def test_min_max_scaler_3darray(data, axis):
function test_min_max_scaler_fit_transform (line 118) | def test_min_max_scaler_fit_transform(data):
function test_min_max_scaler_serialize (line 132) | def test_min_max_scaler_serialize(tmpdir, data, indices):
function test_min_max_scaler_assert_raises (line 149) | def test_min_max_scaler_assert_raises():
function test_min_max_scaler_transform_zero_max (line 161) | def test_min_max_scaler_transform_zero_max():
FILE: tests/links_tests/scaler_tests/test_standard_scaler.py
function data (line 12) | def data():
function test_standard_scaler_transform (line 29) | def test_standard_scaler_transform(data, indices):
function test_standard_scaler_transform_variable (line 45) | def test_standard_scaler_transform_variable(data):
function test_standard_scaler_transform_gpu (line 57) | def test_standard_scaler_transform_gpu(data):
function test_standard_scaler_inverse_transform (line 70) | def test_standard_scaler_inverse_transform(data, indices):
function test_standard_scaler_3darray (line 87) | def test_standard_scaler_3darray(data, axis):
function test_standard_scaler_fit_transform (line 114) | def test_standard_scaler_fit_transform(data):
function test_standard_scaler_serialize (line 128) | def test_standard_scaler_serialize(tmpdir, data, indices):
function test_standard_scaler_assert_raises (line 145) | def test_standard_scaler_assert_raises():
function test_standard_scaler_transform_zero_std (line 157) | def test_standard_scaler_transform_zero_std():
function test_standard_scaler_forward (line 167) | def test_standard_scaler_forward(data):
FILE: tests/links_tests/update_tests/test_cgcnn_update.py
function update (line 20) | def update():
function data (line 25) | def data():
function check_forward (line 51) | def check_forward(update, data):
function test_forward_cpu (line 56) | def test_forward_cpu(update, data):
function test_forward_gpu (line 62) | def test_forward_gpu(update, data):
FILE: tests/links_tests/update_tests/test_ggnn_update.py
function update (line 23) | def update():
function data (line 29) | def data():
function convert_to_sparse (line 46) | def convert_to_sparse(dense_adj):
function check_forward (line 53) | def check_forward(update, atom_data, adj_data):
function test_forward_cpu (line 60) | def test_forward_cpu(update, data):
function test_forward_gpu (line 74) | def test_forward_gpu(update, data):
function check_backward (line 87) | def check_backward(update, atom_data, adj_data, y_grad):
function test_backward_cpu (line 109) | def test_backward_cpu(update, data):
function test_backward_gpu (line 119) | def test_backward_gpu(update, data):
function test_forward_cpu_graph_invariant (line 129) | def test_forward_cpu_graph_invariant(update, data):
FILE: tests/links_tests/update_tests/test_gin_update.py
function update (line 23) | def update():
function data (line 30) | def data():
function check_forward (line 45) | def check_forward(update, atom_data, adj_data):
function test_forward_cpu (line 51) | def test_forward_cpu(update, data):
function test_forward_gpu (line 58) | def test_forward_gpu(update, data):
function test_backward_cpu (line 65) | def test_backward_cpu(update, data):
function test_backward_gpu (line 73) | def test_backward_gpu(update, data):
function test_forward_cpu_graph_invariant (line 81) | def test_forward_cpu_graph_invariant(update, data):
FILE: tests/links_tests/update_tests/test_gnn_film_update.py
function update (line 20) | def update():
function data (line 26) | def data():
function check_forward (line 44) | def check_forward(update, atom_data, adj_data):
function test_forward_cpu (line 50) | def test_forward_cpu(update, data):
function test_forward_gpu (line 57) | def test_forward_gpu(update, data):
function test_backward_cpu (line 64) | def test_backward_cpu(update, data):
function test_backward_gpu (line 72) | def test_backward_gpu(update, data):
function test_forward_cpu_graph_invariant (line 81) | def test_forward_cpu_graph_invariant(update, data):
FILE: tests/links_tests/update_tests/test_megnet_update.py
function update (line 22) | def update():
function data (line 27) | def data():
function check_forward (line 73) | def check_forward(update, data):
function test_forward_cpu (line 81) | def test_forward_cpu(update, data):
function test_forward_gpu (line 89) | def test_forward_gpu(update, data):
FILE: tests/links_tests/update_tests/test_mpnn_update.py
function message (line 21) | def message():
function update (line 27) | def update():
function data (line 33) | def data():
function check_message_forward (line 51) | def check_message_forward(message, atom_data, adj_data):
function test_message_forward_cpu (line 57) | def test_message_forward_cpu(message, data):
function test_message_forward_gpu (line 64) | def test_message_forward_gpu(message, data):
function test_message_backward_cpu (line 71) | def test_message_backward_cpu(message, data):
function test_message_backward_gpu (line 80) | def test_message_backward_gpu(message, data):
function check_forward (line 91) | def check_forward(update, atom_data, adj_data):
function test_forward_cpu (line 97) | def test_forward_cpu(update, data):
function test_forward_gpu (line 104) | def test_forward_gpu(update, data):
function check_backward (line 111) | def check_backward(update, atom_data, adj_data, y_grad):
function test_backward_cpu (line 132) | def test_backward_cpu(update, data):
function test_backward_gpu (line 139) | def test_backward_gpu(update, data):
FILE: tests/links_tests/update_tests/test_nfp_update.py
function update (line 20) | def update():
function data (line 25) | def data():
function check_forward (line 43) | def check_forward(update, atom_data, adj_data, deg_conds):
function test_forward_cpu (line 48) | def test_forward_cpu(update, data):
function test_forward_gpu (line 54) | def test_forward_gpu(update, data):
function test_backward_cpu (line 60) | def test_backward_cpu(update, data):
function test_backward_gpu (line 67) | def test_backward_gpu(update, data):
function test_forward_cpu_graph_invariant (line 74) | def test_forward_cpu_graph_invariant(update, data):
FILE: tests/links_tests/update_tests/test_relgat_update.py
function update (line 21) | def update():
function data (line 28) | def data():
function check_forward (line 43) | def check_forward(update, atom_data, adj_data):
function test_forward_cpu (line 48) | def test_forward_cpu(update, data):
function test_forward_gpu (line 54) | def test_forward_gpu(update, data):
function test_backward_cpu (line 60) | def test_backward_cpu(update, data):
function test_backward_gpu (line 71) | def test_backward_gpu(update, data):
function test_forward_cpu_graph_invariant (line 78) | def test_forward_cpu_graph_invariant(update, data):
FILE: tests/links_tests/update_tests/test_relgcn_update.py
function update (line 20) | def update():
function data (line 26) | def data():
function check_forward (line 41) | def check_forward(update, atom_data, adj_data):
function test_forward_cpu (line 46) | def test_forward_cpu(update, data):
function test_forward_gpu (line 52) | def test_forward_gpu(update, data):
function test_backward_cpu (line 58) | def test_backward_cpu(update, data):
function test_backward_gpu (line 65) | def test_backward_gpu(update, data):
function test_forward_cpu_graph_invariant (line 72) | def test_forward_cpu_graph_invariant(update, data):
FILE: tests/links_tests/update_tests/test_rsgcn_update.py
function update (line 20) | def update():
function data (line 25) | def data():
function check_forward (line 39) | def check_forward(update, atom_data, adj_data):
function test_forward_cpu (line 44) | def test_forward_cpu(update, data):
function test_forward_gpu (line 50) | def test_forward_gpu(update, data):
function test_backward_cpu (line 56) | def test_backward_cpu(update, data):
function test_backward_gpu (line 63) | def test_backward_gpu(update, data):
function test_forward_cpu_graph_invariant (line 70) | def test_forward_cpu_graph_invariant(update, data):
FILE: tests/links_tests/update_tests/test_schnet_update.py
function update (line 19) | def update():
function data (line 24) | def data():
function check_forward (line 41) | def check_forward(update, atom_data, dist_data):
function test_forward_cpu (line 46) | def test_forward_cpu(update, data):
function test_forward_gpu (line 52) | def test_forward_gpu(update, data):
function test_backward_cpu (line 58) | def test_backward_cpu(update, data):
function test_backward_gpu (line 65) | def test_backward_gpu(update, data):
function test_forward_cpu_graph_invariant (line 72) | def test_forward_cpu_graph_invariant(update, data):
FILE: tests/models_tests/gwm_tests/test_gwm.py
function graph_warp_gate_unit (line 18) | def graph_warp_gate_unit():
function super_warp_gate_unit (line 23) | def super_warp_gate_unit():
function super_node_transmitter_unit (line 28) | def super_node_transmitter_unit():
function graph_transmitter_unit (line 34) | def graph_transmitter_unit():
function gwm (line 40) | def gwm():
function data (line 49) | def data():
function test_graph_transmitter_unit_forward (line 67) | def test_graph_transmitter_unit_forward(graph_transmitter_unit, data):
function test_graph_transmitter_unit_backward (line 74) | def test_graph_transmitter_unit_backward(graph_transmitter_unit, data):
function test_super_node_transmitter_unit_forward (line 83) | def test_super_node_transmitter_unit_forward(super_node_transmitter_unit,
function test_super_node_transmitter_unit_backward (line 90) | def test_super_node_transmitter_unit_backward(super_node_transmitter_unit,
function test_graph_warp_gate_unit_forward (line 98) | def test_graph_warp_gate_unit_forward(graph_warp_gate_unit, data):
function test_graph_warp_gate_unit_backward (line 105) | def test_graph_warp_gate_unit_backward(graph_warp_gate_unit, data):
function test_super_warp_gate_unit_forward (line 114) | def test_super_warp_gate_unit_forward(super_warp_gate_unit, data):
function test_super_warp_gate_unit_backward (line 120) | def test_super_warp_gate_unit_backward(super_warp_gate_unit, data):
function check_forward (line 128) | def check_forward(gwm, embed_atom_data, new_embed_atom_data, supernode):
function test_forward_cpu (line 135) | def test_forward_cpu(gwm, data):
function test_forward_gpu (line 141) | def test_forward_gpu(gwm, data):
function check_backward (line 150) | def check_backward(gwm, embed_atom_data, new_embed_atom_data, supernode,
function test_backward_cpu (line 161) | def test_backward_cpu(gwm, data):
function test_backward_gpu (line 166) | def test_backward_gpu(gwm, data):
function test_forward_cpu_graph_invariant (line 171) | def test_forward_cpu_graph_invariant(gwm, data):
FILE: tests/models_tests/gwm_tests/test_gwm_graph_conv_model.py
function plain_context (line 43) | def plain_context(request):
function gwm_context (line 57) | def gwm_context(request):
function make_model (line 70) | def make_model(update, readout, ch, bn, wt):
function make_gwm_model (line 78) | def make_gwm_model(update, readout, ch, bn, wt):
function make_data (line 86) | def make_data(adj_type):
function test_plain_model_forward (line 108) | def test_plain_model_forward(plain_context):
function test_gwm_model_forward (line 120) | def test_gwm_model_forward(gwm_context):
function test_plain_model_forward_general_readout (line 141) | def test_plain_model_forward_general_readout(
function test_gwm_model_forward_general_readout (line 164) | def test_gwm_model_forward_general_readout(update):
function test_model_forward_general_weight_tying (line 201) | def test_model_forward_general_weight_tying(update, readout, gwm):
function test_model_forward_general_concat_hidden (line 235) | def test_model_forward_general_concat_hidden(update, readout, gwm):
function test_model_forward_general_sum_hidden (line 260) | def test_model_forward_general_sum_hidden(update, readout, gwm):
FILE: tests/models_tests/prediction_tests/test_base.py
class DummyForwardModel (line 11) | class DummyForwardModel(BaseForwardModel):
method __init__ (line 13) | def __init__(self, device=-1, dummy_str='dummy'):
method __call__ (line 21) | def __call__(self, x):
function _test_save_load_pickle (line 26) | def _test_save_load_pickle(device, tmpdir):
function test_save_load_pickle_cpu (line 49) | def test_save_load_pickle_cpu(tmpdir):
function test_save_load_pickle_gpu (line 54) | def test_save_load_pickle_gpu(tmpdir):
FILE: tests/models_tests/prediction_tests/test_classifier.py
class AccuracyWithIgnoreLabel (line 18) | class AccuracyWithIgnoreLabel(object):
method __call__ (line 20) | def __call__(self, y, t):
class DummyPredictor (line 24) | class DummyPredictor(chainer.Chain):
method __call__ (line 25) | def __call__(self, x):
class TestClassifier (line 33) | class TestClassifier(object):
method setup_method (line 35) | def setup_method(self, method):
method check_call (line 40) | def check_call(
method test_call_cpu (line 74) | def test_call_cpu(self, metrics_fun, compute_metrics):
method test_call_three_args_cpu (line 79) | def test_call_three_args_cpu(self, metrics_fun, compute_metrics):
method test_call_positive_cpu (line 84) | def test_call_positive_cpu(self, metrics_fun, compute_metrics):
method test_call_kwargs_cpu (line 89) | def test_call_kwargs_cpu(self, metrics_fun, compute_metrics):
method test_call_no_arg_cpu (line 94) | def test_call_no_arg_cpu(self, metrics_fun, compute_metrics):
method test_call_gpu (line 100) | def test_call_gpu(self, metrics_fun, compute_metrics):
method test_call_three_args_gpu (line 107) | def test_call_three_args_gpu(self, metrics_fun, compute_metrics):
method test_call_positive_gpu (line 114) | def test_call_positive_gpu(self, metrics_fun, compute_metrics):
method test_call_kwargs_gpu (line 121) | def test_call_kwargs_gpu(self, metrics_fun, compute_metrics):
method test_call_no_arg_gpu (line 128) | def test_call_no_arg_gpu(self, metrics_fun, compute_metrics):
method to_gpu (line 133) | def to_gpu(self):
method test_report_key (line 138) | def test_report_key(self, metrics_fun, compute_metrics):
class TestInvalidArgument (line 165) | class TestInvalidArgument(object):
method setup_class (line 168) | def setup_class(cls):
method check_invalid_argument (line 172) | def check_invalid_argument(self):
method test_invalid_argument_cpu (line 179) | def test_invalid_argument_cpu(self):
method test_invalid_argument_gpu (line 183) | def test_invalid_argument_gpu(self):
class TestInvalidLabelKey (line 188) | class TestInvalidLabelKey(object):
method setup_class (line 191) | def setup_class(cls):
method test_invalid_label_key_type (line 194) | def test_invalid_label_key_type(self):
method check_invalid_key (line 198) | def check_invalid_key(self, gpu, label_key):
method test_invalid_index_cpu (line 206) | def test_invalid_index_cpu(self):
method test_invalid_argument_gpu (line 210) | def test_invalid_argument_gpu(self):
method test_invalid_index_too_small_cpu (line 213) | def test_invalid_index_too_small_cpu(self):
method test_invalid_index_too_small_gpu (line 217) | def test_invalid_index_too_small_gpu(self):
method test_invalid_str_key_cpu (line 220) | def test_invalid_str_key_cpu(self):
method test_invalid_str_key_gpu (line 224) | def test_invalid_str_key_gpu(self):
class TestClassifierPrediction (line 228) | class TestClassifierPrediction(object):
method setup_class (line 231) | def setup_class(cls):
method test_predict_cpu (line 237) | def test_predict_cpu(self):
method test_predict_gpu (line 245) | def test_predict_gpu(self):
method check_predict_proba (line 250) | def check_predict_proba(self, device):
method test_predict_proba_cpu (line 261) | def test_predict_proba_cpu(self):
method test_predict_proba_gpu (line 265) | def test_predict_proba_gpu(self):
FILE: tests/models_tests/prediction_tests/test_graph_conv_predictor.py
function model (line 24) | def model():
function data (line 33) | def data():
function check_forward (line 45) | def check_forward(model, atom_data, adj_data):
function test_forward_cpu (line 51) | def test_forward_cpu(model, data):
function test_forward_gpu (line 57) | def test_forward_gpu(model, data):
function test_backward_cpu (line 64) | def test_backward_cpu(model, data):
function test_backward_gpu (line 72) | def test_backward_gpu(model, data):
function test_forward_cpu_graph_invariant (line 80) | def test_forward_cpu_graph_invariant(model, data):
FILE: tests/models_tests/prediction_tests/test_regressor.py
class DummyPredictor (line 13) | class DummyPredictor(chainer.Chain):
method __call__ (line 14) | def __call__(self, x):
class TestRegressor (line 22) | class TestRegressor(object):
method setup_method (line 24) | def setup_method(self, method):
method check_call (line 29) | def check_call(
method test_call_cpu (line 63) | def test_call_cpu(self, metrics_fun, compute_metrics):
method test_call_three_args_cpu (line 68) | def test_call_three_args_cpu(self, metrics_fun, compute_metrics):
method test_call_positive_cpu (line 73) | def test_call_positive_cpu(self, metrics_fun, compute_metrics):
method test_call_kwargs_cpu (line 78) | def test_call_kwargs_cpu(self, metrics_fun, compute_metrics):
method test_call_no_arg_cpu (line 83) | def test_call_no_arg_cpu(self, metrics_fun, compute_metrics):
method test_call_gpu (line 89) | def test_call_gpu(self, metrics_fun, compute_metrics):
method test_call_three_args_gpu (line 96) | def test_call_three_args_gpu(self, metrics_fun, compute_metrics):
method test_call_positive_gpu (line 103) | def test_call_positive_gpu(self, metrics_fun, compute_metrics):
method test_call_kwargs_gpu (line 110) | def test_call_kwargs_gpu(self, metrics_fun, compute_metrics):
method test_call_no_arg_gpu (line 117) | def test_call_no_arg_gpu(self, metrics_fun, compute_metrics):
method to_gpu (line 122) | def to_gpu(self):
method test_report_key (line 127) | def test_report_key(self, metrics_fun, compute_metrics):
class TestInvalidArgument (line 154) | class TestInvalidArgument(object):
method setup_class (line 157) | def setup_class(cls):
method check_invalid_argument (line 161) | def check_invalid_argument(self):
method test_invalid_argument_cpu (line 168) | def test_invalid_argument_cpu(self):
method test_invalid_argument_gpu (line 172) | def test_invalid_argument_gpu(self):
class TestInvalidLabelKey (line 177) | class TestInvalidLabelKey(object):
method setup_class (line 180) | def setup_class(cls):
method test_invalid_label_key_type (line 183) | def test_invalid_label_key_type(self):
method check_invalid_key (line 187) | def check_invalid_key(self, gpu, label_key):
method test_invalid_index_cpu (line 195) | def test_invalid_index_cpu(self):
method test_invalid_argument_gpu (line 199) | def test_invalid_argument_gpu(self):
method test_invalid_index_too_small_cpu (line 202) | def test_invalid_index_too_small_cpu(self):
method test_invalid_index_too_small_gpu (line 206) | def test_invalid_index_too_small_gpu(self):
method test_invalid_str_key_cpu (line 209) | def test_invalid_str_key_cpu(self):
method test_invalid_str_key_gpu (line 213) | def test_invalid_str_key_gpu(self):
class TestRegressorPrediction (line 217) | class TestRegressorPrediction(object):
method setup_class (line 220) | def setup_class(cls):
method test_predict_cpu (line 226) | def test_predict_cpu(self):
method test_predict_gpu (line 234) | def test_predict_gpu(self):
FILE: tests/models_tests/prediction_tests/test_set_up_predictor.py
function models_dict (line 44) | def models_dict():
function test_setup_predictor (line 81) | def test_setup_predictor(models_dict):
function test_call_invalid_model (line 93) | def test_call_invalid_model():
function test_set_up_predictor_with_conv_kwargs (line 103) | def test_set_up_predictor_with_conv_kwargs():
FILE: tests/models_tests/test_cgcnn.py
function model (line 19) | def model():
function data (line 24) | def data():
function check_forward (line 54) | def check_forward(model, data):
function test_forward_cpu (line 59) | def test_forward_cpu(model, data):
function test_forward_gpu (line 65) | def test_forward_gpu(model, data):
FILE: tests/models_tests/test_ggnn.py
function model (line 22) | def model():
function sparse_model (line 28) | def sparse_model():
function data (line 34) | def data():
function check_forward (line 47) | def check_forward(model, *args):
function test_forward_cpu (line 54) | def test_forward_cpu(model, sparse_model, data):
function test_forward_gpu (line 66) | def test_forward_gpu(model, sparse_model, data):
function test_backward_cpu (line 75) | def test_backward_cpu(model, data):
function test_backward_gpu (line 84) | def test_backward_gpu(model, data):
function test_forward_cpu_graph_invariant (line 91) | def test_forward_cpu_graph_invariant(model, data):
function test_forward_cpu_input_size_invariant (line 103) | def test_forward_cpu_input_size_invariant(model, data):
FILE: tests/models_tests/test_gin.py
function model (line 20) | def model():
function data (line 26) | def data():
function check_forward (line 37) | def check_forward(model, atom_data, adj_data):
function test_forward_cpu (line 43) | def test_forward_cpu(model, data):
function test_forward_gpu (line 50) | def test_forward_gpu(model, data):
function test_backward_cpu (line 57) | def test_backward_cpu(model, data):
function test_backward_gpu (line 65) | def test_backward_gpu(model, data):
function test_forward_cpu_graph_invariant (line 73) | def test_forward_cpu_graph_invariant(model, data):
FILE: tests/models_tests/test_gnn_film.py
function model (line 21) | def model():
function data (line 27) | def data():
function check_forward (line 39) | def check_forward(model, atom_data, adj_data):
function test_forward_cpu (line 45) | def test_forward_cpu(model, data):
function test_forward_gpu (line 52) | def test_forward_gpu(model, data):
function test_backward_cpu (line 59) | def test_backward_cpu(model, data):
function test_backward_gpu (line 67) | def test_backward_gpu(model, data):
function test_forward_cpu_graph_invariant (line 75) | def test_forward_cpu_graph_invariant(model, data):
FILE: tests/models_tests/test_megnet.py
function model (line 23) | def model():
function data (line 28) | def data():
function check_forward (line 69) | def check_forward(model, data):
function test_forward_cpu (line 74) | def test_forward_cpu(model, data):
function test_forward_gpu (line 82) | def test_forward_gpu(model, data):
FILE: tests/models_tests/test_mlp.py
function model (line 14) | def model():
function data (line 19) | def data():
function check_forward (line 27) | def check_forward(model, data):
function test_forward_cpu (line 32) | def test_forward_cpu(model, data):
function test_forward_gpu (line 37) | def test_forward_gpu(model, data):
function test_mlp_assert_raises (line 42) | def test_mlp_assert_raises():
function test_backward_cpu (line 47) | def test_backward_cpu(model, data):
function test_backward_gpu (line 53) | def test_backward_gpu(model, data):
FILE: tests/models_tests/test_mpnn.py
function model (line 22) | def model(request):
function data (line 33) | def data():
function check_forward (line 47) | def check_forward(model, atom_data, adj_data):
function test_forward_cpu (line 53) | def test_forward_cpu(model, data):
function test_forward_gpu (line 60) | def test_forward_gpu(model, data):
function test_backward_cpu (line 67) | def test_backward_cpu(model, data):
function test_backward_gpu (line 75) | def test_backward_gpu(model, data):
function test_forward_cpu_graph_invariant (line 83) | def test_forward_cpu_graph_invariant(model, data):
function test_invalid_message_funcion (line 100) | def test_invalid_message_funcion():
function test_invalid_readout_funcion (line 106) | def test_invalid_readout_funcion():
FILE: tests/models_tests/test_nfp.py
function model (line 18) | def model():
function data (line 23) | def data():
function check_forward (line 36) | def check_forward(model, atom_data, adj_data):
function test_forward_cpu (line 41) | def test_forward_cpu(model, data):
function test_forward_gpu (line 47) | def test_forward_gpu(model, data):
function test_backward_cpu (line 54) | def test_backward_cpu(model, data):
function test_backward_gpu (line 62) | def test_backward_gpu(model, data):
function test_forward_cpu_graph_invariant (line 69) | def test_forward_cpu_graph_invariant(model, data):
function test_forward_cpu_input_size_invariant (line 81) | def test_forward_cpu_input_size_invariant(model, data):
FILE: tests/models_tests/test_relgat.py
function model (line 18) | def model(request):
function data (line 23) | def data():
function check_forward (line 36) | def check_forward(model, atom_data, adj_data):
function test_forward_cpu (line 41) | def test_forward_cpu(model, data):
function test_forward_gpu (line 47) | def test_forward_gpu(model, data):
function test_backward_cpu (line 54) | def test_backward_cpu(model, data):
function test_backward_gpu (line 64) | def test_backward_gpu(model, data):
function test_forward_cpu_graph_invariant (line 73) | def test_forward_cpu_graph_invariant(model, data):
FILE: tests/models_tests/test_relgcn.py
function model (line 19) | def model():
function data (line 24) | def data():
function check_forward (line 35) | def check_forward(model, atom_data, adj_data):
function test_forward_cpu (line 40) | def test_forward_cpu(model, data):
function test_forward_gpu (line 46) | def test_forward_gpu(model, data):
function test_backward_cpu (line 52) | def test_backward_cpu(model, data):
function test_backward_gpu (line 59) | def test_backward_gpu(model, data):
function test_forward_cpu_invariant (line 66) | def test_forward_cpu_invariant(model, data):
function test_rescale_adj (line 78) | def test_rescale_adj(data):
FILE: tests/models_tests/test_rsgcn.py
function model (line 21) | def model():
function model_no_dropout (line 26) | def model_no_dropout():
function model_with_nfp (line 33) | def model_with_nfp():
function model_with_nfp_no_dropout (line 39) | def model_with_nfp_no_dropout():
function data (line 46) | def data():
function check_forward (line 61) | def check_forward(model, atom_data, adj_data):
function test_forward_cpu (line 66) | def test_forward_cpu(model, data):
function test_forward_gpu (line 72) | def test_forward_gpu(model, data):
function test_forward_cpu_with_nfp (line 78) | def test_forward_cpu_with_nfp(model_with_nfp, data):
function test_backward_cpu (line 83) | def test_backward_cpu(model_no_dropout, data):
function test_backward_gpu (line 99) | def test_backward_gpu(model_no_dropout, data):
function test_backward_cpu_with_nfp (line 115) | def test_backward_cpu_with_nfp(model_with_nfp_no_dropout, data):
function test_forward_cpu_graph_invariant (line 127) | def test_forward_cpu_graph_invariant(model, data):
function test_forward_cpu_input_size_invariant (line 143) | def test_forward_cpu_input_size_invariant(model, data):
FILE: tests/models_tests/test_schnet.py
function model (line 17) | def model():
function data (line 22) | def data():
function check_forward (line 38) | def check_forward(model, atom_data, adj_data):
function test_forward_cpu (line 43) | def test_forward_cpu(model, data):
function test_forward_gpu (line 49) | def test_forward_gpu(model, data):
function test_backward_cpu (line 55) | def test_backward_cpu(model, data):
function test_backward_gpu (line 62) | def test_backward_gpu(model, data):
function test_forward_cpu_graph_invariant (line 69) | def test_forward_cpu_graph_invariant(model, data):
FILE: tests/models_tests/test_weavenet.py
function model (line 20) | def model():
function model_processed (line 25) | def model_processed():
function data (line 31) | def data():
function check_forward (line 54) | def check_forward(model, atom_data, adj_data):
function test_forward_cpu (line 60) | def test_forward_cpu(model, model_processed, data):
function test_forward_gpu (line 67) | def test_forward_gpu(model, model_processed, data):
function test_backward_cpu (line 76) | def test_backward_cpu(model, model_processed, data):
function test_backward_gpu (line 86) | def test_backward_gpu(model, model_processed, data):
function _test_forward_cpu_graph_invariant (line 98) | def _test_forward_cpu_graph_invariant(
function test_forward_cpu_graph_invariant_embed (line 118) | def test_forward_cpu_graph_invariant_embed(model, data):
function test_forward_cpu_graph_invariant_processed (line 124) | def test_forward_cpu_graph_invariant_processed(model_processed, data):
FILE: tests/saliency_tests/calculator_tests/test_base_calculator.py
class DummyCalculator (line 13) | class DummyCalculator(BaseCalculator):
method _compute_core (line 16) | def _compute_core(self, *inputs):
class DummyModel (line 21) | class DummyModel(chainer.Chain):
method __init__ (line 22) | def __init__(self):
method forward (line 30) | def forward(self, x):
function model (line 37) | def model():
function test_base_calculator_compute (line 43) | def test_base_calculator_compute(model):
function test_base_calculator_compute_noise_sampler (line 54) | def test_base_calculator_compute_noise_sampler(model):
function test_base_calculator_compute_target_extractor (line 67) | def test_base_calculator_compute_target_extractor(model):
function test_base_calculator_aggregate (line 79) | def test_base_calculator_aggregate():
FILE: tests/saliency_tests/calculator_tests/test_calculator_utils.py
function test_gaussian_noise_sampler (line 8) | def test_gaussian_noise_sampler(mode):
function test_gaussian_noise_sampler_assert_raises (line 16) | def test_gaussian_noise_sampler_assert_raises():
FILE: tests/saliency_tests/calculator_tests/test_gradient_calculator.py
class DummyModel (line 13) | class DummyModel(chainer.Chain):
method __init__ (line 14) | def __init__(self):
method forward (line 21) | def forward(self, x):
function test_gradient_calculator (line 27) | def test_gradient_calculator():
function test_gradient_calculator_multiple_output (line 38) | def test_gradient_calculator_multiple_output():
function test_gradient_calculator_multiply_target (line 51) | def test_gradient_calculator_multiply_target():
function test_gradient_calculator_target_extractor (line 62) | def test_gradient_calculator_target_extractor():
FILE: tests/saliency_tests/calculator_tests/test_integrated_gradient_calculator.py
class DummyModel (line 13) | class DummyModel(chainer.Chain):
method __init__ (line 14) | def __init__(self):
method forward (line 21) | def forward(self, x):
function test_integrated_gradient_calculator (line 27) | def test_integrated_gradient_calculator():
function test_integrated_gradient_calculator_target_extractor (line 38) | def test_integrated_gradient_calculator_target_extractor():
FILE: tests/saliency_tests/calculator_tests/test_occlusion_calculator.py
class DummyModel (line 13) | class DummyModel(chainer.Chain):
method __init__ (line 14) | def __init__(self):
method forward (line 21) | def forward(self, x):
class DummyCNNModel (line 25) | class DummyCNNModel(chainer.Chain):
method __init__ (line 26) | def __init__(self):
method forward (line 33) | def forward(self, x):
function test_occlusion_calculator (line 39) | def test_occlusion_calculator():
function test_occlusion_calculator_cnn (line 50) | def test_occlusion_calculator_cnn():
function test_occlusion_calculator_target_extractor (line 62) | def test_occlusion_calculator_target_extractor():
FILE: tests/saliency_tests/visualizer_tests/test_image_visualizer.py
function test_image_visualizer (line 18) | def test_image_visualizer(tmpdir):
function test_table_visualizer_assert_raises (line 39) | def test_table_visualizer_assert_raises():
FILE: tests/saliency_tests/visualizer_tests/test_mol_visualizer.py
function test_mol_visualizer (line 11) | def test_mol_visualizer(tmpdir):
function test_smiles_visualizer (line 30) | def test_smiles_visualizer(tmpdir):
function test_mol_visualizer_assert_raises (line 57) | def test_mol_visualizer_assert_raises(tmpdir):
FILE: tests/saliency_tests/visualizer_tests/test_table_visualizer.py
function test_table_visualizer (line 17) | def test_table_visualizer(tmpdir):
function test_table_visualizer_assert_raises (line 34) | def test_table_visualizer_assert_raises():
FILE: tests/saliency_tests/visualizer_tests/test_visualizer_utils.py
function test_abs_max_scaler (line 10) | def test_abs_max_scaler():
function test_min_max_scaler (line 23) | def test_min_max_scaler():
function test_normalize_scaler (line 36) | def test_normalize_scaler():
function test_red_blue_cmap (line 49) | def test_red_blue_cmap():
FILE: tests/test_init.py
function test_version (line 7) | def test_version():
FILE: tests/training_tests/extensions_tests/test_auto_print_report.py
class TestAutoPrintReport (line 11) | class TestAutoPrintReport(object):
method _setup (line 12) | def _setup(self, stream=None, delete_flush=False):
method test_stream_with_flush_is_flushed (line 30) | def test_stream_with_flush_is_flushed(self):
method test_stream_without_flush_raises_no_exception (line 37) | def test_stream_without_flush_raises_no_exception(self):
method test_real_stream_raises_no_exception (line 42) | def test_real_stream_raises_no_exception(self):
FILE: tests/training_tests/extensions_tests/test_prc_auc_evaluator.py
function data0 (line 18) | def data0():
function data1 (line 26) | def data1():
function data2 (line 35) | def data2():
class DummyPredictor (line 43) | class DummyPredictor(chainer.Chain):
method __call__ (line 45) | def __call__(self, y):
function test_prc_auc_evaluator (line 50) | def test_prc_auc_evaluator(data0, data1):
function _test_prc_auc_evaluator_default_args (line 55) | def _test_prc_auc_evaluator_default_args(data0):
function _test_prc_auc_evaluator_with_labels (line 78) | def _test_prc_auc_evaluator_with_labels(data1):
function test_prc_auc_evaluator_raise_value_error (line 104) | def test_prc_auc_evaluator_raise_value_error(data2):
function _test_prc_auc_evaluator_raise_error (line 112) | def _test_prc_auc_evaluator_raise_error(data, raise_value_error=True):
FILE: tests/training_tests/extensions_tests/test_r2_score_evaluator.py
function inputs (line 13) | def inputs():
function r2_score (line 27) | def r2_score(pred, true, sample_weight=None, multioutput="uniform_average",
class DummyPredictor (line 57) | class DummyPredictor(chainer.Chain):
method __call__ (line 59) | def __call__(self, y):
function test_r2_score_evaluator (line 64) | def test_r2_score_evaluator(inputs):
function test_r2_score_evaluator_gpu (line 72) | def test_r2_score_evaluator_gpu(inputs):
function _test_r2_score_evaluator (line 83) | def _test_r2_score_evaluator(inputs):
function _test_r2_score_evaluator_ignore_nan (line 103) | def _test_r2_score_evaluator_ignore_nan(inputs):
function _test_r2_score_evaluator_ignore_nan_with_nonnan_value (line 124) | def _test_r2_score_evaluator_ignore_nan_with_nonnan_value(inputs):
function _test_r2_score_evaluator_raw_values (line 145) | def _test_r2_score_evaluator_raw_values(inputs):
FILE: tests/training_tests/extensions_tests/test_roc_auc_evaluator.py
function data0 (line 17) | def data0():
function data1 (line 25) | def data1():
function data2 (line 34) | def data2():
class DummyPredictor (line 42) | class DummyPredictor(chainer.Chain):
method __call__ (line 44) | def __call__(self, y):
function test_roc_auc_evaluator (line 49) | def test_roc_auc_evaluator(data0, data1):
function _test_roc_auc_evaluator_default_args (line 54) | def _test_roc_auc_evaluator_default_args(data0):
function _test_roc_auc_evaluator_with_labels (line 79) | def _test_roc_auc_evaluator_with_labels(data1):
function test_roc_auc_evaluator_raise_value_error (line 107) | def test_roc_auc_evaluator_raise_value_error(data2):
function _test_roc_auc_evaluator_raise_error (line 115) | def _test_roc_auc_evaluator_raise_error(data, raise_value_error=True):
FILE: tests/utils_tests/test_extend.py
function test_extend_node_2d (line 20) | def test_extend_node_2d(x):
function test_extend_node_3d (line 33) | def test_extend_node_3d(x, axis):
function test_extend_node_assert_raises (line 48) | def test_extend_node_assert_raises():
function test_extend_adj (line 54) | def test_extend_adj(adj):
function test_extend_adj_assert_raises (line 63) | def test_extend_adj_assert_raises():
FILE: tests/utils_tests/test_json_utils.py
function test_save_json (line 32) | def test_save_json(tmpdir):
function test_save_json_ignore_error (line 38) | def test_save_json_ignore_error(tmpdir):
function test_load_json (line 49) | def test_load_json(tmpdir):
FILE: tests/utils_tests/test_permutation.py
function test_permute_node_2d (line 17) | def test_permute_node_2d(x):
function test_permute_node_3d (line 32) | def test_permute_node_3d(x, axis):
function test_permute_adj (line 51) | def test_permute_adj(adj):
function test_permute_adj_axis12 (line 62) | def test_permute_adj_axis12():
function test_permute_adj_error (line 75) | def test_permute_adj_error():
FILE: tests/utils_tests/test_sparse_utils.py
function naive_convert (line 12) | def naive_convert(data, row, col, edge_type, num_edge_type):
function test_convert_sparse_with_edge_type (line 47) | def test_convert_sparse_with_edge_type(in_shape, num_edge_type):
FILE: tests/utils_tests/test_train_utils.py
function model (line 22) | def model():
function train_data (line 27) | def train_data():
function valid_data (line 36) | def valid_data():
function test_run_train_cpu (line 44) | def test_run_train_cpu(model, train_data, valid_data):
function test_run_train_cpu_iterator (line 48) | def test_run_train_cpu_iterator(model, train_data, valid_data):
function test_run_train_invalid (line 56) | def test_run_train_invalid(model, train_data):
function test_run_train_gpu (line 62) | def test_run_train_gpu(model, train_data, valid_data):
function test_run_train_chainerx_native (line 71) | def test_run_train_chainerx_native(model, train_data, valid_data):
function test_run_train_chainerx_cuda0 (line 81) | def test_run_train_chainerx_cuda0(model, train_data, valid_data):
Condensed preview — 374 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (1,360K chars).
[
{
"path": ".codecov.yml",
"chars": 300,
"preview": "coverage:\n status:\n # pull-requests only\n # Allow to drop coverage\n project:\n default:\n threshold:"
},
{
"path": ".flexci/config.pbtxt",
"chars": 6210,
"preview": "# DO NOT MODIFY THIS FILE MANUALLY.\n# USE gen_config.py INSTEAD.\n\nconfigs {\n key: \"chainerch.py37.stable.cpu.chx\"\n val"
},
{
"path": ".flexci/gen_config.py",
"chars": 2174,
"preview": "\"\"\"Config generator for Flex CI\nUsage:\n $ python gen_config.py > config.pbtxt\n\"\"\"\n\nfrom __future__ import print_funct"
},
{
"path": ".flexci/pytest_script.sh",
"chars": 2462,
"preview": "#!/bin/bash\nset -eux\n\nBASE=6.0.0\n\nservice docker stop\nmount -t tmpfs -o size=100% tmpfs /var/lib/docker\nservice docker s"
},
{
"path": ".gitignore",
"chars": 1371,
"preview": "# Byte-compiled / optimized / DLL files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# C extensions\n*.so\n\n# Distribution / packagi"
},
{
"path": ".readthedocs.yml",
"chars": 98,
"preview": "name: chainer-chemistry\ntype: sphinx\nbase: docs/source\nconda:\n file: docs/source/environment.yml\n"
},
{
"path": ".travis.yml",
"chars": 1129,
"preview": "sudo: false\nlanguage: python\n\nos: linux\ndist: trusty\npython:\n - 3.6\nenv:\nenv:\n - CHAINER_VERSION=\"chainer==7.0.0\"\n - "
},
{
"path": "LICENSE",
"chars": 1081,
"preview": "MIT License\n\nCopyright (c) 2017 Preferred Networks, Inc.\n\nPermission is hereby granted, free of charge, to any person ob"
},
{
"path": "README.md",
"chars": 13604,
"preview": "# Chainer Chemistry: A Library for Deep Learning in Biology and Chemistry\n\n[\ndef concat_mols(batch, device=None, padding=0):\n \"\"\"Concatenates a list"
},
{
"path": "chainer_chemistry/dataset/converters/megnet_converter.py",
"chars": 1515,
"preview": "import chainer\nfrom chainer.dataset.convert import to_device\n\n\n@chainer.dataset.converter()\ndef megnet_converter(batch, "
},
{
"path": "chainer_chemistry/dataset/graph_dataset/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "chainer_chemistry/dataset/graph_dataset/base_graph_data.py",
"chars": 2209,
"preview": "import numpy\n\nimport chainer\n\n\nclass BaseGraphData(object):\n \"\"\"Base class of graph data \"\"\"\n\n def __init__(self, "
},
{
"path": "chainer_chemistry/dataset/graph_dataset/base_graph_dataset.py",
"chars": 4885,
"preview": "import numpy\n\nimport chainer\nfrom chainer._backend import Device\nfrom chainer_chemistry.dataset.graph_dataset.base_graph"
},
{
"path": "chainer_chemistry/dataset/graph_dataset/feature_converters.py",
"chars": 3913,
"preview": "import numpy\n\nfrom chainer.dataset.convert import _concat_arrays\n\n\ndef batch_with_padding(name, batch, device=None, pad="
},
{
"path": "chainer_chemistry/dataset/indexer.py",
"chars": 6559,
"preview": "import numpy\nimport six\n\n\nclass ExtractBySliceNotSupportedError(Exception):\n pass\n\n\nclass BaseIndexer(object):\n \"\""
},
{
"path": "chainer_chemistry/dataset/indexers/__init__.py",
"chars": 123,
"preview": "from chainer_chemistry.dataset.indexers.numpy_tuple_dataset_feature_indexer import NumpyTupleDatasetFeatureIndexer # NO"
},
{
"path": "chainer_chemistry/dataset/indexers/numpy_tuple_dataset_feature_indexer.py",
"chars": 637,
"preview": "from chainer_chemistry.dataset.indexer import BaseFeatureIndexer\n\n\nclass NumpyTupleDatasetFeatureIndexer(BaseFeatureInde"
},
{
"path": "chainer_chemistry/dataset/networkx_preprocessors/base_networkx.py",
"chars": 5082,
"preview": "import networkx\nimport numpy\n\nimport chainer\nfrom chainer_chemistry.dataset.graph_dataset.base_graph_dataset import Padd"
},
{
"path": "chainer_chemistry/dataset/networkx_preprocessors/reddit_coo.py",
"chars": 1241,
"preview": "import os\n\nimport numpy\nimport scipy\n\nimport chainer\n\nfrom chainer_chemistry.dataset.graph_dataset.base_graph_data impor"
},
{
"path": "chainer_chemistry/dataset/parsers/__init__.py",
"chars": 842,
"preview": "from chainer_chemistry.dataset.parsers import base_parser # NOQA\nfrom chainer_chemistry.dataset.parsers import csv_file"
},
{
"path": "chainer_chemistry/dataset/parsers/base_parser.py",
"chars": 329,
"preview": "class BaseParser(object):\n def __init__(self):\n pass\n\n\nclass BaseFileParser(BaseParser):\n \"\"\"base class for"
},
{
"path": "chainer_chemistry/dataset/parsers/csv_file_parser.py",
"chars": 3157,
"preview": "import pandas\n\nfrom chainer_chemistry.dataset.parsers.data_frame_parser import DataFrameParser\n\n\nclass CSVFileParser(Dat"
},
{
"path": "chainer_chemistry/dataset/parsers/data_frame_parser.py",
"chars": 8218,
"preview": "from logging import getLogger\n\nimport numpy\nfrom rdkit import Chem\nfrom tqdm import tqdm\n\nfrom chainer_chemistry.dataset"
},
{
"path": "chainer_chemistry/dataset/parsers/sdf_file_parser.py",
"chars": 7697,
"preview": "from logging import getLogger\n\nimport numpy\nfrom rdkit import Chem\nfrom tqdm import tqdm\n\nfrom chainer_chemistry.dataset"
},
{
"path": "chainer_chemistry/dataset/parsers/smiles_parser.py",
"chars": 2904,
"preview": "import pandas\n\nfrom chainer_chemistry.dataset.parsers.data_frame_parser import DataFrameParser\n\n\nclass SmilesParser(Data"
},
{
"path": "chainer_chemistry/dataset/preprocessors/__init__.py",
"chars": 3118,
"preview": "from chainer_chemistry.dataset.preprocessors.atomic_number_preprocessor import AtomicNumberPreprocessor # NOQA\nfrom cha"
},
{
"path": "chainer_chemistry/dataset/preprocessors/atomic_number_preprocessor.py",
"chars": 1600,
"preview": "from chainer_chemistry.dataset.preprocessors.common \\\n import construct_atomic_number_array\nfrom chainer_chemistry.da"
},
{
"path": "chainer_chemistry/dataset/preprocessors/base_preprocessor.py",
"chars": 231,
"preview": "\"\"\"\nPreprocessor supports feature extraction for each model (network)\n\"\"\"\n\n\nclass BasePreprocessor(object):\n \"\"\"Base "
},
{
"path": "chainer_chemistry/dataset/preprocessors/cgcnn_preprocessor.py",
"chars": 2026,
"preview": "from logging import getLogger\nimport numpy\nimport os\nimport shutil\n\nfrom chainer.dataset import download\n\nfrom chainer_c"
},
{
"path": "chainer_chemistry/dataset/preprocessors/common.py",
"chars": 8981,
"preview": "\"\"\"Common preprocess method is gethered in this file\"\"\"\nimport numpy\nfrom rdkit import Chem\nfrom rdkit.Chem import rdmol"
},
{
"path": "chainer_chemistry/dataset/preprocessors/ecfp_preprocessor.py",
"chars": 932,
"preview": "from logging import getLogger\n\nimport numpy\nfrom rdkit.Chem import rdMolDescriptors\n\nfrom chainer_chemistry.dataset.prep"
},
{
"path": "chainer_chemistry/dataset/preprocessors/ggnn_preprocessor.py",
"chars": 3847,
"preview": "import numpy\n\nfrom chainer_chemistry.dataset.graph_dataset.base_graph_data import SparseGraphData # NOQA\nfrom chainer_c"
},
{
"path": "chainer_chemistry/dataset/preprocessors/gin_preprocessor.py",
"chars": 4005,
"preview": "import numpy\n\nfrom chainer_chemistry.dataset.graph_dataset.base_graph_data import SparseGraphData # NOQA\nfrom chainer_c"
},
{
"path": "chainer_chemistry/dataset/preprocessors/gnnfilm_preprocessor.py",
"chars": 1992,
"preview": "from chainer_chemistry.dataset.preprocessors.common \\\n import construct_atomic_number_array, construct_discrete_edge_"
},
{
"path": "chainer_chemistry/dataset/preprocessors/gwm_preprocessor.py",
"chars": 1794,
"preview": "from chainer_chemistry.dataset.preprocessors.common import construct_supernode_feature # NOQA\nfrom chainer_chemistry.da"
},
{
"path": "chainer_chemistry/dataset/preprocessors/megnet_preprocessor.py",
"chars": 13308,
"preview": "from logging import getLogger\nimport os\nimport traceback\n\nimport numpy\nfrom rdkit import Chem, RDConfig # NOQA\nfrom rdk"
},
{
"path": "chainer_chemistry/dataset/preprocessors/mol_preprocessor.py",
"chars": 3508,
"preview": "from rdkit import Chem\n\nfrom chainer_chemistry.dataset.preprocessors.base_preprocessor import BasePreprocessor # NOQA\nf"
},
{
"path": "chainer_chemistry/dataset/preprocessors/nfp_preprocessor.py",
"chars": 1938,
"preview": "from chainer_chemistry.dataset.preprocessors.common import construct_adj_matrix\nfrom chainer_chemistry.dataset.preproces"
},
{
"path": "chainer_chemistry/dataset/preprocessors/relgat_preprocessor.py",
"chars": 1894,
"preview": "from chainer_chemistry.dataset.preprocessors.common import construct_atomic_number_array # NOQA\nfrom chainer_chemistry."
},
{
"path": "chainer_chemistry/dataset/preprocessors/relgcn_preprocessor.py",
"chars": 1394,
"preview": "from chainer_chemistry.dataset.preprocessors.ggnn_preprocessor import GGNNPreprocessor, GGNNSparsePreprocessor # NOQA\n\n"
},
{
"path": "chainer_chemistry/dataset/preprocessors/rsgcn_preprocessor.py",
"chars": 2487,
"preview": "from chainer_chemistry.dataset.preprocessors.common import construct_adj_matrix # NOQA\nfrom chainer_chemistry.dataset.p"
},
{
"path": "chainer_chemistry/dataset/preprocessors/schnet_preprocessor.py",
"chars": 3632,
"preview": "from logging import getLogger\nimport traceback\n\nimport numpy\nfrom rdkit.Chem import AllChem\nfrom rdkit.Chem import rdmol"
},
{
"path": "chainer_chemistry/dataset/preprocessors/weavenet_preprocessor.py",
"chars": 12870,
"preview": "import os\n\nimport numpy\nfrom rdkit import Chem\nfrom rdkit.Chem import AllChem\nfrom rdkit.Chem import ChemicalFeatures\nfr"
},
{
"path": "chainer_chemistry/dataset/preprocessors/wle.py",
"chars": 4031,
"preview": "import collections\n\nimport numpy as np\n\nfrom chainer_chemistry.dataset.preprocessors import wle_io\nfrom chainer_chemistr"
},
{
"path": "chainer_chemistry/dataset/preprocessors/wle_atom_array_update.py",
"chars": 5201,
"preview": "import collections\n\nimport numpy as np\n\nfrom chainer_chemistry.dataset.preprocessors import wle_util\n\n\ndef update_atom_a"
},
{
"path": "chainer_chemistry/dataset/preprocessors/wle_io.py",
"chars": 3768,
"preview": "import numpy as np\n\n\nfrom chainer_chemistry.datasets.numpy_tuple_dataset import NumpyTupleDataset\n\n\nDEBUG = False\n\n\ndef "
},
{
"path": "chainer_chemistry/dataset/preprocessors/wle_util.py",
"chars": 1626,
"preview": "import numpy as np\n\n\nDEBUG = False\n\n\ndef _index(atom, values):\n idx = values.index(atom)\n if DEBUG:\n print("
},
{
"path": "chainer_chemistry/dataset/splitters/__init__.py",
"chars": 1191,
"preview": "from chainer_chemistry.dataset.splitters import base_splitter # NOQA\nfrom chainer_chemistry.dataset.splitters import ra"
},
{
"path": "chainer_chemistry/dataset/splitters/base_splitter.py",
"chars": 2054,
"preview": "from chainer_chemistry.datasets.numpy_tuple_dataset import NumpyTupleDataset\n\n\ndef converter_default(dataset, indices):\n"
},
{
"path": "chainer_chemistry/dataset/splitters/deepchem_scaffold_splitter.py",
"chars": 5522,
"preview": "from collections import defaultdict\n\nimport numpy\nfrom rdkit import Chem\nfrom rdkit.Chem.Scaffolds import MurckoScaffold"
},
{
"path": "chainer_chemistry/dataset/splitters/random_splitter.py",
"chars": 5189,
"preview": "import numpy\n\nfrom chainer_chemistry.dataset.splitters.base_splitter import BaseSplitter\n\n\nclass RandomSplitter(BaseSpli"
},
{
"path": "chainer_chemistry/dataset/splitters/scaffold_splitter.py",
"chars": 5076,
"preview": "from collections import defaultdict\n\nimport numpy\nfrom rdkit import Chem\nfrom rdkit.Chem.Scaffolds import MurckoScaffold"
},
{
"path": "chainer_chemistry/dataset/splitters/stratified_splitter.py",
"chars": 8885,
"preview": "import numpy\nimport pandas\n\nfrom chainer_chemistry.dataset.splitters.base_splitter import BaseSplitter\nfrom chainer_chem"
},
{
"path": "chainer_chemistry/dataset/splitters/time_splitter.py",
"chars": 4566,
"preview": "import numpy\n\nfrom chainer_chemistry.dataset.splitters.base_splitter import BaseSplitter\n\n\nclass TimeSplitter(BaseSplitt"
},
{
"path": "chainer_chemistry/dataset/utils.py",
"chars": 1591,
"preview": "import numpy\n\n\nclass GaussianDistance(object):\n \"\"\"Expand distance with Gaussian basis sit at centers and with width "
},
{
"path": "chainer_chemistry/datasets/__init__.py",
"chars": 949,
"preview": "from chainer_chemistry.datasets import molnet # NOQA\nfrom chainer_chemistry.datasets import qm9 # NOQA\nfrom chainer_ch"
},
{
"path": "chainer_chemistry/datasets/citation_network/citation.py",
"chars": 1517,
"preview": "import os\n\nimport networkx as nx\nimport numpy\nfrom tqdm import tqdm\n\n\ndef citation_to_networkx(dirpath, name):\n G = n"
},
{
"path": "chainer_chemistry/datasets/citation_network/citeseer.py",
"chars": 3102,
"preview": "from logging import getLogger\nimport os\nimport tarfile\nfrom typing import List, Tuple # NOQA\n\nfrom chainer.dataset impo"
},
{
"path": "chainer_chemistry/datasets/citation_network/cora.py",
"chars": 3122,
"preview": "from logging import getLogger\nimport os\nimport tarfile\nfrom typing import List, Tuple # NOQA\n\nfrom chainer.dataset impo"
},
{
"path": "chainer_chemistry/datasets/molnet/__init__.py",
"chars": 762,
"preview": "from chainer_chemistry.datasets.molnet import chembl_tasks # NOQA\nfrom chainer_chemistry.datasets.molnet import molnet "
},
{
"path": "chainer_chemistry/datasets/molnet/chembl_tasks.py",
"chars": 6892,
"preview": "# flake8: noqa\n\nchembl_tasks = [\n 'CHEMBL1075104', 'CHEMBL1075228', 'CHEMBL1075284', 'CHEMBL1163101',\n 'CHEMBL1163"
},
{
"path": "chainer_chemistry/datasets/molnet/molnet.py",
"chars": 22081,
"preview": "import joblib\nfrom logging import getLogger\nimport os\nimport shutil\nimport tarfile\n\nimport numpy\nimport pandas\n\nfrom cha"
},
{
"path": "chainer_chemistry/datasets/molnet/molnet_config.py",
"chars": 15167,
"preview": "import chainer.functions as F\nimport chainer_chemistry\n\nfrom chainer_chemistry.datasets.molnet.chembl_tasks import chemb"
},
{
"path": "chainer_chemistry/datasets/molnet/pdbbind_time.py",
"chars": 2116,
"preview": "from logging import getLogger\nimport os\nimport shutil\n\nimport pandas\n\nfrom chainer.dataset import download\n\n\ndef get_pdb"
},
{
"path": "chainer_chemistry/datasets/molnet/toxcast_tasks.py",
"chars": 16231,
"preview": "# flake8: noqa\n\ntoxcast_tasks = ['ACEA_T47D_80hr_Negative', 'ACEA_T47D_80hr_Positive',\n 'APR_HepG2_CellCycleArrest"
},
{
"path": "chainer_chemistry/datasets/numpy_tuple_dataset.py",
"chars": 3579,
"preview": "import os\nimport six\n\nimport numpy\n\nfrom chainer_chemistry.dataset.converters import concat_mols\nfrom chainer_chemistry."
},
{
"path": "chainer_chemistry/datasets/qm9.py",
"chars": 4292,
"preview": "import glob\nfrom logging import getLogger\nimport os\nimport shutil\nimport tarfile\nimport tempfile\n\nfrom chainer.dataset i"
},
{
"path": "chainer_chemistry/datasets/reddit/reddit.py",
"chars": 3487,
"preview": "from logging import getLogger\nimport os\nfrom zipfile import ZipFile\n\nimport networkx as nx\nimport numpy\nimport scipy\n\nfr"
},
{
"path": "chainer_chemistry/datasets/tox21.py",
"chars": 6579,
"preview": "from logging import getLogger\nimport os\nimport shutil\nimport zipfile\n\nfrom chainer.dataset import download\nimport numpy\n"
},
{
"path": "chainer_chemistry/datasets/zinc.py",
"chars": 3865,
"preview": "from logging import getLogger\nimport os\n\nfrom chainer.dataset import download\nimport numpy\nimport pandas\n\nfrom chainer_c"
},
{
"path": "chainer_chemistry/functions/__init__.py",
"chars": 846,
"preview": "from chainer_chemistry.functions.activation.megnet_softplus import megnet_softplus # NOQA\nfrom chainer_chemistry.functi"
},
{
"path": "chainer_chemistry/functions/activation/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "chainer_chemistry/functions/activation/megnet_softplus.py",
"chars": 516,
"preview": "from chainer import functions\n\n\ndef megnet_softplus(x):\n \"\"\"Modified softplus function used by MEGNet\n\n The origin"
},
{
"path": "chainer_chemistry/functions/activation/shifted_softplus.py",
"chars": 665,
"preview": "import chainer\nfrom chainer import functions\n\n\ndef shifted_softplus(x, beta=1, shift=0.5, threshold=20):\n \"\"\"shifted "
},
{
"path": "chainer_chemistry/functions/activation/softmax.py",
"chars": 1042,
"preview": "from chainer import functions\n\n\ndef softmax(x, axis=1, mask=None, mask_value=1e10):\n \"\"\"softmax function, which suppo"
},
{
"path": "chainer_chemistry/functions/evaluation/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "chainer_chemistry/functions/evaluation/r2_score.py",
"chars": 2886,
"preview": "from chainer.backends import cuda\nfrom chainer import function\nfrom chainer.utils import type_check\n\n\nclass R2Score(func"
},
{
"path": "chainer_chemistry/functions/loss/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "chainer_chemistry/functions/loss/mean_absolute_error.py",
"chars": 2612,
"preview": "import numpy\n\nimport chainer\nfrom chainer.backends import cuda\nfrom chainer import function_node\nfrom chainer.utils impo"
},
{
"path": "chainer_chemistry/functions/loss/mean_squared_error.py",
"chars": 2786,
"preview": "import numpy\n\nfrom chainer import cuda\nfrom chainer import function_node\nimport chainer.functions\nfrom chainer.utils imp"
},
{
"path": "chainer_chemistry/functions/math/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "chainer_chemistry/functions/math/matmul.py",
"chars": 1557,
"preview": "import chainer\n\n\nif int(chainer.__version__[0]) >= 3:\n _matmul_fn = chainer.functions.matmul\nelse:\n _matmul_fn = c"
},
{
"path": "chainer_chemistry/iterators/__init__.py",
"chars": 173,
"preview": "from chainer_chemistry.iterators.balanced_serial_iterator import BalancedSerialIterator # NOQA\nfrom chainer_chemistry.i"
},
{
"path": "chainer_chemistry/iterators/balanced_serial_iterator.py",
"chars": 6789,
"preview": "from __future__ import division\n\nfrom logging import getLogger\n\nfrom chainer.dataset import iterator\nimport numpy\n\nfrom "
},
{
"path": "chainer_chemistry/iterators/index_iterator.py",
"chars": 2844,
"preview": "import numpy\n\nfrom chainer.dataset import iterator\n\n\nclass IndexIterator(iterator.Iterator):\n \"\"\"Index iterator\n\n "
},
{
"path": "chainer_chemistry/link_hooks/__init__.py",
"chars": 434,
"preview": "try:\n from chainer_chemistry.link_hooks import variable_monitor_link_hook # NOQA\n\n from chainer_chemistry.link_ho"
},
{
"path": "chainer_chemistry/link_hooks/variable_monitor_link_hook.py",
"chars": 6241,
"preview": "from collections import OrderedDict\nfrom logging import getLogger\n\nimport chainer\nfrom chainer.link_hook import _Forward"
},
{
"path": "chainer_chemistry/links/__init__.py",
"chars": 1637,
"preview": "from chainer_chemistry.links.connection.embed_atom_id import EmbedAtomID # NOQA\nfrom chainer_chemistry.links.connection"
},
{
"path": "chainer_chemistry/links/array/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "chainer_chemistry/links/array/shape_transformer_to_2d.py",
"chars": 1945,
"preview": "import chainer\nfrom chainer import functions\n\n\nclass ShapeTransformerTo2D(chainer.Link):\n \"\"\"Transforms input array `"
},
{
"path": "chainer_chemistry/links/connection/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "chainer_chemistry/links/connection/embed_atom_id.py",
"chars": 1763,
"preview": "import chainer\nfrom chainer_chemistry.config import MAX_ATOMIC_NUM\n\n\nclass EmbedAtomID(chainer.links.EmbedID):\n \"\"\"Em"
},
{
"path": "chainer_chemistry/links/connection/graph_linear.py",
"chars": 1275,
"preview": "import chainer\n\n\nclass GraphLinear(chainer.links.Linear):\n \"\"\"Graph Linear layer.\n\n This function assumes its inpu"
},
{
"path": "chainer_chemistry/links/connection/graph_mlp.py",
"chars": 1309,
"preview": "import numpy\n\nimport chainer\nfrom chainer.functions import relu\n\nfrom chainer_chemistry.links.connection.graph_linear im"
},
{
"path": "chainer_chemistry/links/normalization/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "chainer_chemistry/links/normalization/graph_batch_normalization.py",
"chars": 1657,
"preview": "import chainer\n\n\nclass GraphBatchNormalization(chainer.links.BatchNormalization):\n \"\"\"Graph Batch Normalization layer"
},
{
"path": "chainer_chemistry/links/readout/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "chainer_chemistry/links/readout/cgcnn_readout.py",
"chars": 682,
"preview": "import chainer\nfrom chainer import functions, links # NOQA\n\n\nclass CGCNNReadout(chainer.Chain):\n \"\"\"CGCNN submodule "
},
{
"path": "chainer_chemistry/links/readout/general_readout.py",
"chars": 2115,
"preview": "import chainer\nfrom chainer import functions\n\n\nclass GeneralReadout(chainer.Link):\n \"\"\"General submodule for readout "
},
{
"path": "chainer_chemistry/links/readout/ggnn_readout.py",
"chars": 2111,
"preview": "import chainer\nfrom chainer import functions\n\nfrom chainer_chemistry.links.connection.graph_linear import GraphLinear\n\n\n"
},
{
"path": "chainer_chemistry/links/readout/megnet_readout.py",
"chars": 2258,
"preview": "import chainer\nfrom chainer import functions, links # NOQA\n\n\nfrom chainer_chemistry.functions import megnet_softplus\nfr"
},
{
"path": "chainer_chemistry/links/readout/mpnn_readout.py",
"chars": 1627,
"preview": "import chainer\nfrom chainer import functions\nfrom chainer import links\n\nfrom chainer_chemistry.links.readout.set2set imp"
},
{
"path": "chainer_chemistry/links/readout/nfp_readout.py",
"chars": 1215,
"preview": "import chainer\nfrom chainer import functions\n\nfrom chainer_chemistry.links.connection.graph_linear import GraphLinear\n\n\n"
},
{
"path": "chainer_chemistry/links/readout/scatter_ggnn_readout.py",
"chars": 2538,
"preview": "import numpy\n\nimport chainer\nfrom chainer import functions\n\n\nclass ScatterGGNNReadout(chainer.Chain):\n \"\"\"GGNN submod"
},
{
"path": "chainer_chemistry/links/readout/schnet_readout.py",
"chars": 1034,
"preview": "import chainer\nfrom chainer import functions\n\nfrom chainer_chemistry.functions import shifted_softplus\nfrom chainer_chem"
},
{
"path": "chainer_chemistry/links/readout/set2set.py",
"chars": 2406,
"preview": "from typing import List, Optional # NOQA\n\nimport chainer\nfrom chainer import cuda\nfrom chainer import functions\nfrom ch"
},
{
"path": "chainer_chemistry/links/scaler/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "chainer_chemistry/links/scaler/base.py",
"chars": 1071,
"preview": "import chainer\n\n\ndef to_array(x):\n \"\"\"Convert x into numpy.ndarray or cupy.ndarray\"\"\"\n if isinstance(x, chainer.Va"
},
{
"path": "chainer_chemistry/links/scaler/flow_scaler.py",
"chars": 6583,
"preview": "import numpy\n\nimport chainer\n\nfrom chainer_chemistry.links.scaler.base import BaseScaler, to_array # NOQA\n\n\ndef _sigmoi"
},
{
"path": "chainer_chemistry/links/scaler/max_abs_scaler.py",
"chars": 3579,
"preview": "from logging import getLogger\n\nimport numpy\n\nfrom chainer import cuda, Variable # NOQA\n\nfrom chainer_chemistry.links.sc"
},
{
"path": "chainer_chemistry/links/scaler/min_max_scaler.py",
"chars": 3895,
"preview": "from logging import getLogger\n\nimport numpy\n\nfrom chainer import cuda, Variable # NOQA\n\nfrom chainer_chemistry.links.sc"
},
{
"path": "chainer_chemistry/links/scaler/standard_scaler.py",
"chars": 4076,
"preview": "from logging import getLogger\n\nimport numpy\n\nfrom chainer import cuda, Variable # NOQA\n\nfrom chainer_chemistry.links.sc"
},
{
"path": "chainer_chemistry/links/update/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "chainer_chemistry/links/update/cgcnn_update.py",
"chars": 1555,
"preview": "import chainer\nfrom chainer import links, functions # NOQA\n\n\nclass CGCNNUpdate(chainer.Chain):\n \"\"\"Update submodule "
},
{
"path": "chainer_chemistry/links/update/ggnn_update.py",
"chars": 2826,
"preview": "import chainer\nfrom chainer import functions\nfrom chainer import links\n\nimport chainer_chemistry\nfrom chainer_chemistry."
},
{
"path": "chainer_chemistry/links/update/gin_update.py",
"chars": 4120,
"preview": "import chainer\nfrom chainer import functions\n\nimport chainer_chemistry\nfrom chainer_chemistry.links import GraphMLP\n\n\ncl"
},
{
"path": "chainer_chemistry/links/update/gnn_film_update.py",
"chars": 2599,
"preview": "import chainer\nfrom chainer import functions\nfrom chainer import links\n\nfrom chainer_chemistry.links.connection.graph_li"
},
{
"path": "chainer_chemistry/links/update/megnet_update.py",
"chars": 6332,
"preview": "import chainer\nfrom chainer import functions, links # NOQA\n\n\nfrom chainer_chemistry.functions import megnet_softplus\n\n\n"
},
{
"path": "chainer_chemistry/links/update/mpnn_update.py",
"chars": 4909,
"preview": "import chainer\nfrom chainer import functions\nfrom chainer import links\n\nimport chainer_chemistry\n\n\nclass MPNNUpdate(chai"
},
{
"path": "chainer_chemistry/links/update/nfp_update.py",
"chars": 1812,
"preview": "import chainer\nfrom chainer import functions\nimport numpy\n\nimport chainer_chemistry\nfrom chainer_chemistry.links.connect"
},
{
"path": "chainer_chemistry/links/update/relgat_update.py",
"chars": 6717,
"preview": "import chainer\nfrom chainer import functions\n\nfrom chainer_chemistry.links.connection.graph_linear import GraphLinear\n\n\n"
},
{
"path": "chainer_chemistry/links/update/relgcn_update.py",
"chars": 2713,
"preview": "import chainer\nfrom chainer import functions\n\nfrom chainer_chemistry.links.connection.graph_linear import GraphLinear\n\n\n"
},
{
"path": "chainer_chemistry/links/update/rsgcn_update.py",
"chars": 860,
"preview": "import chainer\n\nimport chainer_chemistry\nfrom chainer_chemistry.links.connection.graph_linear import GraphLinear\n\n\nclass"
},
{
"path": "chainer_chemistry/links/update/schnet_update.py",
"chars": 3558,
"preview": "\"\"\"\nChainer implementation of CFConv.\n\nSchNet: A continuous-filter convolutional neural network for modeling\n quantum"
},
{
"path": "chainer_chemistry/models/__init__.py",
"chars": 2822,
"preview": "from chainer_chemistry.models import ggnn # NOQA\nfrom chainer_chemistry.models import gin # NOQA\nfrom chainer_chemistr"
},
{
"path": "chainer_chemistry/models/cgcnn.py",
"chars": 1483,
"preview": "import chainer\nfrom chainer import links\n\nfrom chainer_chemistry.links.readout.cgcnn_readout import CGCNNReadout\nfrom ch"
},
{
"path": "chainer_chemistry/models/cwle/__init__.py",
"chars": 722,
"preview": "#from chainer_chemistry.models.cwle import cwle\nfrom chainer_chemistry.models.cwle import cwle_graph_conv_model\nfrom cha"
},
{
"path": "chainer_chemistry/models/cwle/cwle_graph_conv_model.py",
"chars": 9188,
"preview": "import chainer\nfrom chainer import cuda\nfrom chainer import links\nfrom chainer import functions\n\nfrom chainer_chemistry."
},
{
"path": "chainer_chemistry/models/cwle/cwle_net.py",
"chars": 6684,
"preview": "from chainer import functions\n\nfrom chainer_chemistry.config import MAX_ATOMIC_NUM\nfrom chainer_chemistry.links import G"
},
{
"path": "chainer_chemistry/models/ggnn.py",
"chars": 5784,
"preview": "import chainer\nfrom chainer import functions, cuda # NOQA\n\nfrom chainer_chemistry.config import MAX_ATOMIC_NUM\nfrom cha"
},
{
"path": "chainer_chemistry/models/gin.py",
"chars": 8214,
"preview": "import chainer\nfrom chainer import functions, cuda # NOQA\n\nfrom chainer_chemistry.config import MAX_ATOMIC_NUM\nfrom cha"
},
{
"path": "chainer_chemistry/models/gnn_film.py",
"chars": 4581,
"preview": "import chainer\nfrom chainer import cuda\nfrom chainer import functions\n\nfrom chainer_chemistry.config import MAX_ATOMIC_N"
},
{
"path": "chainer_chemistry/models/gwle/__init__.py",
"chars": 581,
"preview": "#from chainer_chemistry.models.cwle import cwle\nfrom chainer_chemistry.models.gwle import gwle_graph_conv_model\nfrom cha"
},
{
"path": "chainer_chemistry/models/gwle/gwle_graph_conv_model.py",
"chars": 9313,
"preview": "import chainer\nfrom chainer import cuda\nfrom chainer import links\nfrom chainer import functions\n\nfrom chainer_chemistry."
},
{
"path": "chainer_chemistry/models/gwle/gwle_net.py",
"chars": 6684,
"preview": "from chainer import functions\n\nfrom chainer_chemistry.config import MAX_ATOMIC_NUM\nfrom chainer_chemistry.links import G"
},
{
"path": "chainer_chemistry/models/gwm/__init__.py",
"chars": 589,
"preview": "from chainer_chemistry.models.gwm import gwm # NOQA\nfrom chainer_chemistry.models.gwm import gwm_graph_conv_model # NO"
},
{
"path": "chainer_chemistry/models/gwm/gwm.py",
"chars": 11732,
"preview": "import chainer\nfrom chainer import functions\nfrom chainer import links\n\nfrom chainer_chemistry.links import GraphLinear\n"
},
{
"path": "chainer_chemistry/models/gwm/gwm_graph_conv_model.py",
"chars": 9446,
"preview": "import chainer\nfrom chainer import cuda\nfrom chainer import functions\nfrom chainer import links\n\nfrom chainer_chemistry."
},
{
"path": "chainer_chemistry/models/gwm/gwm_net.py",
"chars": 4390,
"preview": "from chainer import functions\n\nfrom chainer_chemistry.config import MAX_ATOMIC_NUM\nfrom chainer_chemistry.links import G"
},
{
"path": "chainer_chemistry/models/megnet.py",
"chars": 2925,
"preview": "import chainer\nfrom chainer.backend import get_array_module\nfrom chainer import functions\n\nfrom chainer_chemistry.functi"
},
{
"path": "chainer_chemistry/models/mlp.py",
"chars": 1095,
"preview": "import chainer\nfrom chainer.functions import relu\nfrom chainer import links\n\n\nclass MLP(chainer.Chain):\n\n \"\"\"Basic im"
},
{
"path": "chainer_chemistry/models/mpnn.py",
"chars": 5766,
"preview": "from functools import partial\nfrom typing import Optional # NOQA\n\nimport chainer\nfrom chainer import cuda, functions #"
},
{
"path": "chainer_chemistry/models/nfp.py",
"chars": 4066,
"preview": "import chainer\nfrom chainer import Variable, functions # NOQA\n\nfrom chainer_chemistry.config import MAX_ATOMIC_NUM\nfrom"
},
{
"path": "chainer_chemistry/models/prediction/__init__.py",
"chars": 690,
"preview": "from chainer_chemistry.models.prediction import base # NOQA\nfrom chainer_chemistry.models.prediction import classifier "
},
{
"path": "chainer_chemistry/models/prediction/base.py",
"chars": 7436,
"preview": "import pickle\n\nimport numpy\n\nimport chainer\nfrom chainer import cuda\nfrom chainer.dataset.convert import concat_examples"
},
{
"path": "chainer_chemistry/models/prediction/classifier.py",
"chars": 11388,
"preview": "import warnings\n\nimport numpy\n\nimport chainer\nfrom chainer.dataset.convert import concat_examples\nfrom chainer.functions"
},
{
"path": "chainer_chemistry/models/prediction/graph_conv_predictor.py",
"chars": 2256,
"preview": "from typing import Optional # NOQA\n\nimport chainer\nimport numpy # NOQA\n\n\nclass GraphConvPredictor(chainer.Chain):\n "
},
{
"path": "chainer_chemistry/models/prediction/node_classifier.py",
"chars": 1803,
"preview": "from chainer import reporter\nfrom chainer_chemistry.models.prediction.classifier import Classifier\n\n\nclass NodeClassifie"
},
{
"path": "chainer_chemistry/models/prediction/regressor.py",
"chars": 7314,
"preview": "import numpy\n\nimport chainer\nfrom chainer.dataset.convert import concat_examples\nfrom chainer import cuda, Variable # N"
},
{
"path": "chainer_chemistry/models/prediction/set_up_predictor.py",
"chars": 12003,
"preview": "from typing import Any # NOQA\nfrom typing import Dict # NOQA\nfrom typing import Optional # NOQA\n\nimport chainer # NO"
},
{
"path": "chainer_chemistry/models/relgat.py",
"chars": 5357,
"preview": "# -*- coding: utf-8 -*-\nimport chainer\nfrom chainer import functions, cuda # NOQA\n\nfrom chainer_chemistry.config import"
},
{
"path": "chainer_chemistry/models/relgcn.py",
"chars": 7287,
"preview": "import chainer\nfrom chainer import functions, cuda # NOQA\n\nfrom chainer.links import Linear\nfrom chainer_chemistry.conf"
},
{
"path": "chainer_chemistry/models/rsgcn.py",
"chars": 4619,
"preview": "import chainer\nfrom chainer import functions, Variable # NOQA\n\nimport chainer_chemistry\nfrom chainer_chemistry.config i"
},
{
"path": "chainer_chemistry/models/schnet.py",
"chars": 2825,
"preview": "import chainer\nfrom chainer import functions\n\nfrom chainer_chemistry.config import MAX_ATOMIC_NUM\nfrom chainer_chemistry"
},
{
"path": "chainer_chemistry/models/weavenet.py",
"chars": 7235,
"preview": "import chainer\nfrom chainer import functions\nfrom chainer import links\n\nfrom chainer_chemistry.config import MAX_ATOMIC_"
},
{
"path": "chainer_chemistry/saliency/__init__.py",
"chars": 116,
"preview": "from chainer_chemistry.saliency import calculator # NOQA\nfrom chainer_chemistry.saliency import visualizer # NOQA\n"
},
{
"path": "chainer_chemistry/saliency/calculator/__init__.py",
"chars": 899,
"preview": "from chainer_chemistry.saliency.calculator import base_calculator # NOQA\nfrom chainer_chemistry.saliency.calculator imp"
},
{
"path": "chainer_chemistry/saliency/calculator/base_calculator.py",
"chars": 12804,
"preview": "from logging import getLogger\n\nimport numpy\n\nimport chainer\nfrom chainer import cuda\nfrom chainer.dataset.convert import"
},
{
"path": "chainer_chemistry/saliency/calculator/calculator_utils.py",
"chars": 1062,
"preview": "from chainer import cuda\n\n\nclass GaussianNoiseSampler(object):\n \"\"\"Default noise sampler class to calculate SmoothGra"
},
{
"path": "chainer_chemistry/saliency/calculator/gradient_calculator.py",
"chars": 2708,
"preview": "import chainer # NOQA\nfrom chainer import functions\nfrom chainer_chemistry.saliency.calculator.base_calculator import B"
},
{
"path": "chainer_chemistry/saliency/calculator/integrated_gradients_calculator.py",
"chars": 3172,
"preview": "import numpy\n\nfrom chainer_chemistry.saliency.calculator.gradient_calculator import GradientCalculator # NOQA\n\n\nclass I"
},
{
"path": "chainer_chemistry/saliency/calculator/occlusion_calculator.py",
"chars": 5639,
"preview": "import itertools\nimport six\n\nimport chainer\nfrom chainer import cuda\n\nfrom chainer_chemistry.saliency.calculator.base_ca"
},
{
"path": "chainer_chemistry/saliency/visualizer/__init__.py",
"chars": 1183,
"preview": "from chainer_chemistry.saliency.visualizer import base_visualizer # NOQA\nfrom chainer_chemistry.saliency.visualizer imp"
},
{
"path": "chainer_chemistry/saliency/visualizer/base_visualizer.py",
"chars": 254,
"preview": "class BaseVisualizer(object):\n\n \"\"\"Base saliency visualizer\"\"\"\n\n def visualize(self, *args, **kwargs):\n \"\"\""
},
{
"path": "chainer_chemistry/saliency/visualizer/image_visualizer.py",
"chars": 3872,
"preview": "from logging import getLogger\n\nimport matplotlib.cm as cm\nimport matplotlib.pyplot as plt\nimport numpy\n\nfrom chainer imp"
},
{
"path": "chainer_chemistry/saliency/visualizer/mol_visualizer.py",
"chars": 7122,
"preview": "from logging import getLogger\n\nimport numpy\n\nfrom rdkit import Chem\nfrom rdkit.Chem.Draw import rdMolDraw2D\nfrom rdkit.C"
},
{
"path": "chainer_chemistry/saliency/visualizer/table_visualizer.py",
"chars": 3289,
"preview": "import matplotlib.pyplot as plt\nimport numpy\n\nfrom chainer_chemistry.saliency.visualizer.base_visualizer import BaseVisu"
},
{
"path": "chainer_chemistry/saliency/visualizer/visualizer_utils.py",
"chars": 2471,
"preview": "from logging import getLogger\nimport numpy # NOQA\n\nfrom chainer import cuda\n\n\ndef red_blue_cmap(x):\n \"\"\"Red to Blue "
},
{
"path": "chainer_chemistry/training/__init__.py",
"chars": 58,
"preview": "from chainer_chemistry.training import extensions # NOQA\n"
},
{
"path": "chainer_chemistry/training/extensions/__init__.py",
"chars": 531,
"preview": "from chainer_chemistry.training.extensions import batch_evaluator # NOQA\nfrom chainer_chemistry.training.extensions imp"
},
{
"path": "chainer_chemistry/training/extensions/auto_print_report.py",
"chars": 4790,
"preview": "from copy import deepcopy\nimport os\nimport sys\n\nfrom chainer.training import extension\nfrom chainer.training.extensions "
},
{
"path": "chainer_chemistry/training/extensions/batch_evaluator.py",
"chars": 2707,
"preview": "import copy\nfrom logging import getLogger\n\nimport numpy\n\nimport chainer\nfrom chainer import cuda\nfrom chainer.dataset im"
},
{
"path": "chainer_chemistry/training/extensions/prc_auc_evaluator.py",
"chars": 4423,
"preview": "import numpy\n\nfrom chainer.dataset import convert\nfrom sklearn import metrics\n\nfrom chainer_chemistry.training.extension"
},
{
"path": "chainer_chemistry/training/extensions/r2_score_evaluator.py",
"chars": 4863,
"preview": "from chainer.backends import cuda\nfrom chainer.dataset import convert\n\nfrom chainer_chemistry.training.extensions.batch_"
},
{
"path": "chainer_chemistry/training/extensions/roc_auc_evaluator.py",
"chars": 4522,
"preview": "import numpy\n\nfrom chainer.dataset import convert\nfrom sklearn import metrics\n\nfrom chainer_chemistry.training.extension"
},
{
"path": "chainer_chemistry/utils/__init__.py",
"chars": 350,
"preview": "from chainer_chemistry.utils.json_utils import load_json # NOQA\nfrom chainer_chemistry.utils.json_utils import save_jso"
},
{
"path": "chainer_chemistry/utils/extend.py",
"chars": 3569,
"preview": "from collections import Iterable\nfrom logging import getLogger\nimport six\n\nfrom chainer import cuda\n\n\ndef _to_list(a):\n "
},
{
"path": "chainer_chemistry/utils/json_utils.py",
"chars": 2211,
"preview": "import json\nfrom logging import getLogger\nimport numpy\ntry:\n from pathlib import PurePath\n _is_pathlib_available ="
},
{
"path": "chainer_chemistry/utils/permutation.py",
"chars": 2519,
"preview": "import numpy\n\n\ndef permute_node(node, permutation_index, axis=-1):\n \"\"\"Permute index of `node` array\n\n Args:\n "
},
{
"path": "chainer_chemistry/utils/sparse_utils.py",
"chars": 4096,
"preview": "import chainer\nfrom chainer import cuda\nimport numpy as np\n\ntry:\n from chainer.utils import CooMatrix\n _coomatrix_"
},
{
"path": "chainer_chemistry/utils/train_utils.py",
"chars": 5302,
"preview": "import chainer\nfrom chainer import optimizers, training, Optimizer # NOQA\nfrom chainer._backend import Device\nfrom chai"
},
{
"path": "docker/conda/python36/Dockerfile",
"chars": 1163,
"preview": "FROM nvidia/cuda:10.1-cudnn7-devel\nRUN apt-get update -y && \\\n apt-get install -y --no-install-recommends \\\n git \\"
},
{
"path": "docker/conda/python36/conda-entrypoint.sh",
"chars": 78,
"preview": "#!/bin/bash\n. /opt/conda/etc/profile.d/conda.sh\nconda activate py36\nexec \"$@\"\n"
},
{
"path": "docker/conda/python37/Dockerfile",
"chars": 1163,
"preview": "FROM nvidia/cuda:10.1-cudnn7-devel\nRUN apt-get update -y && \\\n apt-get install -y --no-install-recommends \\\n git \\"
},
{
"path": "docker/conda/python37/conda-entrypoint.sh",
"chars": 78,
"preview": "#!/bin/bash\n. /opt/conda/etc/profile.d/conda.sh\nconda activate py37\nexec \"$@\"\n"
},
{
"path": "docker/conda/python37-chainerx-cpu-base/Dockerfile",
"chars": 1243,
"preview": "FROM nvidia/cuda:10.1-cudnn7-devel\nRUN apt-get update -y && \\\n apt-get install -y --no-install-recommends \\\n git \\"
},
{
"path": "docker/conda/python37-chainerx-cpu-base/conda-entrypoint.sh",
"chars": 78,
"preview": "#!/bin/bash\n. /opt/conda/etc/profile.d/conda.sh\nconda activate py37\nexec \"$@\"\n"
},
{
"path": "docker/conda/python37-chainerx-cpu-latest/Dockerfile",
"chars": 1245,
"preview": "FROM nvidia/cuda:10.1-cudnn7-devel\nRUN apt-get update -y && \\\n apt-get install -y --no-install-recommends \\\n git \\"
},
{
"path": "docker/conda/python37-chainerx-cpu-latest/conda-entrypoint.sh",
"chars": 78,
"preview": "#!/bin/bash\n. /opt/conda/etc/profile.d/conda.sh\nconda activate py37\nexec \"$@\"\n"
},
{
"path": "docker/conda/python37-chainerx-cpu-stable/Dockerfile",
"chars": 1243,
"preview": "FROM nvidia/cuda:10.1-cudnn7-devel\nRUN apt-get update -y && \\\n apt-get install -y --no-install-recommends \\\n git \\"
},
{
"path": "docker/conda/python37-chainerx-cpu-stable/conda-entrypoint.sh",
"chars": 78,
"preview": "#!/bin/bash\n. /opt/conda/etc/profile.d/conda.sh\nconda activate py37\nexec \"$@\"\n"
},
{
"path": "docker/conda/python37-chainerx-gpu-base/Dockerfile",
"chars": 1285,
"preview": "FROM nvidia/cuda:10.1-cudnn7-devel\nRUN apt-get update -y && \\\n apt-get install -y --no-install-recommends \\\n git \\"
},
{
"path": "docker/conda/python37-chainerx-gpu-base/conda-entrypoint.sh",
"chars": 78,
"preview": "#!/bin/bash\n. /opt/conda/etc/profile.d/conda.sh\nconda activate py37\nexec \"$@\"\n"
}
]
// ... and 174 more files (download for full content)
About this extraction
This page contains the full source code of the chainer/chainer-chemistry GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 374 files (1.2 MB), approximately 340.6k tokens, and a symbol index with 1707 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.