kliff icon indicating copy to clipboard operation
kliff copied to clipboard

RMSE analyzer bug

Open michaelmacisaac opened this issue 2 years ago • 1 comments

Describe the bug With the current RMSE analyzer, when one runs it an error occurs in the "_to_numpy" function. The error is on the line with the modification: x[0].detach().numpy()

The error is prompted because there is a complication with converting a cuda tensor to a numpy array.

My work around is simple. simply modify to: x[0].detach().cpu().numpy()

this sends the data to the cpu.

An additional error I encountered was in the RMSE.py script from lines 160-164. Here an error associated with the print command occurred. The issue seemed to be resolved when I replaced the use of ".format()" with the use of f-strings. image

To Reproduce To reproduce, run the current RMSE analyzer

Expected behavior RMSE analyzer should calculate the RMSE

Screenshots

_to_numpy function mod:

def _to_numpy(x, compute_argument): """ Convert to a numpy array from a tensor.

`compute_argument` is needed to determine whether ``x`` is a list of tensor of a numpy
array.
"""
if isinstance(compute_argument, Iterable):
    return x[0].detach().cpu().numpy() #added '.cpu()'
else:
    return x

Additional context Windows operating system Python 3.7

michaelmacisaac avatar Oct 06 '22 16:10 michaelmacisaac

Thanks @michaelmacisaac!

I can confirm that the error related to _to_numpy() is a bug. The script is created without considering gpu and yours is correct. Can you make a PR to correct this?

For the string error, I cannot reproduce it on Mac and Linux. Not sure why it does not work on Win. Are you using linux subsystem on Win?

mjwen avatar Oct 07 '22 02:10 mjwen