Fix loading of saved models with class weights#431
Fix loading of saved models with class weights#431Timoeller merged 5 commits intodeepset-ai:masterfrom
Conversation
|
An easy fix (hack) would be to pass FARM/farm/modeling/adaptive_model.py Line 323 in 451bc0b This would avoid the exception but I am not sure if it fixees the underlying problem. |
|
The bug also happens when PyTorch 1.4.0 is used. I tested it. This is very strange. What did FARM do to introduce this bug? I am pretty sure that the early stopping example was ok 3 weeks ago... |
925ea19 to
7c671d8
Compare
|
Well, long debugging, quick fix. :-) |
- throw ValueError - add test
|
Because we convert the class_weights to a list I added a check that the numpy array has exactly one dimension. |
Timoeller
left a comment
There was a problem hiding this comment.
Thanks @PhilipMay , well spotted. This fixes our saving + loading issues.
Calling json.dump on numpy class weights should result in TypeError: Object of type 'ndarray' is not JSON serializable
Weird that this error happens silently and class weights are simply omitted when saving the Prediction Head config. I might look into this another time.
Thanks for the changes and for adding a dedicated test case.
It is because you checked if it can be converted to json: |

This is a PR regarding #428 and #422
TODO