mindsponge.metrics.frame_aligned_point_error_map

View Source On Gitee
mindsponge.metrics.frame_aligned_point_error_map(pred_frames, target_frames, frames_mask, pred_positions, target_positions, positions_mask, length_scale, l1_clamp_distance)[source]

Measure point error under different alignments which computes error between two structures with B points under A alignments derived from the given pairs of frames. Similar with the frame_aligned_point_error function. The difference is this is a batched version which return batch error for each group of local frames individually, this version considers only backbone frames \(C\alpha\) .

Parameters
  • pred_frames (list) – The predicted backbone frames which is a 2-dimensional list, the first element of pred_frames is a list of 9 tensors which are the 9 components of rotation matrix; the second element of pred_frames is a list of 3 tensors are the 3 component of translation matrix. All tensors are of shape \((N_{recycle}, N_{res})\). with \(N_{recycle}\) the recycle number of FoldIteration in Structure module, \(N_{res}\) the number of residues in protein.

  • target_frames (list) – The ground truth backbone frames which is also a 2-dimensional list, the same as pred_frames except that the shape of tensors is \((N_{res},)\).

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

  • pred_positions (list) – The predicted \(C\alpha\) atom positions which is a list of 3 tensors of shape \((N_{recycle}, N_{res},)\).

  • target_positions (list) – The ground truth \(C\alpha\) atom positions which is a list of 3 tensors of shape \((N_{res},)\).

  • positions_mask (Tensor) – The binary mask for Ca atom positions of shape \((N_{res},)\).

  • length_scale (float) – The unit distance which is used to scale distances.

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

Returns

  • error_clamp (Tensor) - Backbone FAPE loss clamped with shape \((N_{recycle},)\).

  • error_no_clamp (Tensor) - Backbone FAPE loss (not clamped) with shape \((N_{recycle},)\).

Supported Platforms:

Ascend GPU

Examples

>>> import numpy as np
>>> from mindsponge.metrics import frame_aligned_point_error_map
>>> from mindspore import dtype as mstype
>>> from mindspore import Tensor
>>> np.random.seed(0)
>>> rot_matrix = [[Tensor(np.random.rand(8, 256)).astype(mstype.float32) for _ in range(9)]]
>>> trans_matrix = [[Tensor(np.random.rand(8, 256)).astype(mstype.float32) for _ in range(3)]]
>>> pred_frames = rot_matrix + trans_matrix
>>> rot_matrix = [[Tensor(np.random.rand(256,)).astype(mstype.float32) for _ in range(9)]]
>>> trans_matrix = [[Tensor(np.random.rand(256,)).astype(mstype.float32) for _ in range(3)]]
>>> target_frames = rot_matrix + trans_matrix
>>> frames_mask = Tensor(np.random.rand(256,)).astype(mstype.float32)
>>> positions_mask = Tensor(np.random.rand(256,)).astype(mstype.float32)
>>> pred_positions = [Tensor(np.random.rand(8, 256)).astype(mstype.float32) for _ in range(3)]
>>> target_positions = [Tensor(np.random.rand(256,)).astype(mstype.float32) for _ in range(3)]
>>> length_scale = 10.0
>>> l1_clamp_distance = 10.0
>>> error, error_noclamp = frame_aligned_point_error_map(pred_frames, target_frames, frames_mask,
...                                                      pred_positions, target_positions, positions_mask,
...                                                      length_scale, l1_clamp_distance)
>>> print(error, error_noclamp)
[0.0827449  0.08608595 0.09045469 0.08518302 0.08452212 0.08624027 0.08426301 0.08154671]
[0.0827449  0.08608595 0.09045469 0.08518302 0.08452212 0.08624027 0.08426301 0.08154671]