当前位置: 首页 > news >正文

南昌 网站建设黄山网站建设公司

南昌 网站建设,黄山网站建设公司,惠网 做网站,申请域网站Rotation 类(rigid_utils 模块)是 AlphaFold3 中用于 3D旋转 的核心组件,支持两种旋转表示: 1️⃣ 旋转矩阵 (3x3) 2️⃣ 四元数 (quaternion, 4元向量) 👉 设计目标: 允许灵活选择 旋转矩阵 或 四元数 封装了常用的 旋转操作(组合、逆旋转、应用到点上等) 像 torch.…

Rotation 类(rigid_utils 模块)是 AlphaFold3 中用于 3D旋转 的核心组件,支持两种旋转表示: 1️⃣ 旋转矩阵 (3x3)
2️⃣ 四元数 (quaternion, 4元向量)

👉 设计目标

  • 允许灵活选择 旋转矩阵 或 四元数

  • 封装了常用的 旋转操作(组合、逆旋转、应用到点上等)

  • 像 torch.Tensor 一样,支持索引、拼接、广播等操作

源代码:

class Rotation:"""A 3D rotation. Depending on how the object is initialized, therotation is represented by either a rotation matrix or aquaternion, though both formats are made available by helper functions.To simplify gradient computation, the underlying format of therotation cannot be changed in-place. Like Rigid, the class is designedto mimic the behavior of a torch Tensor, almost as if each Rotationobject were a tensor of rotations, in one format or another."""def __init__(self,rot_mats: Optional[torch.Tensor] = None,quats: Optional[torch.Tensor] = None,normalize_quats: bool = True,):"""Args:rot_mats:A [*, 3, 3] rotation matrix tensor. Mutually exclusive withquatsquats:A [*, 4] quaternion. Mutually exclusive with rot_mats. Ifnormalize_quats is not True, must be a unit quaternionnormalize_quats:If quats is specified, whether to normalize quats"""if((rot_mats is None and quats is None) or (rot_mats is not None and quats is not None)):raise ValueError("Exactly one input argument must be specified")if((rot_mats is not None and rot_mats.shape[-2:] != (3, 3)) or (quats is not None and quats.shape[-1] != 4)):raise ValueError("Incorrectly shaped rotation matrix or quaternion")# Force full-precisionif(quats is not None):quats = quats.to(dtype=torch.float32)if(rot_mats is not None):rot_mats = rot_mats.to(dtype=torch.float32)if(quats is not None and normalize_quats):quats = quats / torch.linalg.norm(quats, dim=-1, keepdim=True)self._rot_mats = rot_matsself._quats = quats@staticmethoddef identity(shape,dtype: Optional[torch.dtype] = None,device: Optional[torch.device] = None,requires_grad: bool = True,fmt: str = "quat",) -> Rotation:"""Returns an identity Rotation.Args:shape:The "shape" of the resulting Rotation object. See documentationfor the shape propertydtype:The torch dtype for the rotationdevice:The torch device for the new rotationrequires_grad:Whether the underlying tensors in the new rotation objectshould require gradient computationfmt:One of "quat" or "rot_mat". Determines the underlying formatof the new object's rotation Returns:A new identity rotation"""if(fmt == "rot_mat"):rot_mats = identity_rot_mats(shape, dtype, device, requires_grad,)return Rotation(rot_mats=rot_mats, quats=None)elif(fmt == "quat"):quats = identity_quats(shape, dtype, device, requires_grad)return Rotation(rot_mats=None, quats=quats, normalize_quats=False)else:raise ValueError(f"Invalid format: f{fmt}")# Magic methodsdef __getitem__(self, index: Any) -> Rotation:"""Allows torch-style indexing over the virtual shape of the rotationobject. See documentation for the shape property.Args:index:A torch index. E.g. (1, 3, 2), or (slice(None,))Returns:The indexed rotation"""if type(index) != tuple:index = (index,)if(self._rot_mats is not None):rot_mats = self._rot_mats[index + (slice(None), slice(None))]return Rotation(rot_mats=rot_mats)elif(self._quats is not None):quats = self._quats[index + (slice(None),)]return Rotation(quats=quats, normalize_quats=False)else:raise ValueError("Both rotations are None")def __mul__(self,right: torch.Tensor,) -> Rotation:"""Pointwise left multiplication of the rotation with a tensor. Can beused to e.g. mask the Ro
http://www.dtcms.com/a/589788.html

相关文章:

  • 深入解析:动画组件为何必须使用useCallback
  • 深度强化学习算法详解:从理论到实践
  • 4.1.8 文件系统基础【2011统考真题】
  • 行业网站开发互联网广告平台有哪些
  • 做网站自己上传电影要多大服务器电商是做什么的?
  • 零基础学JAVA--Day27(注释+异常+异常处理方法)
  • 新华网站建设设计漂亮的网站
  • Linux下的编译器gcc/g++
  • 【Redis|第一篇】基础篇
  • 嵌入式回调:弱函数与函数指针的实战解析
  • 网站建设技术支持包括哪些小工程施工合同协议书
  • 掌握RAG系统的七个优秀GitHub存储库
  • 网站开发面试都会问什么问题网站开发的阶段流程图
  • 如何将废弃笔记本搭建成服务器:使用花生壳内网穿透实现公网访问
  • Linux网络编程:应用层协议HTTP
  • 网站按域名跳转不同的页面网站建设面谈话术
  • Photoshop - Photoshop 工具栏(25)仿制图章工具
  • Java 会话技术、Cookie、JWT令牌、过滤器Filter、拦截器Interceptor
  • 简单理解:ADC(模数转换)采集的滤波算法
  • WASM 3.0 两大领域实战:SvelteKit前端新范式(完整版)
  • WebForms ArrayList 深入解析
  • 免费建站网站建设wordpress4.9.1加速
  • 网络seo营销推广网站开发百灵鸟优化
  • 详解Shell中的if分支(单个条件、多个条件)
  • C++后端总览
  • 快速上手配置Zookeeper
  • Linux1
  • 没有基础怎么学网站建设有没有免费查公司的软件
  • 毕业设计做网站有什么好处wordpress 的论坛模板下载
  • linux spi回环测试