ai.onnx.ml - Binarizer

Binarizer - 1 (ai.onnx.ml)

版本

  • 名称: Binarizer (GitHub)

  • : ai.onnx.ml

  • 起始版本: 1

  • 函数: False

  • 支持级别: SupportType.COMMON

  • 形状推断: True

该算子的此版本**自 ai.onnx.ml 域的 1 版本起**可用。

摘要

根据与阈值进行比较的结果,逐元素地将输入张量的值映射为 0 或 1。

属性

  • threshold - FLOAT (默认为 '0.0')

    大于此值的值映射为 1,否则映射为 0。

输入

  • X (异构) - T

    要二值化的数据

输出

  • Y (异构) - T

    二值化后的输出数据

类型约束

  • T 接受 ( tensor(double), tensor(float), tensor(int32), tensor(int64) )

    输入必须是数值类型的张量。输出将是相同的张量类型。

示例

默认

import numpy as np
import onnx

threshold = 1.0
node = onnx.helper.make_node(
    "Binarizer",
    inputs=["X"],
    outputs=["Y"],
    threshold=threshold,
    domain="ai.onnx.ml",
)
x = np.random.randn(3, 4, 5).astype(np.float32)
y = compute_binarizer(x, threshold)[0]

expect(node, inputs=[x], outputs=[y], name="test_ai_onnx_ml_binarizer")