Giter Site home page Giter Site logo

federated-learning-with-tensorflow's Introduction

Federated Learning in TensorFlow [Video]

This is the code repository for Federated Learning in TensorFlow [Video], published by Packt. It contains all the supporting project files necessary to work through the video course from start to finish.

About the Video Course

Federated learning is revolutionizing how machine learning models are trained. TensorFlow Federated is the first production-level federated learning platform that makes it easy to build mobile device learning-based applications. In this course, you’ll learn the basics of building Federated Learning models that can be gradually improved by decentralized data that comes from a variety of mobile devices while not violating the privacy of end users.

You’ll start by exploring the nature of problems that TensorFlow Federated helps to solve and you’ll install the necessary software. After that, we’ll jump straight into improving an image classification model using a bunch of samples of decentralized data from specially prepared MNIST dataset. Then you’ll start working with text and apply Federated Learning to text generation using a pre-trained model on Charles Dickens' texts. Next, you’ll handle a text classification problem with TensorFlow Federated where you’ll use a movie reviews dataset.

By the end of this course, you’ll have the practical skills to prepare both datasets and models for Federated Learning as well as the ability to train and evaluate your own models in TensorFlow Federated.

What You Will Learn

  • Quickly install all the necessary tools to practice Federated Learning on your own machine
  • Apply Federated Learning on a variety of common Deep Learning problems
  • Gradually improve your pre-trained models using decentralized data
  • Discover what to look for when applying the TensorFlow Federated framework in your own projects
  • Train and evaluate your own models in a Federated Learning fashion

Instructions and Navigation

Assumed Knowledge

To fully benefit from the coverage included in this course, you will need:

  • Python 3 working knowledge

  • Some Keras/Tensorflow experience

  • Ability to run a simple Python script in command line (Terminal)

Technical Requirements

This course has the following software requirements:

  • Python 3

  • Keras

  • TensorFlowlow

This course has the following software requirements:

  • OS: macOS High Sierra

  • Processor: 1.3 GHz Intel Core i5

  • Memory: 4 GB

  • Storage: 121 GB

Related Products

federated-learning-with-tensorflow's People

Contributors

packt-itservice avatar siddheshkavle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

federated-learning-with-tensorflow's Issues

iterative_process = tff.learning.build_federated_averaging_process(model_fn)

Why this function call is giving error

TypeError Traceback (most recent call last)
in
1 # Initialize training
----> 2 iterative_process = tff.learning.build_federated_averaging_process(model_fn)
3 state = iterative_process.initialize()

~/anaconda3/envs/text_pred/lib/python3.6/site-packages/tensorflow_federated/python/learning/federated_averaging.py in build_federated_averaging_process(model_fn, server_optimizer_fn, client_weight_fn, stateful_delta_aggregate_fn, stateful_model_broadcast_fn)
162 return optimizer_utils.build_model_delta_optimizer_process(
163 model_fn, client_fed_avg, server_optimizer_fn,
--> 164 stateful_delta_aggregate_fn, stateful_model_broadcast_fn)

~/anaconda3/envs/text_pred/lib/python3.6/site-packages/tensorflow_federated/python/learning/framework/optimizer_utils.py in build_model_delta_optimizer_process(model_fn, model_to_client_delta_fn, server_optimizer_fn, stateful_delta_aggregate_fn, stateful_model_broadcast_fn)
359 server_state_type = tf_init_fn.type_signature.result
360
--> 361 @tff.tf_computation(tf_dataset_type, server_state_type.model)
362 def tf_client_delta(tf_dataset, initial_model_weights):
363 """Performs client local model optimization.

~/anaconda3/envs/text_pred/lib/python3.6/site-packages/tensorflow_federated/python/core/impl/computation_wrapper.py in (fn)
413 args = (args,)
414 arg_type = computation_types.to_type(args[0])
--> 415 return lambda fn: _wrap(fn, arg_type, self._wrapper_fn)

~/anaconda3/envs/text_pred/lib/python3.6/site-packages/tensorflow_federated/python/core/impl/computation_wrapper.py in _wrap(fn, parameter_type, wrapper_fn)
101
102 # Either we have a concrete parameter type, or this is no-arg function.
--> 103 concrete_fn = wrapper_fn(fn, parameter_type, unpack=None)
104 py_typecheck.check_type(concrete_fn, function_utils.ConcreteFunction,
105 'value returned by the wrapper')

~/anaconda3/envs/text_pred/lib/python3.6/site-packages/tensorflow_federated/python/core/impl/computation_wrapper_instances.py in _tf_wrapper_fn(failed resolving arguments)
42 ctx_stack = context_stack_impl.context_stack
43 comp_pb, extra_type_spec = tensorflow_serialization.serialize_py_fn_as_tf_computation(
---> 44 target_fn, parameter_type, ctx_stack)
45 return computation_impl.ComputationImpl(comp_pb, ctx_stack, extra_type_spec)
46

~/anaconda3/envs/text_pred/lib/python3.6/site-packages/tensorflow_federated/python/core/impl/tensorflow_serialization.py in serialize_py_fn_as_tf_computation(target, parameter_type, context_stack)
266 context = tf_computation_context.TensorFlowComputationContext(graph)
267 with context_stack.install(context):
--> 268 result = target(*args)
269
270 # TODO(b/122081673): This needs to change for TF 2.0. We may also

~/anaconda3/envs/text_pred/lib/python3.6/site-packages/tensorflow_federated/python/core/impl/utils/function_utils.py in (arg)
582 except NameError:
583 raise AssertionError('Args to be bound must be in scope.')
--> 584 return lambda arg: _unpack_and_call(fn, arg_types, kwarg_types, arg)
585 else:
586 # An interceptor function that verifies the actual parameter before it

~/anaconda3/envs/text_pred/lib/python3.6/site-packages/tensorflow_federated/python/core/impl/utils/function_utils.py in _unpack_and_call(fn, arg_types, kwarg_types, arg)
553 for idx, expected_type in enumerate(arg_types):
554 element_value = arg[idx]
--> 555 actual_type = type_utils.infer_type(element_value)
556 if not type_utils.is_assignable_from(expected_type, actual_type):
557 raise TypeError(

~/anaconda3/envs/text_pred/lib/python3.6/site-packages/tensorflow_federated/python/core/impl/type_utils.py in infer_type(arg)
63 return computation_types.SequenceType(
64 tf_dtypes_and_shapes_to_type(
---> 65 tf.compat.v1.data.get_output_types(arg),
66 tf.compat.v1.data.get_output_shapes(arg)))
67 elif isinstance(arg, anonymous_tuple.AnonymousTuple):

~/anaconda3/envs/text_pred/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py in get_legacy_output_types(dataset_or_iterator)
2037 of an element of this dataset.
2038 """
-> 2039 return get_structure(dataset_or_iterator)._to_legacy_output_types() # pylint: disable=protected-access
2040
2041

~/anaconda3/envs/text_pred/lib/python3.6/site-packages/tensorflow/python/data/ops/dataset_ops.py in get_structure(dataset_or_iterator)
2001 pass
2002 raise TypeError("dataset_or_iterator must be a Dataset or Iterator object, "
-> 2003 "but got %s." % type(dataset_or_iterator))
2004
2005

TypeError: dataset_or_iterator must be a Dataset or Iterator object, but got <class 'tensorflow.python.data.ops.dataset_ops._VariantDataset'>.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.