Ejemplo n.º 1
0
 def test_with_federated_type(self):
     add = _create_computation_add()
     value = _mock_data_of_type(
         computation_types.at_clients(
             computation_types.SequenceType(np.int32)))
     zero = intrinsics.federated_value(0, placements.CLIENTS)
     result = intrinsics.sequence_reduce(value, zero, add)
     self.assert_value(result, '{int32}@CLIENTS')
Ejemplo n.º 2
0
    def test_with_non_federated_type(self):
        @computations.tf_computation(np.int32, np.int32)
        def add(x, y):
            return x + y

        value = _mock_data_of_type(computation_types.SequenceType(np.int32))
        result = intrinsics.sequence_reduce(value, 0, add)
        self.assert_value(result, 'int32')
Ejemplo n.º 3
0
    def test_with_federated_type(self):
        @computations.tf_computation(np.int32, np.int32)
        def add(x, y):
            return x + y

        value = _mock_data_of_type(
            computation_types.at_clients(
                computation_types.SequenceType(np.int32)))
        zero = intrinsics.federated_value(0, placements.CLIENTS)
        result = intrinsics.sequence_reduce(value, zero, add)
        self.assert_value(result, '{int32}@CLIENTS')
Ejemplo n.º 4
0
 def _train_on_one_client(model, batches):
     return intrinsics.sequence_reduce(batches, model, _train_on_one_batch)
Ejemplo n.º 5
0
 def test_with_non_federated_type(self):
     add = _create_computation_add()
     value = _mock_data_of_type(computation_types.SequenceType(np.int32))
     result = intrinsics.sequence_reduce(value, 0, add)
     self.assert_value(result, 'int32')