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

Train with Fewer Classes #34

Open
adraffy opened this issue Feb 6, 2017 · 2 comments
Open

Train with Fewer Classes #34

adraffy opened this issue Feb 6, 2017 · 2 comments

Comments

@adraffy
Copy link

adraffy commented Feb 6, 2017

I'm not sure how to resize the net properly to reduce the number of output classes.

When I reduce the number of classes in the prototxt, I get dimensional issues while trying to copy values from the base model:

Cannot copy param 0 weights from layer 'inference1'; shape mismatch. Source param shape is 1 1 21 21 (441); target param shape is 1 1 2 2 (4). To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer.

If I rename the resized layers so the weights aren't copied over, solver.py complains that the layers are "composed of zeros!"

What is the appropriate way to retain the initial weights but reduce the number of output classes?

Thanks!

@adraffy
Copy link
Author

adraffy commented Feb 6, 2017

I found this code which just copies over the values in the case where the number of classes is expanding:
https://github.com/shelhamer/fcn.berkeleyvision.org/blob/master/surgery.py
def expand_score(new_net, new_layer, net, layer):

Doing something like the opposite for reducing the number of classes from 21 to 3 (or whatever) makes sense to me but it was missing from the instructions.

@codepujan
Copy link

hey @adraffy . Did youhave any succes in doing net Surgery for smaller number of class (3) in your case ?

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

2 participants