Created by: kuke
Simple Usage:
- Cast specific inputs to float16 (Q: Should we do it automatically?)
imgs = fluid.layers.cast(images, "float16")
- Decorate optimizer and minimize scaled loss
optimizer = fluid.optimizer.Adam(learning_rate=0.001)
mp_optimizer = fluid.contrib.mixed_precision.decorate(
optimizer=optimizer, init_loss_scaling=8.0)
scaled_loss, _, _ = mp_optimizer.minimize(avg_cost)
See test_image_classification_fp16.py for details.