首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何在Google顶点AI中合并来自多个模型的结果?

如何在Google顶点AI中合并来自多个模型的结果?
EN

Stack Overflow用户
提问于 2022-03-21 12:11:39
回答 1查看 310关注 0票数 1

我在Google顶点AI中有多个模型,我想创建一个端点来为我的预测服务。我需要运行聚合算法,比如在我的模型输出上的投票算法。我还没有找到任何方法将模型放在一起,这样我就可以在结果上运行投票算法。我是否必须创建一个新的模型,卷曲我现有的模型,然后对结果运行我的算法?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-03-22 11:53:45

在顶点AI中没有实现聚合算法的内置条款.要将来自模型的curl结果聚合起来,我们需要将它们全部部署到各个端点。相反,我建议使用以下方法使用用于预测的定制容器将模型和元模型(聚合模型)部署到单个端点。可以找到自定义容器需求这里

可以将模型构件从GCS加载到自定义容器中。如果使用相同的模型集(即:对元模型的输入模型不改变),则可以将它们封装在容器中以减少加载时间。然后,可以使用自定义HTTP逻辑来返回聚合输出,如下所示。这是一个示例自定义烧瓶服务器逻辑。

代码语言:javascript
复制
def get_models_from_gcs():
    ## Pull the required model artifacts from GCS and load them here.
    models = [model_1, model_2, model_3]
    return models

def aggregate_predictions(predictions):
    ## Your aggregation algorithm here
    return aggregated_result


@app.post(os.environ['AIP_PREDICT_ROUTE'])
async def predict(request: Request):
    body = await request.json()
    instances = body["instances"]
    inputs = np.asarray(instances)
    preprocessed_inputs = _preprocessor.preprocess(inputs)

    models = get_models_from_gcs()
    predictions = []
    
    for model in models:
        predictions.append(model.predict(preprocessed_inputs))

    aggregated_result = aggregate_predictions(predictions)

    return {"aggregated_predictions": aggregated_result}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71557442

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档