dvgodoy / deepreplay

Deep Replay - Generate visualizations as in my "Hyper-parameters in Action!" series!
https://towardsdatascience.com/hyper-parameters-in-action-a524bf5bf1c
MIT License
271 stars 48 forks source link

Custom metrics #13

Closed BWallyn closed 2 years ago

BWallyn commented 5 years ago

Thank you for the job done, it's really impressive.

I have encountered a problem when working with custom metrics. Indeed, custom metrics are passed to the model as functions, not strings, which does not work with self.group.create_dataset(metric, shape=(self.n_epochs,), dtype='f')

Here is the error I get when running : File "C:\Users\AppData\Local\Continuum\anaconda3\lib\site-packages\deepreplay\callbacks.py", line 62, in __init__ self.on_train_begin() File "C:\Users\AppData\Local\Continuum\anaconda3\lib\site-packages\deepreplay\callbacks.py", line 109, in on_train_begin self.group.create_dataset(metric, shape=(self.n_epochs,), dtype='f') File "C:\Users\AppData\Roaming\Python\Python36\site-packages\h5py\_hl\group.py", line 119, in create_dataset self[name] = dset File "C:\Users\AppData\Roaming\Python\Python36\site-packages\h5py\_hl\group.py", line 284, in __setitem__ name, lcpl = self._e(name, lcpl=True) File "C:\Users\AppData\Roaming\Python\Python36\site-packages\h5py\_hl\base.py", line 132, in _e name = name.encode('ascii') AttributeError: 'function' object has no attribute 'encode'

dvgodoy commented 5 years ago

Thanks :-) And thank you for reporting the issue. I was indeed assuming a string for the name of the metric and used it to create a group inside the H5 file. I will fix this by testing the metric passed as argument and, if it is a function, take its name to create the corresponding group.

dvgodoy commented 5 years ago

Hi @BWallyn ,

It has been a looong while, but I've finally released a version that fixes the problem of custom metrics :-)