0

I am currently working on an implementation of an federated learning with the flower library in an embedded system. I am using a tensorflow lite model because of the limited hardware. For my project I need to be able to load model weights from a dictionary directly rather than from a file. but I can not seem to find any advice on how to do that. I know that I can use signatures as shown in this tutorial from tensorflow, but I do not know how to create a signature for loading the weights directly from a dictionary. Therefore I wonder myself if anybody here has any experience in creating a signature for loading model weights into a lite model using a dictionary.

I already tried implementing a signature but I a can not wrap my head around how the input signature should look like regarding the input dictionary. I used the code found in this question, which was sadly never answered.

@tf.function(input_signature=[tf.TensorSpec(shape=[1], dtype=tf.float32)])
    def initialize(self, weights):
        tnames = [weight.name for weight in self.model.weights]
        for i, tensor in enumerate(self.model.weights):
            tensor.assign(weights[tnames[i]])
Niklas
  • 29
  • 1
  • 6

0 Answers0