TFF : Modify the process that includes an initialization and iterated computation

Viewed 70

what can I write in this code :

def initialize_fn():
  ...

1 Answers

The state object returned by iterative_process.initialize() is typically a Python container (tuple, collections.OrderedDict, etc) that contains numpy arrays. To see this, try print(state) after initialize.

Perhaps simply replacing the values with the those loaded from an external file after initialze() and before loop over next():


def load_my_weights(filename):
  # read from external file, create numpy arrays

iterative_process = IterativeProcess(initialize_fn, next_fn)
state = iterative_process.initialize()
state['model'] = load_my_weights(filename)  # assumes 'model' is a key in state.
for round in range(num_rounds):
  state = iterative_process.next(state)
Related