fastmtl
Multi-task learning utilities for fastai
Install
pip install fastmtl
Usage
Loss
Apply a loss function per model output and get weighted sum of them. For instance, if the first model output is for classification and the second model output is for regression,
from fastmtl.loss import CombinedLoss
loss_func = CombinedLoss(CrossEntropyLossFlat(), MSELossFlat(), weight=[1.0, 3.0])
Metric
Apply metrics for each model output. For instance, if we have a model making classification and regression, we can evaluate each model output with relevant metrics. Assuming that model outputs a tuple of tensors for classification and regression, respectively:
from fastai.metrics import F1Score, R2Score
from fastmtl.metric import mtl_metrics
clf_f1_macro = F1Score(average='macro')
clf_f1_macro.name = 'clf_f1(macro)'
clf_f1_micro = F1Score(average='micro')
clf_f1_micro.name = 'clf_f1(micro)'
reg_r2 = R2Score()
reg_r2.name = 'reg_r2'
# metrics for classification in the first list
# metrics for regression in the second list
metrics = mtl_metrics([clf_f1_macro, clf_f1_micro], [reg_r2])
learn = Learner(
...
metrics=metrics,
)
Tutorials
TODO
- Support tabular learner
- Support fastai>=2.7
Metadata
Release files for fastmtl 1.2.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 |
|---|---|---|---|---|
| fastmtl-1.2.1.tar.gz | 10.0 kB | Without provenance | Details for fastmtl-1.2.1.tar.gz |
Release files / fastmtl-1.2.1.tar.gz
| Download URL | fastmtl-1.2.1.tar.gz |
|---|---|
| Size | 10.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f3e100a9933f9b268845e8c26b3ec652133dcb842a2d2172472067d4c1bc2567
|
|
BLAKE2b-256 checksum How to use checksums |
4fa80b71003543840b5e96359c5678070e2445583ca759eba009013b9b320d5c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Security for fastmtl 1.2.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.