Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
qubvel committed Aug 7, 2019
1 parent 206b4e4 commit 9a5280b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 17 deletions.
6 changes: 3 additions & 3 deletions segmentation_models/losses.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ class DiceLoss(Loss):
.. math:: L(tp, fp, fn) = \frac{(1 + \beta^2) \cdot tp} {(1 + \beta^2) \cdot fp + \beta^2 \cdot fn + fp}
where:
tp - true positives;
fp - false positives;
fn - false negatives;
- tp - true positives;
- fp - false positives;
- fn - false negatives;
Args:
beta: Float or integer coefficient for precision and recall balance.
Expand Down
24 changes: 18 additions & 6 deletions segmentation_models/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ class IOUScore(Metric):
threshold: value to round predictions (use ``>`` comparison), if ``None`` prediction will not be round
Returns:
A callable ``iou_score`` instance. Can be passed to ``model.compile(..., metrics=[iou_score])``.
A callable ``iou_score`` instance. Can be used in ``model.compile(...)`` function.
.. _`Jaccard index`: https://en.wikipedia.org/wiki/Jaccard_index
Example:
.. code:: python
metric = IOUScore()
model.compile('SGD', loss=loss, metrics=[metric])
"""

def __init__(self, class_weights=None, threshold=None, per_image=True, smooth=SMOOTH):
Expand Down Expand Up @@ -56,12 +62,12 @@ class FScore(Metric):
The formula in terms of *Type I* and *Type II* errors:
.. math:: F_\beta(A, B) = \frac{(1 + \beta^2) TP} {(1 + \beta^2) TP + \beta^2 FN + FP}
.. math:: L(tp, fp, fn) = \frac{(1 + \beta^2) \cdot tp} {(1 + \beta^2) \cdot fp + \beta^2 \cdot fn + fp}
where:
TP - true positive;
FP - false positive;
FN - false negative;
- tp - true positives;
- fp - false positives;
- fn - false negatives;
Args:
beta: f-score coefficient
Expand All @@ -72,8 +78,14 @@ class FScore(Metric):
threshold: value to round predictions (use ``>`` comparison), if ``None`` prediction will not be round
Returns:
callable: f_score
A callable ``f_score`` instance. Can be used in ``model.compile(...)`` function.
Example:
.. code:: python
metric = FScore()
model.compile('SGD', loss=loss, metrics=[metric])
"""

def __init__(self, beta=1, class_weights=None, threshold=None, per_image=True, smooth=SMOOTH):
Expand Down
16 changes: 8 additions & 8 deletions segmentation_models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ def set_trainable(model, recompile=True, **kwargs):
Note:
Model is recompiled using same optimizer, loss and metrics::
model.compile(
model.optimizer,
loss=model.loss,
metrics=model.metrics,
loss_weights=model.loss_weights,
sample_weight_mode=model.sample_weight_mode,
weighted_metrics=model.weighted_metrics,
)
model.compile(
model.optimizer,
loss=model.loss,
metrics=model.metrics,
loss_weights=model.loss_weights,
sample_weight_mode=model.sample_weight_mode,
weighted_metrics=model.weighted_metrics,
)
Args:
model (``keras.models.Model``): instance of keras model
Expand Down

0 comments on commit 9a5280b

Please sign in to comment.