How to use the schnetpack.train.metrics function in schnetpack

To help you get started, we’ve selected a few schnetpack 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 atomistic-machine-learning / schnetpack / src / scripts / schnetpack_md17.py View on Github external
parser = get_main_parser()
    add_md17_arguments(parser)
    add_subparsers(
        parser,
        defaults=dict(property=MD17.energy, elements=["H", "C", "O"]),
        choices=dict(property=[MD17.energy, MD17.forces]),
    )
    args = parser.parse_args()
    train_args = setup_run(args)

    # set device
    device = torch.device("cuda" if args.cuda else "cpu")

    # define metrics
    metrics = [
        schnetpack.train.metrics.MeanAbsoluteError(MD17.energy, MD17.energy),
        schnetpack.train.metrics.RootMeanSquaredError(MD17.energy, MD17.energy),
        schnetpack.train.metrics.MeanAbsoluteError(
            MD17.forces, MD17.forces, element_wise=True
        ),
        schnetpack.train.metrics.RootMeanSquaredError(
            MD17.forces, MD17.forces, element_wise=True
        ),
    ]

    # build dataset
    logging.info("MD17 will be loaded...")
    md17 = MD17(
        args.datapath,
        args.molecule,
        download=True,
        collect_triples=args.model == "wacsf",
github atomistic-machine-learning / schnetpack / src / scripts / schnetpack_omdb.py View on Github external
features=64,
            patience=6,
            aggregation_mode="mean",
        ),
        choices=dict(property=[OrganicMaterialsDatabase.BandGap]),
    )

    args = parser.parse_args()
    train_args = setup_run(args)

    # set device
    device = torch.device("cuda" if args.cuda else "cpu")

    # define metrics
    metrics = [
        schnetpack.train.metrics.MeanAbsoluteError(
            train_args.property, train_args.property
        ),
        schnetpack.train.metrics.RootMeanSquaredError(
            train_args.property, train_args.property
        ),
    ]

    # build dataset
    logging.info("OMDB will be loaded...")
    omdb = spk.datasets.OrganicMaterialsDatabase(
        args.datapath, args.cutoff, download=True, load_only=[train_args.property]
    )

    # get atomrefs
    atomref = omdb.get_atomrefs(train_args.property)
github atomistic-machine-learning / schnetpack / src / scripts / schnetpack_omdb.py View on Github external
),
        choices=dict(property=[OrganicMaterialsDatabase.BandGap]),
    )

    args = parser.parse_args()
    train_args = setup_run(args)

    # set device
    device = torch.device("cuda" if args.cuda else "cpu")

    # define metrics
    metrics = [
        schnetpack.train.metrics.MeanAbsoluteError(
            train_args.property, train_args.property
        ),
        schnetpack.train.metrics.RootMeanSquaredError(
            train_args.property, train_args.property
        ),
    ]

    # build dataset
    logging.info("OMDB will be loaded...")
    omdb = spk.datasets.OrganicMaterialsDatabase(
        args.datapath, args.cutoff, download=True, load_only=[train_args.property]
    )

    # get atomrefs
    atomref = omdb.get_atomrefs(train_args.property)

    # splits the dataset in test, val, train sets
    split_path = os.path.join(args.modelpath, "split.npz")
    train_loader, val_loader, test_loader = get_loaders(
github atomistic-machine-learning / schnetpack / src / scripts / schnetpack_qm9.py View on Github external
QM9.U,
                QM9.H,
                QM9.G,
                QM9.Cv,
            ]
        ),
    )
    args = parser.parse_args()
    train_args = setup_run(args)

    # set device
    device = torch.device("cuda" if args.cuda else "cpu")

    # define metrics
    metrics = [
        schnetpack.train.metrics.MeanAbsoluteError(
            train_args.property, train_args.property
        ),
        schnetpack.train.metrics.RootMeanSquaredError(
            train_args.property, train_args.property
        ),
    ]

    # build dataset
    logging.info("QM9 will be loaded...")
    qm9 = QM9(
        args.datapath,
        download=True,
        load_only=[train_args.property],
        collect_triples=args.model == "wacsf",
        remove_uncharacterized=train_args.remove_uncharacterized,
    )
github atomistic-machine-learning / schnetpack / src / scripts / schnetpack_matproj.py View on Github external
MaterialsProject.TotalMagnetization,
            ]
        ),
    )
    args = parser.parse_args()
    train_args = setup_run(args)

    # set device
    device = torch.device("cuda" if args.cuda else "cpu")

    # define metrics
    metrics = [
        schnetpack.train.metrics.MeanAbsoluteError(
            train_args.property, train_args.property
        ),
        schnetpack.train.metrics.RootMeanSquaredError(
            train_args.property, train_args.property
        ),
    ]

    # build dataset
    mp = spk.datasets.MaterialsProject(
        args.datapath,
        args.cutoff,
        apikey=args.apikey,
        download=True,
        load_only=[train_args.property],
    )

    # get atomrefs
    atomref = mp.get_atomrefs(train_args.property)
github atomistic-machine-learning / schnetpack / src / scripts / schnetpack_matproj.py View on Github external
MaterialsProject.EformationPerAtom,
                MaterialsProject.EPerAtom,
                MaterialsProject.BandGap,
                MaterialsProject.TotalMagnetization,
            ]
        ),
    )
    args = parser.parse_args()
    train_args = setup_run(args)

    # set device
    device = torch.device("cuda" if args.cuda else "cpu")

    # define metrics
    metrics = [
        schnetpack.train.metrics.MeanAbsoluteError(
            train_args.property, train_args.property
        ),
        schnetpack.train.metrics.RootMeanSquaredError(
            train_args.property, train_args.property
        ),
    ]

    # build dataset
    mp = spk.datasets.MaterialsProject(
        args.datapath,
        args.cutoff,
        apikey=args.apikey,
        download=True,
        load_only=[train_args.property],
    )
github atomistic-machine-learning / schnetpack / src / scripts / schnetpack_md17.py View on Github external
add_subparsers(
        parser,
        defaults=dict(property=MD17.energy, elements=["H", "C", "O"]),
        choices=dict(property=[MD17.energy, MD17.forces]),
    )
    args = parser.parse_args()
    train_args = setup_run(args)

    # set device
    device = torch.device("cuda" if args.cuda else "cpu")

    # define metrics
    metrics = [
        schnetpack.train.metrics.MeanAbsoluteError(MD17.energy, MD17.energy),
        schnetpack.train.metrics.RootMeanSquaredError(MD17.energy, MD17.energy),
        schnetpack.train.metrics.MeanAbsoluteError(
            MD17.forces, MD17.forces, element_wise=True
        ),
        schnetpack.train.metrics.RootMeanSquaredError(
            MD17.forces, MD17.forces, element_wise=True
        ),
    ]

    # build dataset
    logging.info("MD17 will be loaded...")
    md17 = MD17(
        args.datapath,
        args.molecule,
        download=True,
        collect_triples=args.model == "wacsf",
    )
github atomistic-machine-learning / schnetpack / src / schnetpack / utils / script_utils / training.py View on Github external
def get_metrics(args):
    # setup property metrics
    metrics = [
        spk.train.metrics.MeanAbsoluteError(args.property, args.property),
        spk.train.metrics.RootMeanSquaredError(args.property, args.property),
    ]

    # add metrics for derivative
    derivative = spk.utils.get_derivative(args)
    if derivative is not None:
        metrics += [
            spk.train.metrics.MeanAbsoluteError(
                derivative, derivative, element_wise=True
            ),
            spk.train.metrics.RootMeanSquaredError(
                derivative, derivative, element_wise=True
            ),
        ]

    return metrics
github atomistic-machine-learning / schnetpack / src / scripts / schnetpack_qm9.py View on Github external
QM9.Cv,
            ]
        ),
    )
    args = parser.parse_args()
    train_args = setup_run(args)

    # set device
    device = torch.device("cuda" if args.cuda else "cpu")

    # define metrics
    metrics = [
        schnetpack.train.metrics.MeanAbsoluteError(
            train_args.property, train_args.property
        ),
        schnetpack.train.metrics.RootMeanSquaredError(
            train_args.property, train_args.property
        ),
    ]

    # build dataset
    logging.info("QM9 will be loaded...")
    qm9 = QM9(
        args.datapath,
        download=True,
        load_only=[train_args.property],
        collect_triples=args.model == "wacsf",
        remove_uncharacterized=train_args.remove_uncharacterized,
    )

    # get atomrefs
    atomref = qm9.get_atomrefs(train_args.property)
github atomistic-machine-learning / schnetpack / src / schnetpack / utils / script_utils / training.py View on Github external
def get_metrics(args):
    # setup property metrics
    metrics = [
        spk.train.metrics.MeanAbsoluteError(args.property, args.property),
        spk.train.metrics.RootMeanSquaredError(args.property, args.property),
    ]

    # add metrics for derivative
    derivative = spk.utils.get_derivative(args)
    if derivative is not None:
        metrics += [
            spk.train.metrics.MeanAbsoluteError(
                derivative, derivative, element_wise=True
            ),
            spk.train.metrics.RootMeanSquaredError(
                derivative, derivative, element_wise=True
            ),
        ]

    return metrics