github / github/codeql

LGTM.com - false positive - Non-callable class errors for classes that inherit from callable torch.nn.Module

未关闭
#4,183 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
false-positive Python
主要语言
CodeQL
星标
10.1k
派生
2.1k
平均合并
2 天 15 小时
30 天内合并 PR
141

描述

**Description of the false positive**

I get `Call to a non-callable of class ...` error alerts for PyTorch classes that inherit from the callable `torch.nn.Module` class:
1. Class `torch.nn.CrossEntropyLoss`
This class inherits from `_WeightedLoss` which inherits form `_Loss` which inherits from `torch.nn.Module` (see [here](https://pytorch.org/docs/stable/_modules/torch/nn/modules/loss.html#CrossEntropyLoss) for the source code).
2. Class `torch.nn.ReflectionPad2d`
This class inherits from `_ReflectionPadNd` which inherits from `torch.nn.Module` (see [here](https://pytorch.org/docs/stable/_modules/torch/nn/modules/padding.html#ReflectionPad2d) for the source code).

`torch.nn.Module` defines the `__call__` method as can be seen [here](https://github.com/pytorch/pytorch/blob/8094228f26cdef24529bffadd6a6e43b56df2d6e/torch/nn/modules/module.py#L751).

**URL to the alert on the project page on LGTM.com**
`CrossEntropyLoss` errors: [alert-1](https://lgtm.com/projects/g/mfl28/MachineLearning/snapshot/6305daee10649072dd64b5f5f86076369655e6c9/files/mltools/classification/utils.py?sort=name&dir=ASC&mode=heatmap#xfb842e36390a0f89:1), [alert-2](https://lgtm.com/projects/g/mfl28/MachineLearning/snapshot/6305daee10649072dd64b5f5f86076369655e6c9/files/mltools/classification/utils.py?sort=name&dir=ASC&mode=heatmap#x7ecfd52bd6020a51:1)
`ReflectionPad2d` error: [alert](https://lgtm.com/projects/g/mfl28/MachineLearning/snapshot/6305daee10649072dd64b5f5f86076369655e6c9/files/mltools/segmentation/models.py?sort=name&dir=ASC&mode=heatmap#x1d7d7e0c7ca68410:1)

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。