Closed birkantunc closed 6 months ago
I'm not sure what to do about this. It will always be specific to a version I guess. Any ideas @birkantunc ?
here is another problem related to this one and a possible solution:
Issue: After loading the learned dictionary using np.load()
basis_set = np.load(localized_basis_file, allow_pickle=True).item()
dictionary = basis_set[feat]
you cannot set any parameters, for example, to increase the number of iterations for transform()
dictionary.set_params(transform_max_iter=2000)
This gives the following error:
AttributeError: 'DictionaryLearning' object has no attribute 'callback'
After further investigation, I realized the loaded object was not an instance of the class
sklearn.decomposition.DictionaryLearning
but instead
sklearn.decomposition._dict_learning.DictionaryLearning
That is, there might be an issue with serialization.
Possible Solution: How about instead of dumping the object into disk, dumping all relevant attributes (coefficients, etc.) and then after loading them from the disk, you can create a new sklearn.decomposition.DictionaryLearning object and set all the attributes back?
We can access the basis matrix with basis_set[feat].components_
even when we get the callback error when we try to access basis_set[feat]
. For now we'll leave this here, hoping that this version compatibility won't lead to severe errors. In the future we'll likely implement the sparse dictionary learning ourselves, otherwise we may always have version-related issues.
With the estimation of localized expressions coefficients (_compute_local_expcoefficients.py), a
.npy
file that was created using scikit-learn==1.1.3, is loaded. When the install scikit-learn version is different we get the following warning.