djl icon indicating copy to clipboard operation
djl copied to clipboard

Remove final from EasyTrain so that we can extend it

Open hmf opened this issue 4 years ago • 4 comments

Description

I am working on data with labels but do not use those labels for learning and inference - unsupervised learning with auto-encoders. I do need the labels later for validation though, so creating a DataSet that sets the labels to be the same as the data and loosing the label information, won't solve my problem. To get this working, I changed EasyTrain.java of version 0.9.0, to set the labelmember equal to the data member. However, EasyTrain has been updated, and will in the future most probably be updated again. It is much easier for users to simply extend the class and change the required behavior. In my case just change the trainSplit and validateSplit methods.

Will this change the current api? How?

Removing the final qualifier won't change the API, so most users won't even be aware of the change.

Who will benefit from this enhancement?

Anyone that has to adapt the EasyTrain class to do something similar to the already existing class.

hmf avatar May 04 '21 12:05 hmf

This seems reasonable. Would you like to open a PR?

You will probably have to add a @SuppressWarnings annotation to the EasyTrain as well because one of our checkers thinks utility classes should be final.

zachgk avatar May 04 '21 17:05 zachgk

On my to-do list. Thanks.

hmf avatar May 06 '21 08:05 hmf

@hmf EasyTrain is a utility class. It doesn't make sense to have a class inherit to it. Even you have a subclass and you changed trainSplit, it's a completely independent class.

If you want to customize some of the behavior, the right way to do is add a new parameter to the training options, and EasyTrain will do different thing based on the option.

frankfliu avatar May 06 '21 17:05 frankfliu

@frankfliu How would one parametrize the requirements I described above? I don't think I can come up with a set of parameters that are generic enough to be useful for other users. Also I only have this use case that seems very specific. Do you have any other functionality in mind that could/should be parametrized.

TIA

hmf avatar May 06 '21 17:05 hmf