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

Update layers and losses for mixed precision compatibility. #490

Merged
merged 11 commits into from
Feb 9, 2021

Conversation

willgraf
Copy link
Contributor

@willgraf willgraf commented Feb 6, 2021

What

  • Change references to K.floatx to refer to inputs.dtype or compute_type.
  • Cast y_true to y_pred.dtype to preserve dtype in losses.py.

Why

  • Setting floatx to float16 is not recommended for training, and instead the global precision policy should be changed to mixed_float16. However, the Location and Normalization layers were set to output K.floatx() which conflicts with the global precision policy. Instead, setting the dtype to the internal compute_type or inputs.dtype preserves the mixed dtype policy.
  • Fixes Enable training/inference with half-precision (float16) #112

@willgraf willgraf changed the title Update Location and Normalize layers for mixed precision compatibility Update layers and losses for mixed precision compatibility. Feb 8, 2021
@willgraf willgraf merged commit e68bc7c into master Feb 9, 2021
@willgraf willgraf deleted the mixed-precision branch February 9, 2021 16:01
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

Successfully merging this pull request may close these issues.

Enable training/inference with half-precision (float16)
1 participant