Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resnet18: AttributeError: 'SVDDecomposedConvLayer' object has no attribute 'min_rank' #13

Open
aupuzikov opened this issue Jan 22, 2021 · 6 comments

Comments

@aupuzikov
Copy link

aupuzikov commented Jan 22, 2021

I've tried to compress my resnet18 and failed. SVDDecomposedConvLayer has no min_rank field. I'm getting exception.

Anaconda3\envs\musco\lib\site-packages\musco\pytorch\compressor\decompositions\svd_layer.py in __init__(self, layer, layer_name, rank_selection, rank, pretrained, vbmf_weaken_factor, param_reduction_rate)
    157 
    158         if rank_selection == 'vbmf':
--> 159             self.rank = estimate_vbmf_ranks(self.weight, vbmf_weaken_factor, min_rank = self.min_rank)
    160         elif rank_selection == 'manual':
    161             self.rank = rank

AttributeError: 'SVDDecomposedConvLayer' object has no attribute 'min_rank'

because of 6e4c947

@aupuzikov
Copy link
Author

hi everybody! can anyone fix it? doesn't seem like a big issue more like a bug.

@aupuzikov
Copy link
Author

https://github.com/musco-ai/musco-pytorch/blob/master/musco/pytorch/compressor/decompositions/svd_layer.py#L168
looks like out_features/in_features should be considered too....

@aswanthkrishna
Copy link

any fix?

@juliagusak
Copy link
Member

Hi @aupuzikov and @aswanthkrishna, thank you for noticing this bug! Now it is fixed

@aswanthkrishna
Copy link

thanks a lot :)

@styler00dollar
Copy link

It seems not to be fixed if it gets installed with pip. I still have:

~/anaconda3/lib/python3.8/site-packages/musco/pytorch/compressor/decompositions/svd_layer.py in __init__(self, layer, layer_name, rank_selection, rank, pretrained, vbmf_weaken_factor, param_reduction_rate)
    157 
    158         if rank_selection == 'vbmf':
--> 159             self.rank = estimate_vbmf_ranks(self.weight, vbmf_weaken_factor, min_rank = self.min_rank)
    160         elif rank_selection == 'manual':
    161             self.rank = rank

AttributeError: 'SVDDecomposedConvLayer' object has no attribute 'min_rank'

I used musco-pytorch 1.0.6. Solution:

pip uninstall musco-pytorch -y
git clone https://github.com/musco-ai/musco-pytorch
cd musco-pytorch
python setup.py install

This results in:

~/anaconda3/lib/python3.8/site-packages/numpy/linalg/linalg.py in _raise_linalgerror_svd_nonconvergence(err, flag)
    104 
    105 def _raise_linalgerror_svd_nonconvergence(err, flag):
--> 106     raise LinAlgError("SVD did not converge")
    107 
    108 def _raise_linalgerror_lstsq(err, flag):

LinAlgError: SVD did not converge

or

~/anaconda3/lib/python3.8/site-packages/numpy/lib/function_base.py in asarray_chkfinite(a, dtype, order)
    495     a = asarray(a, dtype=dtype, order=order)
    496     if a.dtype.char in typecodes['AllFloat'] and not np.isfinite(a).all():
--> 497         raise ValueError(
    498             "array must not contain infs or NaNs")
    499     return a

ValueError: array must not contain infs or NaNs

Which would be a new issue though, but I thought I at least mention it. The output seems random. Used code from Github readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants