|
4 | 4 | import torch |
5 | 5 | import torch.distributed |
6 | 6 |
|
7 | | -from pytorch_lightning.metrics.convertors import tensor_metric, numpy_metric |
| 7 | +from pytorch_lightning.metrics.converters import tensor_metric, numpy_metric |
8 | 8 | from pytorch_lightning.utilities.apply_func import apply_to_collection |
9 | 9 |
|
10 | 10 | __all__ = ['Metric', 'TensorMetric', 'NumpyMetric'] |
@@ -35,7 +35,7 @@ def dtype(self) -> Union[str, torch.dtype]: |
35 | 35 |
|
36 | 36 | @dtype.setter |
37 | 37 | def dtype(self, new_dtype: Union[str, torch.dtype]): |
38 | | - # Necessary to avoid infinite recursion |
| 38 | + # necessary to avoid infinite recursion |
39 | 39 | raise RuntimeError('Cannot set the dtype explicitly. Please use metric.to(new_dtype).') |
40 | 40 |
|
41 | 41 | @property |
@@ -107,25 +107,19 @@ def to(self, *args, **kwargs) -> torch.nn.Module: |
107 | 107 | tensor([[0.4963, 0.7682, 0.0885, 0.1320], |
108 | 108 | [0.3074, 0.6341, 0.4901, 0.8964], |
109 | 109 | [0.4556, 0.6323, 0.3489, 0.4017]]) |
110 | | - >>> metric.to(torch.double) |
| 110 | + >>> metric.to(torch.double) #doctest: +ELLIPSIS |
111 | 111 | ExampleMetric() |
112 | 112 | >>> metric.weight |
113 | | - tensor([[0.4963, 0.7682, 0.0885, 0.1320], |
114 | | - [0.3074, 0.6341, 0.4901, 0.8964], |
115 | | - [0.4556, 0.6323, 0.3489, 0.4017]], dtype=torch.float64) |
| 113 | + tensor([[...]], dtype=torch.float64) |
116 | 114 | >>> cpu = torch.device('cpu') |
117 | 115 | >>> metric.to(cpu, dtype=torch.half, non_blocking=True) |
118 | 116 | ExampleMetric() |
119 | | - >>> metric.weight |
120 | | - tensor([[0.4963, 0.7682, 0.0885, 0.1320], |
121 | | - [0.3074, 0.6341, 0.4901, 0.8964], |
122 | | - [0.4556, 0.6323, 0.3489, 0.4017]], dtype=torch.float16) |
| 117 | + >>> metric.weight #doctest: +ELLIPSIS |
| 118 | + tensor([[...]], dtype=torch.float16) |
123 | 119 | >>> metric.to(cpu) |
124 | 120 | ExampleMetric() |
125 | | - >>> metric.weight |
126 | | - tensor([[0.4963, 0.7682, 0.0885, 0.1320], |
127 | | - [0.3074, 0.6341, 0.4901, 0.8964], |
128 | | - [0.4556, 0.6323, 0.3489, 0.4017]], dtype=torch.float16) |
| 121 | + >>> metric.weight #doctest: +ELLIPSIS |
| 122 | + tensor([[...]], dtype=torch.float16) |
129 | 123 |
|
130 | 124 |
|
131 | 125 | """ |
|
0 commit comments