<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.21.0/tensorflow/python/framework/type_spec.py#L960-L1006) |

Returns a [`tf.TypeSpec`](https://www.tensorflow.org/api_docs/python/tf/TypeSpec) that represents the given `value`.

#### View aliases


**Compat aliases for migration**

See
[Migration guide](https://www.tensorflow.org/guide/migrate) for
more details.

[`tf.compat.v1.type_spec_from_value`](https://www.tensorflow.org/api_docs/python/tf/type_spec_from_value)

<br />

    tf.type_spec_from_value(
        value
    ) -> https://www.tensorflow.org/api_docs/python/tf/TypeSpec

### Used in the notebooks

| Used in the guide |
|---|
| - [Extension types](https://www.tensorflow.org/guide/extension_type) |

<br />

<br />

<br />

| ## Examples ||
|---|---|
| <br /> >>> 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) <br /> ||

<br />

<br />

<br />

<br />

| ## Args ||
|---|---|
| `value` | A value that can be accepted or returned by TensorFlow APIs. Accepted types for `value` include [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor), any value that can be converted to [`tf.Tensor`](https://www.tensorflow.org/api_docs/python/tf/Tensor) using [`tf.convert_to_tensor`](https://www.tensorflow.org/api_docs/python/tf/convert_to_tensor), and any subclass of `CompositeTensor` (such as [`tf.RaggedTensor`](https://www.tensorflow.org/api_docs/python/tf/RaggedTensor)). |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A `TypeSpec` that is compatible with `value`. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If a TypeSpec cannot be built for `value`, because its type is not supported. |

<br />