Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[BUG] Hardtanh ignores min_val/max_val from the .nam config

オープン 初心者向け
#342 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
82/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
cpp, python, pytorch
領域
backend

調査の方向性

NAM/activations.cpp から始め、次に nam/models/_activations.py のエクスポートされた境界を比較します。Hardtanh の設定パラメータがどのように解析されるかを追跡し、min_val=-0.5 および max_val=0.8 の設定を試します。境界付き Hardtanh が trainer と一致し、単なる文字列と境界のない設定が現在の ±1 の動作を維持すれば完了です。

索引モデルが issue の本文から書いたものです。

説明

Summary

Hardtanh activations ignore their min_val / max_val bounds: the core always clamps to [-1, 1]. The trainer exports Hardtanh with explicit bounds, so a model trained with torch.nn.Hardtanh(min_val, max_val) other than ±1 runs differently in the core.

Where

  • Trainer (neural-amp-modeler main @ 0072676419): nam/models/_activations.py, lines ~253–258, exports
    if isinstance(module, _nn.Hardtanh):
        return {"type": "Hardtanh", "min_val": module.min_val, "max_val": module.max_val}
    
  • Core (main @ 0b3d3c97b0, also v0.5.4): NAM/activations.cpp maps "Hardtanh" to the parameterless singleton ActivationHardTanh (clamp to ±1); min_val/max_val are only parsed for LeakyHardtanh.

Suggested fix

When a Hardtanh config carries min_val/max_val, honour them — e.g. build a clamp with those bounds, or map it to LeakyHardtanh with min_slope = max_slope = 0 (which is exactly a clamp to [min_val, max_val]). The bare string "Hardtanh" and configs without bounds keep today's ±1 behaviour.

With that mapping, a test model using Hardtanh(min_val=-0.5, max_val=0.8) matched the trainer's PyTorch output to ~6e-8. (That same model also has an inactive layer1x1, so the ~6e-8 figure is with the fix from #341 applied as well.)

主要言語
C++
スター
931
フォーク
178
平均マージ
36分
マージ済み PR(30日)
4

環境構築

このプロジェクトの環境構築ファイルはまだ確認していません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sdatkinson/NeuralAmpModelerCore のほかの issue

sdatkinson/NeuralAmpModelerCore の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。