NPUBroadcastGlobalVariablesCallback Constructor
Description
Broadcasts variables in Keras scenarios to ensure that the initial values of variables on each device are the same in distributed scenarios.
Prototype
def __init__(self, root_rank)
Options
Option |
Input/Output |
Description |
|---|---|---|
root_rank |
Input |
Identifies the device whose variables are to be broadcast to other devices. |
Returns
None
Example
Before porting
1 2 3 4 5 6 | callbacks = [hvd.callbacks.BroadcastGlobalVariablesCallback(0)] import numpy as np data = np.random.random((1000, 100)) lables = np random.randint(2, size=(1000,1)) model.fit(data, lables, epochs=10, batch_size=32, callbacks=callbacks) |
After porting
1 2 3 4 5 6 7 | from npu_bridge.npu_init import * callbacks = [NPUBroadcastGlobalVariablesCallback(0)] import numpy as np data = np.random.random((1000, 100)) lables = np random.randint(2, size=(1000,1)) model.fit(data, lables, epochs=10, batch_size=32, callbacks=callbacks) |
Parent topic: npu_bridge.estimator.npu.npu_callbacks