Loss Functions¶
- class ModifiedForceField(*args, alternative_residue_names=None, **kwargs)[source]¶
Takes all *args and **kwargs of openmm.app.ForceField, plus an optional parameter described here.
- Parameters:
alternative_residue_names (dict) – aliases for resnames, e.g., {‘HIS’:’HIE’}.
- class OpenMMPluginScoreSoftForceField(mol=None, platform='CUDA', atoms=['CA', 'C', 'N', 'CB', 'O'])[source]¶
- Parameters:
mol (biobox.Molecule) – if pldataloader is not given, then a biobox object will be taken from this parameter. If neither are given then an error will be thrown.
xml_file (str) – xml parameter file
platform (str) – ‘CUDA’ or ‘Reference’.
remove_NB (bool) – if True remove NonbondedForce, CustomGBForce and CMMotionRemover, else just remove CustomGBForce
alternative_residue_names (dict) – aliases for resnames, e.g., {‘HIS’:’HIE’}.
atoms
soft
- class OpenmmPluginScore(mol=None, xml_file=['amber14-all.xml'], platform='CUDA', remove_NB=False, alternative_residue_names={'HIS': 'HIE', 'HSE': 'HIE'}, atoms=['CA', 'C', 'N', 'CB', 'O'], soft=False)[source]¶
This will use the new OpenMM Plugin to calculate forces and energy. The intention is that this will be fast enough to be able to calculate forces and energy during training. N.B.: The current torchintegratorplugin only supports float on GPU and double on CPU.
- Parameters:
mol (biobox.Molecule) – if pldataloader is not given, then a biobox object will be taken from this parameter. If neither are given then an error will be thrown.
xml_file (str) – xml parameter file
platform (str) – ‘CUDA’ or ‘Reference’.
remove_NB (bool) – if True remove NonbondedForce, CustomGBForce and CMMotionRemover, else just remove CustomGBForce
alternative_residue_names (dict) – aliases for resnames, e.g., {‘HIS’:’HIE’}.
atoms
soft
- class OpenmmTorchEnergyMinimizer(mol=None, xml_file=['amber14-all.xml'], platform='CUDA', remove_NB=False, alternative_residue_names={'HIS': 'HIE', 'HSE': 'HIE'}, atoms=['CA', 'C', 'N', 'CB', 'O'], soft=False)[source]¶
- Parameters:
mol (biobox.Molecule) – if pldataloader is not given, then a biobox object will be taken from this parameter. If neither are given then an error will be thrown.
xml_file (str) – xml parameter file
platform (str) – ‘CUDA’ or ‘Reference’.
remove_NB (bool) – if True remove NonbondedForce, CustomGBForce and CMMotionRemover, else just remove CustomGBForce
alternative_residue_names (dict) – aliases for resnames, e.g., {‘HIS’:’HIE’}.
atoms
soft
- class openmm_clamped_energy_function(*args, **kwargs)[source]¶
- static backward(ctx, grad_output)[source]¶
Define a formula for differentiating the operation with backward mode automatic differentiation.
This function is to be overridden by all subclasses. (Defining this function is equivalent to defining the
vjpfunction.)It must accept a context
ctxas the first argument, followed by as many outputs as theforward()returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward(). Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_gradas a tuple of booleans representing whether each input needs gradient. E.g.,backward()will havectx.needs_input_grad[0] = Trueif the first input toforward()needs gradient computed w.r.t. the output.
- class openmm_energy(mol, std, clamp=None, **kwargs)[source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- class openmm_energy_function(*args, **kwargs)[source]¶
- static backward(ctx, grad_output)[source]¶
Define a formula for differentiating the operation with backward mode automatic differentiation.
This function is to be overridden by all subclasses. (Defining this function is equivalent to defining the
vjpfunction.)It must accept a context
ctxas the first argument, followed by as many outputs as theforward()returned (None will be passed in for non tensor outputs of the forward function), and it should return as many tensors, as there were inputs toforward(). Each argument is the gradient w.r.t the given output, and each returned value should be the gradient w.r.t. the corresponding input. If an input is not a Tensor or is a Tensor not requiring grads, you can just pass None as a gradient for that input.The context can be used to retrieve tensors saved during the forward pass. It also has an attribute
ctx.needs_input_gradas a tuple of booleans representing whether each input needs gradient. E.g.,backward()will havectx.needs_input_grad[0] = Trueif the first input toforward()needs gradient computed w.r.t. the output.