tfgnn.EdgeSetSpec
December 14, 2023 ยท View on GitHub
View source
on GitHub
A type spec for tfgnn.EdgeSet.
tfgnn.EdgeSetSpec(
data_spec: DataSpec,
shape: tf.TensorShape,
indices_dtype: tf.dtypes.DType,
row_splits_dtype: tf.dtypes.DType,
metadata: Metadata = None,
check_consistent_indices_dtype: bool = False,
check_consistent_row_splits_dtype: bool = False
)
Methods
experimental_as_proto
experimental_as_proto() -> struct_pb2.TypeSpecProto
Returns a proto representation of the TypeSpec instance.
Do NOT override for custom non-TF types.
experimental_from_proto
@classmethodexperimental_from_proto( proto: struct_pb2.TypeSpecProto ) -> 'TypeSpec'
Returns a TypeSpec instance based on the serialized proto.
Do NOT override for custom non-TF types.
| Args | |
|---|---|
proto
|
Proto generated using 'experimental_as_proto'. |
experimental_type_proto
@classmethodexperimental_type_proto() -> Type[struct_pb2.TypeSpecProto]
Returns the type of proto associated with TypeSpec serialization.
Do NOT override for custom non-TF types.
from_field_specs
@classmethodfrom_field_specs( *, features_spec: Optional[FieldsSpec] = None, sizes_spec: FieldSpec, adjacency_spec: AdjacencySpec ) -> 'EdgeSetSpec'
The counterpart of EdgeSet.from_fields() for values type specs.
from_value
@classmethodfrom_value( value: GraphPieceBase )
Extension Types API: Factory method.
is_compatible_with
is_compatible_with(
spec_or_value
)
Returns true if spec_or_value is compatible with this TypeSpec.
Prefer using "is_subtype_of" and "most_specific_common_supertype" wherever possible.
| Args | |
|---|---|
spec_or_value
|
A TypeSpec or TypeSpec associated value to compare against. |
is_subtype_of
is_subtype_of(
other: trace.TraceType
) -> bool
Returns True if self is a subtype of other.
Implements the tf.types.experimental.func.TraceType interface.
If not overridden by a subclass, the default behavior is to assume the TypeSpec is covariant upon attributes that implement TraceType and invariant upon rest of the attributes as well as the structure and type of the TypeSpec.
| Args | |
|---|---|
other
|
A TraceType object. |
most_specific_common_supertype
most_specific_common_supertype(
others: Sequence[trace.TraceType]
) -> Optional['TypeSpec']
Returns the most specific supertype TypeSpec of self and others.
Implements the tf.types.experimental.func.TraceType interface.
If not overridden by a subclass, the default behavior is to assume the TypeSpec is covariant upon attributes that implement TraceType and invariant upon rest of the attributes as well as the structure and type of the TypeSpec.
| Args | |
|---|---|
others
|
A sequence of TraceTypes. |
most_specific_compatible_type
most_specific_compatible_type(
other: 'TypeSpec'
) -> 'TypeSpec'
Returns the most specific TypeSpec compatible with self and other. (deprecated)
Deprecated: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use most_specific_common_supertype instead.
Deprecated. Please use most_specific_common_supertype instead.
Do not override this function.
| Args | |
|---|---|
other
|
A TypeSpec.
|
| Raises | |
|---|---|
ValueError
|
If there is no TypeSpec that is compatible with both self
and other.
|
relax
relax(
*, num_components: bool = False, num_edges: bool = False
) -> 'EdgeSetSpec'
Allows variable number of edge or/and graph components.
Calling with all default parameters keeps the spec unchanged.
| Args | |
|---|---|
num_components
|
if True, allows variable number of graph components by
setting the outermost sizes dimension to None.
|
num_edges
|
if True, allows variable number of edges by setting the
outermost features dimensions to None.
|
| Returns | |
|---|---|
| Relaxed compatible edge set spec. |
| Raises | |
|---|---|
ValueError
|
if edge set is not scalar (rank > 0). |
with_indices_dtype
with_indices_dtype(
dtype: tf.dtypes.DType
) -> 'GraphPieceSpecBase'
Returns a copy of this piece spec with the given indices dtype.
with_row_splits_dtype
with_row_splits_dtype(
dtype: tf.dtypes.DType
) -> 'GraphPieceSpecBase'
Returns a copy of this piece spec with the given row splits dtype.
with_shape
with_shape(
new_shape: ShapeLike
) -> 'GraphPieceSpecBase'
Enforce the common prefix shape on all the contained features.
__eq__
__eq__(
other
) -> bool
Return self==value.
__getitem__
__getitem__(
feature_name: FieldName
) -> FieldSpec
__ne__
__ne__(
other
) -> bool
Return self!=value.