How to use the megnet.data.graph.GaussianDistance function in megnet

To help you get started, we’ve selected a few megnet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hackingmaterials / automatminer / automatminer_dev / graphnet / megnet.py View on Github external
k_folds = list(map(int, args.k_folds.split(",")))
    print("args is : {}".format(args))

    print(
        "Local devices are : {}, \n\n Available gpus are : {}".format(
            device_lib.list_local_devices(), K.tensorflow_backend._get_available_gpus()
        )
    )

    # prepare output path
    if not os.path.exists(output_path):
        os.makedirs(output_path, exist_ok=True)

    # Get a crystal graph with cutoff radius A
    cg = CrystalGraph(
        bond_convertor=GaussianDistance(np.linspace(0, radius + 1, 100), 0.5),
        cutoff=radius,
    )

    if graph_file is not None:
        # load graph data
        with gzip.open(graph_file, "rb") as f:
            valid_graph_dict = pickle.load(f)
        idx_list = list(range(len(valid_graph_dict)))
        valid_idx_list = [
            idx for idx, graph in valid_graph_dict.items() if graph is not None
        ]
    else:
        # load structure data
        with gzip.open(args.input_file, "rb") as f:
            df = pd.DataFrame(pickle.load(f))[["structure", prop_col]]
        idx_list = list(range(len(df)))
github materialsvirtuallab / megnet / megnet / data / crystal.py View on Github external
def __init__(self,
                 nn_strategy='MinimumDistanceNNAll',
                 atom_converter=None,
                 bond_converter=None,
                 cutoff=4.0
                 ):
        if bond_converter is None:
            bond_converter = GaussianDistance(np.linspace(0, 5, 100), 0.5)
        self.cutoff = cutoff
        super().__init__(nn_strategy=nn_strategy, atom_converter=atom_converter,
                         bond_converter=bond_converter, cutoff=self.cutoff)
github materialsvirtuallab / megnet / megnet / data / molecule.py View on Github external
from a single scalar vector to an array of values
            known_elements ([str]): List of elements expected to be in dataset. Used only if the
                feature `element` is used to describe each atom
        """

        # Check if openbabel and RDKit are installed
        if Chem is None or pybel is None:
            raise RuntimeError('RDKit and openbabel must be installed')

        super().__init__()
        if bond_features is None:
            bond_features = _BOND_FEATURES
        if atom_features is None:
            atom_features = _ATOM_FEATURES
        if distance_converter is None:
            distance_converter = GaussianDistance(np.linspace(0, 4, 20), 0.5)
        if known_elements is None:
            known_elements = _ELEMENTS

        # Check if all feature names are valid
        if any(i not in _ATOM_FEATURES for i in atom_features):
            bad_features = set(atom_features).difference(_ATOM_FEATURES)
            raise ValueError('Unrecognized atom features: {}'.format(', '.join(bad_features)))
        self.atom_features = atom_features
        if any(i not in _BOND_FEATURES for i in bond_features):
            bad_features = set(bond_features).difference(_BOND_FEATURES)
            raise ValueError('Unrecognized bond features: {}'.format(', '.join(bad_features)))
        self.bond_features = bond_features
        self.known_elements = known_elements
        self.distance_converter = distance_converter
github materialsvirtuallab / megnet / megnet / data / molecule.py View on Github external
def __init__(self,
                 nn_strategy='AllAtomPairs',
                 atom_converter=None,
                 bond_converter=None
                 ):
        if bond_converter is None:
            bond_converter = GaussianDistance(np.linspace(0, 4, 20), 0.5)
        super().__init__(nn_strategy=nn_strategy, atom_converter=atom_converter,
                         bond_converter=bond_converter)
github materialsvirtuallab / megnet / megnet / data / qm9.py View on Github external
def __init__(self,
                 categorical=["type", 'chirality', 'hybridization', 'donor',
                              'acceptor', 'aromatic'],
                 feature_labels=['type', 'chirality', 'ring_sizes',
                                 'hybridization',
                                 'acceptor', "donor", 'aromatic'],
                 distance_converter=GaussianDistance(),
                 is_norm_dist=False):
        self.categorical = categorical
        self.feature_labels = feature_labels
        self.binarizer = {}
        self.scaler = StandardScaler()
        self.distance_converter = distance_converter
        self.c_labels = []
        self.has_numeric = None
        self.is_norm_dist = is_norm_dist