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

Neuron Conductance Tuple Support #602

Closed
wants to merge 4 commits into from

Conversation

vivekmig
Copy link
Contributor

This adds support for Neuron Conductance to allow a callable for selector function, as long as this function is used for selection rather than aggregation. This functionality allows neuron conductance to work with layers which may have input or output as a tuple of tensors.

Copy link
Contributor

@NarineK NarineK left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for woking on this PR, @vivekmig!
I left a small nit.

net, net.multi_relu, inp, lambda x: x[0][:, 1], [0.0, 6.0, 0.0]
)
lc = LayerConductance(net, net.multi_relu)
print(lc.attribute(inp, target=0))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this printout ? Did you wanted to assert with the results from Layer Conductance ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, good catch thanks! Was initially going to do that, but then made it a separate test, forgot to remove this.

self._conductance_input_test_assert(
net, net.linear1, inp, lambda x: x[:, 0], [0.0, 90.0, 0.0]
)

Copy link
Contributor

@NarineK NarineK Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a test model that has a custom layer which returns a tuple, could we, please, add a test for that too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I think both the other 2 added tests cover this case. Passing multi_input_module=True uses a custom layer MultiRelu, which returns a tuple.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vivekmig has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

- a callable, which should
take the target layer as input (single tensor or tuple
if multiple tensors are in layer) and return a selected
neuron (output shape should be 1D with length equal to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mismatched parens here

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vivekmig has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@facebook-github-bot
Copy link
Contributor

@vivekmig merged this pull request in f4a5b78.

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

Successfully merging this pull request may close these issues.

None yet

4 participants