Region Mutual Information loss
PyTorch implementation of the Region Mutual Information Loss for Semantic Segmentation.
Example usage
With logits:
import torch
from rmi import RMILoss
loss = RMILoss(with_logits=True)
batch_size, classes, height, width = 5, 4, 64, 64
pred = torch.rand(batch_size, classes, height, width, requires_grad=True)
target = torch.empty(batch_size, classes, height, width).random_(2)
output = loss(pred, target)
output.backward()
With probabilities:
import torch
from torch import nn
from rmi import RMILoss
m = nn.Sigmoid()
loss = RMILoss(with_logits=False)
batch_size, classes, height, width = 5, 4, 64, 64
pred = torch.randn(batch_size, classes, height, width, requires_grad=True)
target = torch.empty(batch_size, classes, height, width).random_(2)
output = loss(m(pred), target)
output.backward()
Graphs
Plot of the value of the loss between the prediction and target without the BCE component. Target is a random binary 256x256 matrix. For Random the prediction is a 256x256 matrix of probabilities initialized uniformly at random. For All zero the prediction is a 256x256 matrix with all zeros. For 1- target the prediction is the inverse of the target. The prediction is interpolated with the target by: input_i = (1 - α) * input + α * target.
Difference between this implementation and the implementation in the official git repository, with EPSILON = 0.0005 and pool='max'.
Execution time on tensors with batch size of 8 and with 21 classes.
Size |
This |
Official |
|---|---|---|
8x21x32x32 |
6.5722ms |
6.3261ms |
8x21x64x64 |
11.8159ms |
12.6169ms |
8x21x128x128 |
39.9946ms |
40.3798ms |
8x21x256x256 |
160.0352ms |
160.9543ms |
Metadata
Release files for rmi-pytorch 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rmi-pytorch-0.1.1.tar.gz | 4.6 kB | Without provenance | Details for rmi-pytorch-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rmi_pytorch-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for rmi_pytorch-0.1.1-py3-none-any.whl |
Total release size: 9.6 kB
Release files / rmi-pytorch-0.1.1.tar.gz
| Download URL | rmi-pytorch-0.1.1.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
553b69fbd08f89e0628c940159c39526dff2ea6750fbff38a83e70ce32067717
|
|
BLAKE2b-256 checksum How to use checksums |
a40e0c66ab6f0197b99f5117728207d8e642ab8b89430c2e316366e0a35b673a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.2
|
Release files / rmi_pytorch-0.1.1-py3-none-any.whl
| Download URL | rmi_pytorch-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
efe0e41ccdda7828745ebc548e135709db151425a5c07c578f1e5a3a77cf24b1
|
|
BLAKE2b-256 checksum How to use checksums |
4a3c65abcde92e9cc2cea3f39c6b488ccf63ffdd9fd7701a6cd8d6a37fd0d127
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.0 setuptools/51.1.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.7.2
|
Security for rmi-pytorch 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.