我正在尝试使用联邦代码来构建我自己的联邦学习算法。但我遇到了一个问题。在官方教程中,它定义了模型规范如下:
MODEL_SPEC = collections.OrderedDict(
filter1 = tf.TensorSpec(shape=weights[0].shape, dtype=tf.float32),
bias1 = tf.TensorSpec(shape=weights[1].shape, dtype=tf.float32),
filter2 = tf.TensorSpec(shape=weights[2].shape, dtype=tf.float32),
bias2 = tf.TensorSpec(shape=weights[3].shape, dtype=tf.float32),
weight1 = tf.TensorSpec(shape=weights[4].shape, dtype=tf.float32),
bias3 = tf.TensorSpec(shape=weights[5].shape, dtype=tf.float32)
)
MODEL_TYPE = tff.to_type(MODEL_SPEC)我想知道是否需要将模型作为OrderedDict输入。我可以输入模型作为一个可训练的Keras模型吗?
谢谢!
发布于 2021-04-13 15:39:31
是的,TFF可以使用使用tf.keras.Model (函数或顺序API,而不是使用tff.learning.from_keras_model方法的子类API)定义的模型。
此方法用于文本生成的联合学习和构建您自己的联合学习算法教程。
https://stackoverflow.com/questions/67077765
复制相似问题