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

add non-stochastic inference mode to quantizers #25

Conversation

jecorona97
Copy link
Contributor

Currently, models with stochastic quantizers peform stochastic operations even in inference mode. This mechanism prevents this and uses the non-stochastic version of the quantizer if in inference mode.

Duchstf and others added 30 commits February 3, 2020 12:55
PiperOrigin-RevId: 293813781
Change-Id: Id4539ccc5b3e252c08b7df67b94bea04d2dd0382
remove QActivation and kernel/bias_quantizer check.

PiperOrigin-RevId: 294296495
Change-Id: I1aa49fba7850c63f00c8b905cf448540aa3789d8
PiperOrigin-RevId: 294987571
Change-Id: I63d548bc9516ef595e40d6e736e6eb48e39689ea
PiperOrigin-RevId: 295783821
Change-Id: I0c541eaabe348ca5d9422be18d3877ef1206ce6d
…elu_po2.

PiperOrigin-RevId: 296483972
Change-Id: Ia9aa5e652496c8cb4869bf964afd2c163649f01c
PiperOrigin-RevId: 296515539
Change-Id: I0c3d84919459141a2725ada025c74d5a176d5dc3
PiperOrigin-RevId: 297473595
Change-Id: I300a5d241523d0ea09f4d2004e64f94dde6748d3
PiperOrigin-RevId: 299386814
Change-Id: I6208f7a03b4d9a2863116cfa1b0b024a3893d070
- Add alpha, get_scale function for binary and ternary quantizers.
- Control the initial weight distribution with respect to fan-in of layers.

PiperOrigin-RevId: 302736657
Change-Id: I296d8fe267f9fb47e45ad3bdddac1d7a332c155c
Enhance initialize in qlayer.py.

PiperOrigin-RevId: 305970234
Change-Id: I5ad84a632ce0be6108ba13b8c554be4cbe34b038
add qtools/qenergy: for qkeras energy and power estimations.

PiperOrigin-RevId: 308871576
Change-Id: I287298f74938f5709ad78a5523cabde94e5ad166
PiperOrigin-RevId: 309327349
Change-Id: Iabf1d6ce09bc898d1fe1a419009e7bf4ea303d02
…Changing this temporarily until other platforms are fixed.

PiperOrigin-RevId: 310066976
Change-Id: I0819268839c0a0bcb2e7e1867ca749752e1accfe
PiperOrigin-RevId: 310412069
Change-Id: I81f83c0d7b033cdc3ad8ce5e0f51c60497a52587
- Nonetype check for stochastic_ternary.alpha in __call__ method
- Test for stochastic_ternary.alpha = Nonetype behavior
PiperOrigin-RevId: 314435784
Change-Id: Ic9b1dc650ce1efdd159a0715461bac7a66c5fa0a
@zhuangh
Copy link
Contributor

zhuangh commented Jun 4, 2020

PiperOrigin-RevId: 314828141
Change-Id: I03fdd6830f88b2ba31b5fb5f54c6c3ced39d8827
@zhuangh
Copy link
Contributor

zhuangh commented Jun 5, 2020

Hey @jecorona97

The error is "referenced before assignment"

E         tensorflow.python.autograph.impl.api.StagingError: in user code:
E         
E             /home/travis/virtualenv/python3.7.1/lib/python3.7/site-packages/qkeras/qnormalization.py:204 call  *
E                 training = self._get_training_value(training)
E         
E             UnboundLocalError: local variable 'training' referenced before assignment

@zhuangh zhuangh added ready to pull to trigger copybara-service and removed ready to pull to trigger copybara-service labels Jun 6, 2020
when x == const != 0, std = 0.0, x/std = inf

PiperOrigin-RevId: 315036769
Change-Id: I6e48443fd7227270f9ef6e51fee1d7f36c3e1cf1
@googlebot
Copy link
Collaborator

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link
Collaborator

We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for all the commit author(s) or Co-authors. If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google.
In order to pass this check, please resolve this problem and then comment @googlebot I fixed it.. If the bot doesn't comment, it means it doesn't think anything has changed.

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no contribution license agreement not-signed and removed cla: yes contribution license agreement signed labels Jun 6, 2020
@jecorona97 jecorona97 force-pushed the jose/add_nonstochastic_inference_mode branch from 52ba950 to a8e62f0 Compare June 6, 2020 23:43
@googlebot
Copy link
Collaborator

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link
Collaborator

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@zhuangh
Copy link
Contributor

zhuangh commented Jun 7, 2020

Hi Jose,

  • Why are there so many commits from the history in this PR?
  • I see you use your personal gmail from backend for recent commits (instead of your previous corp mail) so googlebot asked for the CLA.

- base_quantizer class with is_training attribute and setter method
- function call inside layers to pass training information to quantizers ({qconvolutional, qlayers, qnormalization}.py)
- unit tests for stochastic quantizers inference mode behavior

Modified:
- stochastic_{ternary, binary} now inherit from their non stochastic counterparts to delegate inference mode computaiton
- Order of quantizer definition to perfom inheritance
….Activation does not have it

- set the proper learning_phase in qactivation_test
…ng arguments

- Set proper learning phase inside tests
- Fixed multiple instance of tensorflow conditionals in quantizers.py
- Changed stochastic_ternary test to remove the 0 variance cases
- reimported qtools inside init
@jecorona97 jecorona97 force-pushed the jose/add_nonstochastic_inference_mode branch from f1975c7 to fa86b45 Compare June 8, 2020 00:29
@jecorona97 jecorona97 closed this Jun 8, 2020
@jecorona97 jecorona97 deleted the jose/add_nonstochastic_inference_mode branch June 8, 2020 18:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: no contribution license agreement not-signed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants