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

AF3 process_tensors_from_config函数解读

AlphaFold3 input_pipeline 模块 process_tensors_from_config 函数用于根据配置(common_cfgmode_cfg) 处理输入 tensors,并应用不同的变换,最终返回处理后的数据。它包含非集成(nonensembled) 和 集成(ensembled) 两种变换策略,适用于不同的模型训练或推理模式。

源代码:

def process_tensors_from_config(tensors, common_cfg, mode_cfg):
    """Based on the config, apply filters and transformations to the data."""

    ensemble_seed = random.randint(0, torch.iinfo(torch.int32).max)

    def wrap_ensemble_fn(data, i):
        """Function to be mapped over the ensemble dimension."""
        d = data.copy()
        fns = ensembled_transform_fns(
            common_cfg, 
            mode_cfg, 
            ensemble_seed,
        )
        fn = compose(fns)
        d["ensemble_index"] = i
        return fn(d)

    no_templates = True
    if "template_aatype" in tensors:
        no_templates = tensors["template_aatype"].shape[0] == 0

    nonensembled = nonensembled_transform_fns(
        common_cfg,
        mode_cfg,
    )

    tensors = compose(nonensembled)(tensors)

    if "no_recycling_iters" in tensors:
        num_recycling = int(tensors["no_recycling_iters"])
    else:
        num_recycling = common_cfg.max_recycling_iters

    tensors = map_fn(
        lambda x: wrap_ensemble_fn(tensors, x), torch.arange(num_recycling + 1)
    )

    return tensors


@data_transforms.curry1
def compose(x, fs):
    for f in fs:
        x = f(x)
    return x


def map_fn(fun, x):
    ensembles = [fun(elem) for elem in x]
    features = ensembles[0].keys()
    ensembled_dict = {}
    for feat in features:
        ensembled_dict[feat] = torch.stack(
            [dict_i[feat] for dict_i in ensembles], dim=-1
        )
    return ensembled_dict

源码解读:

1. 函数签名
def process_tensors_from_config(tensors, common_cfg, mode_cfg):
    """Based on the config, apply filters and trans

相关文章:

  • True strength lies in embracing vulnerability as a gateway to growth.
  • 清晰易懂的TypeScript安装与开发环境配置教程
  • 主流云厂商的云原生技术栈(Cloud-native stack)及其核心组件对比
  • AIGC1——AIGC技术原理与模型演进:从GAN到多模态融合的突破
  • 备份是个好习惯
  • Android学习总结之通信篇
  • 基于 vue 做数字滚轮效果
  • UE5学习笔记 FPS游戏制作26 UE中的UI
  • Cline源码分析
  • 【力扣hot100题】(016)缺失的第一个正数
  • 一键实现:谷歌表单转word(formtoword)
  • springboot jpa Instant
  • Dubbo(22)如何配置Dubbo的服务提供者?
  • 【LeetCode】算法详解#2 ---和为k的子数组
  • 当AI代写作业成为常态:重构智能时代的教育范式
  • 关于JVM和OS中的栈帧的区别和内存浅析
  • mac m1/m2/m3 pyaudio的安装
  • 前端开发学习路线完整指南
  • Mysql-DCL
  • libpng-1.6.47-windows编译
  • 结构设计网站/搜索引擎推广有哪些平台
  • 邵阳做网站的有哪些/新闻式软文范例
  • 官方网站建设项目询价/西安优化外包
  • 专业的网站设计公司/镇江搜索优化技巧
  • 网站建设1001网站建设/北京百度seo点击器
  • 李沧网站建设/宁波谷歌seo推广公司