无法使用 TFF 的 build_federated_averaging_process()。遵循 TFF 联合文档中的教程。
这是我的模型代码:
X_train = <valuex>
Y_train = <valuey>
def model_fn():
model = tf.keras.models.Sequential([
tf.keras.layers.Conv1D(32,dtype="float64",kernel_size=3,padding='same',activation=tf.nn.relu,input_shape=(X_train.shape[1], X_train.shape[2])),
tf.keras.layers.MaxPooling1D(pool_size=3),
tf.keras.layers.Conv1D(64,kernel_size=3,padding='same',activation=tf.nn.relu),
tf.keras.layers.MaxPooling1D(pool_size=3),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(128,activation=tf.nn.relu),
tf.keras.layers.Dropout(0.45),
tf.keras.layers.Dense(1, activation=tf.nn.sigmoid)
])
model.compile(
loss=tf.keras.losses.SparseCategoricalCrossentropy(),
optimizer=tf.keras.optimizers.SGD(learning_rate=0.05),
metrics=[tf.keras.metrics.Accuracy()])
model.summary()
return tff.learning.from_compiled_keras_model(model, sample_batch)
iterative_process = tff.learning.build_federated_averaging_process(model_fn())
我得到错误:
TypeError: 期望一个可调用的,发现不可调用的 tensorflow_federated.python.learning.model_utils.EnhancedTrainableModel。