Calculates the entropy per class over dropout cycles As it is explicitly formulated in: Deep Bayesian Active Learning with Image Data. (Yarin Gal, Riashat Islam, and Zoubin Ghahramani. 2017.) Args: proba: list with the predictions ove
(proba: list)
| 319 | |
| 320 | |
| 321 | def _entropy(proba: list) -> np.ndarray: |
| 322 | """ |
| 323 | Calculates the entropy per class over dropout cycles |
| 324 | |
| 325 | As it is explicitly formulated in: |
| 326 | Deep Bayesian Active Learning with Image Data. |
| 327 | (Yarin Gal, Riashat Islam, and Zoubin Ghahramani. 2017.) |
| 328 | |
| 329 | Args: |
| 330 | proba: list with the predictions over the dropout cycles |
| 331 | mask: mask to detect the padded classes (must be of same shape as elements in proba) |
| 332 | Return: |
| 333 | Returns the entropy of the dropout cycles over all classes. |
| 334 | """ |
| 335 | |
| 336 | proba_stacked = np.stack(proba, axis=len(proba[0].shape)) |
| 337 | |
| 338 | # calculate entropy per class and sum along dropout cycles |
| 339 | entropy_classes = entropy_sum(proba_stacked, axis=-1) |
| 340 | entropy = np.mean(entropy_classes, where=~ |
| 341 | np.isnan(entropy_classes), axis=-1) |
| 342 | return entropy |
| 343 | |
| 344 | |
| 345 | def _variation_ratios(proba: list) -> np.ndarray: |
no test coverage detected
searching dependent graphs…