tf.type_spec_from_value
Stay organized with collections
Save and categorize content based on your preferences.
Returns a tf.TypeSpec
that represents the given value
.
tf.type_spec_from_value(
value
) -> tf.TypeSpec
Used in the notebooks
Examples |
>>> tf.type_spec_from_value(tf.constant([1, 2, 3]))
TensorSpec(shape=(3,), dtype=tf.int32, name=None)
>>> tf.type_spec_from_value(np.array([4.0, 5.0], np.float64))
TensorSpec(shape=(2,), dtype=tf.float64, name=None)
>>> tf.type_spec_from_value(tf.ragged.constant([[1, 2], [3, 4, 5]]))
RaggedTensorSpec(TensorShape([2, None]), tf.int32, 1, tf.int64)
example_input = tf.ragged.constant([[1, 2], [3]])
@tf.function(input_signature=[tf.type_spec_from_value(example_input)])
def f(x):
return tf.reduce_sum(x, axis=1)
|
Returns |
A TypeSpec that is compatible with value .
|
Raises |
TypeError
|
If a TypeSpec cannot be built for value , because its type
is not supported.
|
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. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-04-26 UTC."],[],[]]