-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add back compatibility for deprecated metrics 1/n (#5067)
* add back compatibility for metrics * tests * Add deprecated metric utility functions back to functional (#5062) * add back *deprecated* metric utility functions to functional * pep * pep * suggestions * move Co-authored-by: Jirka Borovec <[email protected]> * more * fix * import * docs * tests * fix Co-authored-by: Teddy Koker <[email protected]>
- Loading branch information
1 parent
ddc3757
commit 4a3f906
Showing
5 changed files
with
306 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# Copyright The PyTorch Lightning team. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
import torch | ||
|
||
from pytorch_lightning.metrics.utils import reduce as __reduce, class_reduce as __cr | ||
from pytorch_lightning.utilities import rank_zero_warn | ||
|
||
|
||
def reduce(to_reduce: torch.Tensor, reduction: str) -> torch.Tensor: | ||
rank_zero_warn( | ||
"This `reduce` was deprecated in v1.1.0 in favor of" | ||
" `pytorch_lightning.metrics.utils import reduce`." | ||
" It will be removed in v1.3.0", DeprecationWarning | ||
) | ||
return __reduce(to_reduce=to_reduce, reduction=reduction) | ||
|
||
|
||
def class_reduce(num: torch.Tensor, denom: torch.Tensor, weights: torch.Tensor, class_reduction: str = 'none'): | ||
rank_zero_warn( | ||
"This `class_reduce` was deprecated in v1.1.0 in favor of" | ||
" `pytorch_lightning.metrics.utils import class_reduce`." | ||
" It will be removed in v1.3.0", DeprecationWarning | ||
) | ||
return __cr(num=num, denom=denom, weights=weights, class_reduction=class_reduction) |
Oops, something went wrong.