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

BinaryPairwiseMeasures.__init__() got an unexpected keyword argument 'axis'

オープン
#49 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

評価

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

調査の方向性

monai/metrics/wrapper.py の MetricsReloadedBinary._compute_tensor を読み、BinaryPairwiseMeasures の呼び出しをインストール済みの MetricsReloaded API と比較してください。提供されている MONAI の例を再実行し、両方のメトリクス呼び出しと aggregate(reduction="none") が予期しない軸エラーなしで実行されれば完了です。

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

説明

When I ran the example in MONAI, I encountered this error.
MONAI version 1.3.2
MetricsReloaded version 0.1.0
The example code is as follows:

import torch
from monai.metrics import MetricsReloadedBinary

metric_name = "Cohens Kappa"
metric = MetricsReloadedBinary(metric_name=metric_name)

y_pred = torch.tensor([[[[1.0, 0.0], [0.0, 1.0]]]])
y = torch.tensor([[[[1.0, 0.0], [1.0, 1.0]]]])
print(metric(y_pred, y))

y_pred = torch.tensor([[[[1.0, 0.0], [0.0, 0.0]]]])
y = torch.tensor([[[[1.0, 0.0], [1.0, 1.0]]]])
print(metric(y_pred, y))

print(metric.aggregate(reduction="none"))

metric.reset()

The errors are as follows:

{
	"name": "TypeError",
	"message": "BinaryPairwiseMeasures.__init__() got an unexpected keyword argument 'axis'",
	"stack": "---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
File /home/bowen/git/prostate/practice.py:13
     11 y_pred = torch.tensor([[[[1.0, 0.0], [0.0, 1.0]]]])
     12 y = torch.tensor([[[[1.0, 0.0], [1.0, 1.0]]]])
---> 13 print(metric(y_pred, y))
     15 # second iteration
     16 # shape [batch=1, channel=1, 2, 2]
     17 y_pred = torch.tensor([[[[1.0, 0.0], [0.0, 0.0]]]])

File ~/.conda/envs/pytorch/lib/python3.11/site-packages/monai/metrics/metric.py:347, in CumulativeIterationMetric.__call__(self, y_pred, y, **kwargs)
    327 def __call__(
    328     self, y_pred: TensorOrList, y: TensorOrList | None = None, **kwargs: Any
    329 ) -> torch.Tensor | Sequence[torch.Tensor | Sequence[torch.Tensor]]:
    330     \"\"\"
    331     Execute basic computation for model prediction and ground truth.
    332     It can support  both `list of channel-first Tensor` and `batch-first Tensor`.
   (...)
    345         a `batch-first` tensor (BC[HWD]) or a list of `batch-first` tensors.
    346     \"\"\"
--> 347     ret = super().__call__(y_pred=y_pred, y=y, **kwargs)
    348     if isinstance(ret, (tuple, list)):
    349         self.extend(*ret)

File ~/.conda/envs/pytorch/lib/python3.11/site-packages/monai/metrics/metric.py:80, in IterationMetric.__call__(self, y_pred, y, **kwargs)
     78 if isinstance(y_pred, torch.Tensor):
     79     y_ = y.detach() if isinstance(y, torch.Tensor) else None
---> 80     return self._compute_tensor(y_pred.detach(), y_, **kwargs)
     81 raise ValueError(\"y_pred or y must be a list/tuple of `channel-first` Tensors or a `batch-first` Tensor.\")

File ~/.conda/envs/pytorch/lib/python3.11/site-packages/monai/metrics/wrapper.py:169, in MetricsReloadedBinary._compute_tensor(self, y_pred, y)
    166 y = convert_to_numpy(y)
    168 # Create binary pairwise metric object
--> 169 bpm = BinaryPairwiseMeasures(y_pred, y, axis=tuple(range(2, dims)), smooth_dr=1e-5)
    171 # Is requested metric available?
    172 if self.metric_name not in bpm.metrics:

TypeError: BinaryPairwiseMeasures.__init__() got an unexpected keyword argument 'axis'"
}
主要言語
Python
スター
104
フォーク
18
PR マージ指標
30日以内にマージされた PR はありません

環境構築

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

はじめの一歩

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

Project-MONAI/MetricsReloaded のほかの issue

Project-MONAI/MetricsReloaded の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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