topoloss
Project description
topoloss
topoloss
pip install topoloss
Example
import torchvision.models as models
from topoloss import TopoLoss, LaplacianPyramidLoss
# Load a pre-trained ResNet-18 model
model = models.resnet18(pretrained=False)
# define where to apply the topo loss
topo_loss = TopoLoss(
losses=[
LaplacianPyramidLoss.from_layer(
model=model,
layer=model.layer3[1].conv2,
factor_h=3.0,
factor_w=3.0,
)
## add more layers here if you want :)
]
)
# Compute the loss
loss = topo_loss.compute(model=model)
loss.backward()
print(f"Computed topo loss: {loss.item()}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
topoloss-0.0.0.tar.gz
(3.4 kB
view details)
Built Distribution
File details
Details for the file topoloss-0.0.0.tar.gz
.
File metadata
- Download URL: topoloss-0.0.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3bda957e8a9b0f52fdf18433c5dc1dfb7adea9427daa82ff9472ae99da648f3 |
|
MD5 | 4318b7089b21eb32648d2d5650ad70ee |
|
BLAKE2b-256 | e382ee3be494114bfa5ed7e7a4cbabdbe819a16fb0264fc49b6e109093fe671f |
File details
Details for the file topoloss-0.0.0-py3-none-any.whl
.
File metadata
- Download URL: topoloss-0.0.0-py3-none-any.whl
- Upload date:
- Size: 3.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30e56b068db873112fa5ced01389d069c8a40c40aa595645c697588968d9563e |
|
MD5 | 4546da59a05a200396fc33bc74324c63 |
|
BLAKE2b-256 | 2b5c4ffc4d166902f19b3a37a0c91817d67a0b86d9d4cea4f9d8a85df979f538 |