mindsponge.metrics.backbone

mindsponge.metrics.backbone(traj, backbone_affine_tensor, backbone_affine_mask, fape_clamp_distance, fape_loss_unit_distance, use_clamped_fape)[source]

Backbone FAPE Loss using frame_aligned_point_error_map function. Jumper et al. (2021) Suppl. Alg. 20 “StructureModule” line 17.

Parameters
  • traj (Tensor) – The series of backbone frames(trajectory) generated by Structure module, the shape is \((N_{recycle}, N_{res}, 7)\) with \(N_{recycle}\) the recycle number of recycle in Structure module, \(N_{res}\) the number of residues in protein, for the last dimension, the first 4 elements are the affine tensor which contains the rotation information, the last 3 elements are the translations in space.

  • backbone_affine_tensor (Tensor) – The ground truth backbone frames of shape \((N_{res}, 7)\).

  • backbone_affine_mask (Tensor) – The binary mask for backbone frames of shape \((N_{res},)\).

  • fape_clamp_distance (float) – Distance cutoff on error beyond which gradients will be zero.

  • fape_loss_unit_distance (float) – The unit distance of backbone FAPE loss, used to scale distances.

  • use_clamped_fape (float) – The indicator that if backbone FAPE loss is clamped, 0 or 1, 1 means clamping.

Returns

  • fape (Tensor) - Backbone FAPE loss (clamped if use_clamped_fape is 1) of last recycle of Structure module with shape \(()\) .

  • loss (Tensor) - Averaged Backbone FAPE loss (clamped if use_clamped_fape is 1) of all recycle of Structure module with shape \(()\) .

  • no_clamp (Tensor) - Backbone FAPE loss of last recycle of Structure module with shape \(()\) .

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> np.random.seed(0)
>>> from mindsponge.metrics import backbone
>>> from mindspore import dtype as mstype
>>> from mindspore import Tensor
>>> traj = Tensor(np.random.rand(8, 256, 7)).astype(mstype.float32)
>>> backbone_affine_tensor = Tensor(np.random.rand(256, 7)).astype(mstype.float32)
>>> backbone_affine_mask = Tensor(np.random.rand(256,)).astype(mstype.float16)
>>> fape_clamp_distance = 10.0
>>> fape_loss_unit_distance = 10.0
>>> use_clamped_fape = 1
>>> fape, loss, noclamp = backbone(traj, backbone_affine_tensor, backbone_affine_mask,
...                                fape_clamp_distance, fape_loss_unit_distance, use_clamped_fape)
>>> print(fape, loss, noclamp)
0.12813742 0.12904957 0.12813742