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

Why only none-linear activation will be accepted? #39

Open
pgr2015 opened this issue Nov 11, 2019 · 1 comment
Open

Why only none-linear activation will be accepted? #39

pgr2015 opened this issue Nov 11, 2019 · 1 comment

Comments

@pgr2015
Copy link

pgr2015 commented Nov 11, 2019

Hi, there are some linear activation layers in my model. Since the keras-surgeon won't take linear activation layer into account, the pruning for my model failed.
Here is the code in Keras-Surgeon:
https://github.com/BenWhetton/keras-surgeon/blob/master/src/kerassurgeon/utils.py#L143
My question is then. Why only none-linear activation will be accepted? What if I add the if-statement for linear-activation? Will it cause problem to the original logic of the source code?
Any idea? Thanks in advance!

@pgr2015
Copy link
Author

pgr2015 commented Nov 11, 2019

My fix would be like this, quite straight forward. But I have strong concern that this change will break original logic of the source code.

        if activation.__name__ != 'linear':
            if maybe_layer.get_output_shape_at(node_index) != output_shape:
                ValueError('The activation layer ({0}), does not have the same'
                           ' output shape as {1}'.format(maybe_layer.name,
                                                         layer.name))
            return maybe_layer, node_index

        if activation.__name__ == 'linear':
            if maybe_layer.get_output_shape_at(node_index) != output_shape:
                ValueError('The activation layer ({0}), does not have the same'
                           ' output shape as {1}'.format(maybe_layer.name,
                                                         layer.name))
            return maybe_layer, node_index

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

1 participant