Kabsch augmentation
KabschAugmentation
Point-wise Kabsch alignment.
Source code in bionemo/moco/interpolants/continuous_time/continuous/data_augmentation/kabsch_augmentation.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
__init__()
Initialize the KabschAugmentation instance.
Notes
- This implementation assumes no required initialization arguments.
- You can add instance variables (e.g.,
self.variable_name
) as needed.
Source code in bionemo/moco/interpolants/continuous_time/continuous/data_augmentation/kabsch_augmentation.py
28 29 30 31 32 33 34 35 |
|
apply_augmentation(x0, x1, mask=None, align_noise_to_data=True)
Sample indices for noise and data in minibatch according to OT plan.
Compute the OT plan $\pi$ (wrt squared Euclidean cost after Kabsch alignment) between a source and a target minibatch and draw source and target samples from pi $(x,z) \sim \pi$.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x0
|
Tensor
|
shape (bs, *dim), noise from source minibatch. |
required |
x1
|
Tensor
|
shape (bs, *dim), data from source minibatch. |
required |
mask
|
Optional[Tensor]
|
mask to apply to the output, shape (batchsize, nodes), if not provided no mask is applied. Defaults to None. |
None
|
replace
|
bool
|
sampling w/ or w/o replacement from the OT plan, default to False. |
required |
align_noise_to_data
|
bool
|
Direction of alignment default is True meaning it augments Noise to reduce error to Data. |
True
|
Returns:
Name | Type | Description |
---|---|---|
Tuple |
Tuple[Tensor, Tensor]
|
tuple of 2 tensors, represents the noise and data samples following OT plan pi. |
Source code in bionemo/moco/interpolants/continuous_time/continuous/data_augmentation/kabsch_augmentation.py
104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
batch_kabsch_align(target, noise)
Find the Rotation matrix (R) such that RMSD is minimized between target @ R.T and noise.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
Tensor
|
shape (B, N, *dim), data from source minibatch. |
required |
noise
|
Tensor
|
shape (B, N, *dim), noise from source minibatch. |
required |
Returns:
Name | Type | Description |
---|---|---|
R |
Tensor
|
shape (dim, dim), the rotation matrix. |
Aliged Target (Tensor): target tensor rotated and shifted to reduced RMSD with noise |
Source code in bionemo/moco/interpolants/continuous_time/continuous/data_augmentation/kabsch_augmentation.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|
kabsch_align(target, noise)
Find the Rotation matrix (R) such that RMSD is minimized between target @ R.T and noise.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target
|
Tensor
|
shape (N, *dim), data from source minibatch. |
required |
noise
|
Tensor
|
shape (N, *dim), noise from source minibatch. |
required |
Returns:
Name | Type | Description |
---|---|---|
R |
Tensor
|
shape (dim, dim), the rotation matrix. |
Aliged Target (Tensor): target tensor rotated and shifted to reduced RMSD with noise |
Source code in bionemo/moco/interpolants/continuous_time/continuous/data_augmentation/kabsch_augmentation.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|