tff.framework.Lambda
Stay organized with collections
Save and categorize content based on your preferences.
A representation of a lambda expression in TFF's internal language.
Inherits From: ComputationBuildingBlock
, TypedObject
tff.framework.Lambda(
parameter_name: Optional[str],
parameter_type: Optional[object],
result: tff.framework.ComputationBuildingBlock
)
A lambda expression consists of a string formal parameter name, and a result
expression that can contain references by name to that formal parameter. A
concise notation for lambdas is (foo -> bar)
, where foo
is the name of
the formal parameter, and bar
is the result expression.
Args |
parameter_name
|
The (string) name of the parameter accepted by the lambda.
This name can be used by Reference() instances in the body of the lambda
to refer to the parameter. Note that an empty parameter name shall be
treated as equivalent to no parameter.
|
parameter_type
|
The type of the parameter, an instance of types.Type or
something convertible to it by types.to_type().
|
result
|
The resulting value produced by the expression that forms the body
of the lambda. Must be an instance of ComputationBuildingBlock.
|
Raises |
TypeError
|
if the arguments are of the wrong types.
|
Attributes |
parameter_name
|
|
parameter_type
|
|
proto
|
Returns a serialized form of this object as a pb.Computation instance.
|
result
|
|
type_signature
|
Returns the TFF type of this object (an instance of tff.Type ).
|
Methods
children
View source
children() -> Iterator[tff.framework.ComputationBuildingBlock
]
Returns an iterator yielding immediate child building blocks.
compact_representation
View source
compact_representation()
Returns the compact string representation of this building block.
View source
formatted_representation()
Returns the formatted string representation of this building block.
from_proto
View source
@classmethod
from_proto(
computation_proto: pb.Computation
) -> 'Lambda'
Returns an instance of a derived class based on 'computation_proto'.
Args |
computation_proto
|
An instance of pb.Computation.
|
Returns |
An instance of a class that implements 'ComputationBuildingBlock' and
that contains the deserialized logic from in 'computation_proto'.
|
Raises |
NotImplementedError
|
if computation_proto contains a kind of computation
for which deserialization has not been implemented yet.
|
ValueError
|
if deserialization failed due to the argument being invalid.
|
structural_representation
View source
structural_representation()
Returns the structural string representation of this building block.
__eq__
View source
__eq__(
other: object
) -> bool
Return self==value.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-20 UTC.
[null,null,["Last updated 2024-09-20 UTC."],[],[],null,["# tff.framework.Lambda\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |\n\nA representation of a lambda expression in TFF's internal language.\n\nInherits From: [`ComputationBuildingBlock`](../../tff/framework/ComputationBuildingBlock), [`TypedObject`](../../tff/TypedObject) \n\n tff.framework.Lambda(\n parameter_name: Optional[str],\n parameter_type: Optional[object],\n result: ../../tff/framework/ComputationBuildingBlock\n )\n\nA lambda expression consists of a string formal parameter name, and a result\nexpression that can contain references by name to that formal parameter. A\nconcise notation for lambdas is `(foo -\u003e bar)`, where `foo` is the name of\nthe formal parameter, and `bar` is the result expression.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `parameter_name` | The (string) name of the parameter accepted by the lambda. This name can be used by Reference() instances in the body of the lambda to refer to the parameter. Note that an empty parameter name shall be treated as equivalent to no parameter. |\n| `parameter_type` | The type of the parameter, an instance of types.Type or something convertible to it by types.to_type(). |\n| `result` | The resulting value produced by the expression that forms the body of the lambda. Must be an instance of ComputationBuildingBlock. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|-------------|------------------------------------------|\n| `TypeError` | if the arguments are of the wrong types. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|------------------|------------------------------------------------------------------------------------------|\n| `parameter_name` | \u003cbr /\u003e \u003cbr /\u003e |\n| `parameter_type` | \u003cbr /\u003e \u003cbr /\u003e |\n| `proto` | Returns a serialized form of this object as a pb.Computation instance. |\n| `result` | \u003cbr /\u003e \u003cbr /\u003e |\n| `type_signature` | Returns the TFF type of this object (an instance of [`tff.Type`](../../tff/types/Type)). |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `children`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n children() -\u003e Iterator[../../tff/framework/ComputationBuildingBlock]\n\nReturns an iterator yielding immediate child building blocks.\n\n### `compact_representation`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n compact_representation()\n\nReturns the compact string representation of this building block.\n\n### `formatted_representation`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n formatted_representation()\n\nReturns the formatted string representation of this building block.\n\n### `from_proto`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n @classmethod\n from_proto(\n computation_proto: pb.Computation\n ) -\u003e 'Lambda'\n\nReturns an instance of a derived class based on 'computation_proto'.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------------------|--------------------------------|\n| `computation_proto` | An instance of pb.Computation. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| An instance of a class that implements 'ComputationBuildingBlock' and that contains the deserialized logic from in 'computation_proto'. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|-----------------------|-------------------------------------------------------------------------------------------------------------|\n| `NotImplementedError` | if computation_proto contains a kind of computation for which deserialization has not been implemented yet. |\n| `ValueError` | if deserialization failed due to the argument being invalid. |\n\n\u003cbr /\u003e\n\n### `structural_representation`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n structural_representation()\n\nReturns the structural string representation of this building block.\n\n### `__eq__`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n __eq__(\n other: object\n ) -\u003e bool\n\nReturn self==value."]]