tensorflow-federated

TFF loading a pre-trained Keras model

*爱你&永不变心* 提交于 2020-07-09 14:25:10
问题 My goal is to load a base model from a .hdf5 file (it's a Keras model), and continue to train it with federated learning. Here is how I initialize the base model for FL: def model_fn(): model = tf.keras.load_model(path/to/model.hdf5) return tff.learning.from_keras_model(model=model, dummy_batch=db, loss=loss, metrics=metrics) trainer = tff.learning.build_federated_averaging_process(model_fn) state = trainer.initialize() However, it seems like the resulting state.model weights are randomly

Federated learning : convert my own image dataset into tff simulation Clientdata

只愿长相守 提交于 2020-05-26 09:20:16
问题 here is the code of my federated learning test from __future__ import absolute_import, division, print_function import os import collections import warnings from six.moves import range import numpy as np import six import tensorflow as tf import tensorflow_federated as tff from tensorflow.keras.callbacks import EarlyStopping, ReduceLROnPlateau, ModelCheckpoint import PIL #pretrain train_datagen1 = tf.keras.preprocessing.image.ImageDataGenerator(vertical_flip=True) training_set1= train

Implement data generator in federated training

安稳与你 提交于 2020-05-15 04:36:05
问题 (I have posted the question on https://github.com/tensorflow/federated/issues/793 and maybe also here!) I have customized my own data and model to federated interfaces and the training converged. But I am confused about an issue that in an images classification task, the whole dataset is extreme large and it can't be stored in a single federated_train_data nor be imported to memory for one time. So I need to load the dataset from the hard disk in batches to memory real-timely and use Keras

How to plot Histogram summary for delta weight in Federated Tensorflow?

泄露秘密 提交于 2020-04-16 05:44:34
问题 I am analyzing a method that I have implemented in Tensorflow Federated with FedAvg. I need to have a histogram for every clients' delta weights that are communicated to the server. Each client separately called in simulation/federated_avaraging.py , but the thing is I can not call the following API in there. tf.summary.histogram() . any help would be appreciated. 回答1: In TFF, TensorFlow represents "local computation"; so if you need a way to inspect something across clients, you will need to

TFF: Invalid argument: Default MaxPoolingOp only supports NHWC on device type CPU

≯℡__Kan透↙ 提交于 2020-02-16 09:52:55
问题 Here is part of my code TFF for item in data_root.glob("*"): print(item.name) CLASS_NAMES = np.array([item.name for item in data_root.glob('*')]) def get_label(file_path): parts = tf.strings.split(file_path, os.path.sep) return parts[-2] == CLASS_NAMES IMG_WIDTH = 200 IMG_HEIGHT = 200 def decode_img(img): img = tf.io.decode_jpeg(img, channels=3) img = tf.image.convert_image_dtype(img, tf.float32) return tf.image.resize(img, [IMG_HEIGHT, IMG_WIDTH]) def process_path(file_path): label = get

convert my own image dataset into federated data

丶灬走出姿态 提交于 2020-01-25 06:47:25
问题 i'm implementing code with TFF, and I have image dataset of skin cancer. i must convert my dataset into federated data So can anyone help me I use tff.simulation.clientData or tff.simulation.clientData.create_tf_dataset_for_client() or tff.simulation.HDF5ClientData.create_tf_dataset_for_client(client_id) or tf.data.Dataset.from_tensor_slices() 来源: https://stackoverflow.com/questions/59734700/convert-my-own-image-dataset-into-federated-data

tensorflow federated learning checkpoint

允我心安 提交于 2020-01-14 06:36:37
问题 I am studying a federated_learning_for_image_classification.ipynb with tensorflow federated API. In the example, I could check each simulated clients train Accuracy, Loss and Total accuracy, Total loss. But there are no checkpoint files. I want to make each client checkpoint file and total checkpoint files. And then compare the client parameter variables and total parameter variables. Anyone can help me to make checkpoint file in federated_learning_for_image_classification.ipynb example? 回答1:

What is the recommended way to mix TensorFlow and TensorFlow Federated code?

旧城冷巷雨未停 提交于 2019-12-30 11:07:42
问题 TensorFlow (TF) and TensorFlow Federated (TFF) are different layers of functionality that are designed to play well together (as the names implie). Still, they are different things designed to solve different problems. I wonder what is the best way to describe computation in a way that can be used by both vanilla TF and in TFF workloads, as well as the kind of pitfalls that one might want to avoid. 回答1: Great question. Indeed, there are at least 3 ways to approach composition of TensorFlow

how to print local outputs in tensorflow federated?

不打扰是莪最后的温柔 提交于 2019-12-20 05:09:21
问题 I want to print local outputs of clients in the tensorflow federated tutorial https://www.tensorflow.org/federated/tutorials/federated_learning_for_image_classification. What should I do? 回答1: If you only want a list of the values that go into the aggregations (e.g. into tff.federated_mean ), one option would be to add additional outputs to aggregate_mnist_metrics_across_clients() to include metrics computed using tff.federated_collect(). This might look something like: @tff.federated

Operations performed on the communications between the server and clients

社会主义新天地 提交于 2019-12-11 01:05:43
问题 Part of federated learning research is based on operations performed on the communications between the server and clients such as dropping part of the updates (drop some gradients describing a model) exchanged between clients and server or discarding an update from a specific client in a certain communication round. I want to know if such capabilities are supported by Tensorflow-federated (TFF) framework and how they are supported because, from a first look, it seems to me the level of