Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

[tmva][sofie] Selu ignores its alpha and gamma attributes

Đang mở
#23,734 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@lmoneta đang làm issue này rồi.

Từ ngày 16/10/2026.

  • #23743 của @Maher-star-eng — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

bug in:SOFIE
Check duplicate issues.
  • Checked for duplicates
Description

ParseSelu never reads the alpha and gamma attributes of the ONNX Selu operator, and ROperator_Selu::Generate() hard-codes their default values (1.6732632423543772848170429916717 and 1.0507009873554804934193349852946). A Selu node with other values silently gives wrong results. The other activations with attributes (Elu, LeakyRelu, HardSigmoid, Gelu) read them.

Expected: y = gamma * x for x > 0 and y = gamma * alpha * (exp(x) - 1) otherwise, with the values of the node.

Reproducer
import os

import numpy as np
import onnx
import onnxruntime as ort
import ROOT
from onnx import TensorProto, helper

os.chdir(os.path.dirname(os.path.abspath(__file__)))

node = helper.make_node("Selu", ["x"], ["y"], alpha=2.0, gamma=3.0)
graph = helper.make_graph(
    [node],
    "selu_attributes",
    [helper.make_tensor_value_info("x", TensorProto.FLOAT, [1, 4])],
    [helper.make_tensor_value_info("y", TensorProto.FLOAT, [1, 4])],
)
model = helper.make_model(graph, opset_imports=[helper.make_opsetid("", 13)], ir_version=8)
onnx.save(model, "selu_attributes.onnx")

x = np.array([[-2.0, -0.5, 0.5, 2.0]], np.float32)
print("onnxruntime:", ort.InferenceSession("selu_attributes.onnx").run(None, {"x": x})[0].tolist())

ROOT.gInterpreter.Declare("""
#include "TMVA/RModelParser_ONNX.hxx"
void selu_generate() {
   using namespace TMVA::Experimental::SOFIE;
   RModelParser_ONNX parser;
   RModel model = parser.Parse("selu_attributes.onnx");
   model.Generate();
   model.OutputGenerated("selu_attributes.hxx");
}
""")
ROOT.selu_generate()
ROOT.gInterpreter.Declare('#include "selu_attributes.hxx"')
session = ROOT.TMVA_SOFIE_selu_attributes.Session()
print("SOFIE:      ", [round(v, 6) for v in session.infer(x.ravel())])

Output:

onnxruntime: [[-5.18798828125, -2.36081600189209, 1.5, 6.0]]
SOFIE:       [-1.520167, -0.691758, 0.525351, 2.101402]
ROOT version

6.41.01, master at c619e8fbd7f

Installation method

Built from source (CMake, Release, -Dtesting=ON)

Operating system

macOS 26 (arm64, Apple M4 Pro)

Additional context

I found this with a script that runs the ONNX operator tests from the onnx Python package through SOFIE (test_selu and test_selu_example give wrong values)
the script was written by Claude .
I'll open a PR with a fix and a test.

Ngôn ngữ chính
C++
Star
3.3k
Fork
1.6k
Merge trung bình
2 ngày 10 giờ
Pull request đã merge (30 ngày)
197

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của root-project/root

Tất cả issue của root-project/root

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.