Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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",
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)
),
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(
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,
)
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)
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],
)
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",
)
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
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)
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