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

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

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

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
52/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
machine-learning

Hướng nghiên cứu

Đọc monai/metrics/wrapper.py tại MetricsReloadedBinary._compute_tensor và so sánh lệnh gọi BinaryPairwiseMeasures của nó với API MetricsReloaded đã cài đặt. Chạy lại ví dụ MONAI được cung cấp; được xem là hoàn tất khi cả hai lệnh gọi metric và aggregate(reduction="none") đều thực thi mà không gặp lỗi trục không mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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'"
}
Ngôn ngữ chính
Python
Star
105
Fork
18
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 Project-MONAI/MetricsReloaded

Tất cả issue của Project-MONAI/MetricsReloaded

Issue tương tự

Thêm issue về Python

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.