1

我面临一个有点烦人的问题。tensorflow 联合训练(初始化和下一步)需要很长时间才能开始(我不是在谈论完成时间,只是开始时间需要一段时间)。

我怀疑这是由于使用:1)使用 eager_mode():,或 2)使用改组,如下所示:

with eager_mode():
    def preprocess(new_dataset):
        def map_fn(elem):
            return collections.OrderedDict([('x', tf.reshape(elem['In'], [-1])),('y', tf.reshape(elem['Out'],[1]))])

        DS2= new_dataset.map(map_fn)
        if Use_shuffle:
            return DS2.repeat(SNN_epoch).shuffle(shuffle_buffer).batch(SNN_batch_size)
        else:
            return DS2.repeat(SNN_epoch).batch(SNN_batch_size)
...
...
...

这就是我所做的:

trainer_Itr_Process = tff.learning.build_federated_averaging_process(model_fn_Federated,server_optimizer_fn=(lambda : tf.keras.optimizers.SGD(learning_rate=learn_rate)),client_weight_fn=None)
    FLstate = trainer_Itr_Process.initialize()
    # Track loss of different ...... of federated iteration
    for round_num in range(Fed_iter_min,Fed_iter_max): 
        FLstate, FLoutputs = trainer_Itr_Process.next(FLstate, federated_train_data)
......
......
......

这是我收到的警告:


W0616 11:30:00.217065 139843447875392 deprecation_wrapper.py:118] From /usr/local/lib/python3.6/dist-packages/tensorflow_estimator/python/estimator/api/_v1/estimator/__init__.py:10: The name tf.estimator.inputs is deprecated. Please use tf.compat.v1.estimator.inputs instead.

W0616 11:30:02.400945 139843447875392 deprecation_wrapper.py:118] From /usr/local/lib/python3.6/dist-packages/tensorflow_federated/python/core/impl/tensorflow_serialization.py:296: The name tf.initializers.variables is deprecated. Please use tf.compat.v1.initializers.variables instead.

4

0 回答 0