a5ee2e0ea284a9b024721536abb94b7998a9e8ee,qcengine/programs/torchani.py,,run_torchani,#Any#,8
Before Change
ret_data["success"] = False
// Build model and species array
if ret_data["model"]["method"] == "ANI1":
// Build model
builtin = torchani.neurochem.Builtins()
model = torch.nn.Sequential(builtin.aev_computer, builtin.models, builtin.energy_shifter)
// Build species
unknown_sym = set(ret_data["molecule"]["symbols"]) - {"H", "C", "N", "O"}
After Change
// Build model
model = get_model(ret_data["model"]["method"])
if model is False:
ret_data["error_message"] = "run_torchani only accepts the ANI1 method."
return ret_data
// Build species
species = "".join(ret_data["molecule"]["symbols"])
unknown_sym = set(species) - {"H", "C", "N", "O"}
if unknown_sym:
ret_data["error_message"] = "The "{}" model does not support symbols: {}.".format(
ret_data["model"]["method"], unknown_sym)
return ret_data
species = builtin.consts.species_to_tensor(species).to(device).unsqueeze(0)
// Build coord array
geom_array = np.array(ret_data["molecule"]["geometry"]).reshape(1, -1, 3) * units.bohr_to_angstrom
coordinates = torch.tensor(geom_array.tolist(), requires_grad=True, device=device)
_, energy = model((species, coordinates))
ret_data["properties"] = {"return_energy": energy.item()}
if ret_data["driver"] == "energy":
ret_data["return_result"] = ret_data["properties"]["return_energy"]
elif ret_data["driver"] == "gradient":
derivative = torch.autograd.grad(energy.sum(), coordinates)[0].squeeze()
ret_data["return_result"] = np.asarray(derivative / units.bohr_to_angstrom).ravel().tolist()
else:
ret_data["error_message"] = "run_torchani did not understand driver method "{}".".format(ret_data["driver"])
return ret_data
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 5
Instances
Project Name: MolSSI/QCEngine
Commit Name: a5ee2e0ea284a9b024721536abb94b7998a9e8ee
Time: 2018-11-13
Author: malorian@me.com
File Name: qcengine/programs/torchani.py
Class Name:
Method Name: run_torchani
Project Name: tensorflow/transform
Commit Name: 51a0c5fbe8e236cdb7e58afce66d7639d8fe9a45
Time: 2017-10-20
Author: tf-transform-dev@google.com
File Name: tensorflow_transform/coders/example_proto_coder.py
Class Name: _FixedLenFeatureHandler
Method Name: __init__
Project Name: tensorflow/transform
Commit Name: 93c5a8952f5a350c78243bc1ffa47b07f5f93721
Time: 2017-11-22
Author: tf-transform-dev@google.com
File Name: tensorflow_transform/coders/example_proto_coder.py
Class Name: _FixedLenFeatureHandler
Method Name: __init__