New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add torch metrics support #1195
Comments
Nice catch! |
I think it will be easier to check types of inputs and use |
why you could not specify that during init? |
Sometimes people may have no ideas about types. And it also will be much easier to use this thing. Can we assume that |
the problem here is that it requires you to check the type each batch, which is some kind of slow |
And what about the function that will redefine itself on the first batch? In this case, |
馃 do you have an example of such a function? |
class Metric:
# ...
def update(self, value, ...):
self.value = self.compute_wrapper(value)
# ...
def compute_wrapper(self, value):
if torch.is_tensor(value):
self.compute_wrapper = catalyst.utils.detach_tensor
else:
self.compute_wrapper = lambda x: x
def compute(self):
# ...
return value |
why should we use such a metric with undefined behavior? do you have any real-metric examples? |
馃悰 Bug Report
AdditiveValueMetric
assumes that the metric value can be converted to float / NumPy array. But in reality, there are many cases when it is much faster and easier to calculate metrics on GPU using PyTorch. And this will cause errors astorch.Tensor
cannot be converted to NumPy automatically.How To Reproduce
Steps to reproduce the behavior:
FunctionalMetricCallback
with any metric function that returnstorch.Tensor
e.g.piq.psnr
Code sample
https://github.com/leverxgroup/esrgan/blob/update-catalyst/esrgan/callbacks/metrics.py#L20
Expected behavior
It would be great if
utils.detach_tensor
was used before metrics averaging.Environment
Please copy and paste the output from our environment collection script
catalyst-contrib --collect-env # or manually wget https://raw.githubusercontent.com/catalyst-team/catalyst/master/catalyst/contrib/scripts/collect_env.py python collect_env.py
(or fill out the checklist below manually).
# example checklist, fill with your info Catalyst version: 20.04.2 PyTorch version: 1.8.0 TensorFlow version: N/A TensorBoard version: 2.2.1 OS: Ubuntu 20.04 LTS Python version: 3.8 CUDA runtime version: No CUDA Nvidia driver version: No CUDA cuDNN version: No CUDA
Additional context
Checklist
FAQ
Please review the FAQ before submitting an issue:
The text was updated successfully, but these errors were encountered: