Skip to content
This repository has been archived by the owner on May 1, 2023. It is now read-only.

Modify a bug in ranked_structures_pruner.py while running AMC #429

Closed
csc12138 opened this issue Nov 18, 2019 · 4 comments
Closed

Modify a bug in ranked_structures_pruner.py while running AMC #429

csc12138 opened this issue Nov 18, 2019 · 4 comments

Comments

@csc12138
Copy link

While running AMC, there is an error:
in the file distiller/distiller/pruning/ranked_structures_pruner.py
op_type is not defined,

After reviewing author's modification history, in the previous version of this file, in this function: "rank_and_prune_channels":
op_type = 'conv' if param.dim() == 4 else 'fc'

However, for the current version, this line of code is removed, so I guess, something like this should be added into the current version in order to fix this bug

@nzmora
Copy link
Contributor

nzmora commented Nov 18, 2019

Thanks @csc12138, what's the command-line you are executing?

@wangyidong3
Copy link

Thanks @csc12138, I got the same error, and then tried the way @csc12138 mentioned to solve it.
My command is :
python3 amc.py --arch=resnet20_cifar /media/don/datasets/datasets/cifar-10-batches-py --resume=../../ssl/checkpoints/checkpoint_trained_dense.pth.tar --amc-action-range 0.05 1.0 --amc-target-density=0.5 -p=50 --etes=0.075 --amc-ft-epochs=0 --amc-prune-pattern=channels --amc-prune-method=fm-reconstruction --amc-agent-algo=DDPG --amc-cfg=auto_compression_channels.yaml --amc-rllib=hanlab -j=1
I removed "--amc" in original command-line as it is not recognized.

Here are other issues and temperay solutions I found when I run the command, hope it is useful for others.
AssertionError : assert self.removed_macs_pct >= 1 - self.amc_cfg.target_density - 0.002 # 0.01
assertionError
it is difficult to adjust the parameter to pass the assertion, so I comment this line to continue.

One more similar issue is that: name 'ALMOST_ONE' is not defined
ALMOST_ONE
I re-add ALMOST_ONE = 0.9999 in environment.py line38, then training started properly.

nzmora added a commit that referenced this issue Nov 28, 2019
- define ALMOST_ONE
- define op_type
- remove sanity assert (need to understand what tolerance value to use
in the assert)
@nzmora
Copy link
Contributor

nzmora commented Nov 28, 2019

Thanks @csc12138, @wangyidong3 for opening this issue and suggesting the solution. I've pushed a fix. Let me know if there are further problems with this example.
Thanks!
Neta

nzmora added a commit that referenced this issue Nov 28, 2019
- define ALMOST_ONE
- define op_type
- remove sanity assert (need to understand what tolerance value to use
in the assert)

Co-authored-by: csc12138
Co-authored-by: wangyidong3
@levzlotnik
Copy link
Contributor

Hi,

Closing this issue as it seems resolved.

michaelbeale-IL pushed a commit that referenced this issue Apr 24, 2023
- define ALMOST_ONE
- define op_type
- remove sanity assert (need to understand what tolerance value to use
in the assert)
michaelbeale-IL pushed a commit that referenced this issue Apr 24, 2023
- define ALMOST_ONE
- define op_type
- remove sanity assert (need to understand what tolerance value to use
in the assert)

Co-authored-by: csc12138
Co-authored-by: wangyidong3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants