This API is strongly discouraged for use with eager execution and
tf.function. The primary use of this API is for testing computation wrapped
within a tf.function where the input tensors might not have statically known
fully-defined shapes. The same can be achieved by creating a
concrete function
from the tf.function with a tf.TensorSpec input which has partially
defined shapes. For example, the code
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.compat.v1.placeholder_with_default\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.16.1/tensorflow/python/ops/array_ops.py#L2997-L3046) |\n\nA placeholder op that passes through `input` when its output is not fed. \n\n tf.compat.v1.placeholder_with_default(\n input, shape, name=None\n )\n\n\u003cbr /\u003e\n\nMigrate to TF2\n--------------\n\n\u003cbr /\u003e\n\n| **Caution:** This API was designed for TensorFlow v1. Continue reading for details on how to migrate from this API to a native TensorFlow v2 equivalent. See the [TensorFlow v1 to TensorFlow v2 migration guide](https://www.tensorflow.org/guide/migrate) for instructions on how to migrate the rest of your code.\n\nThis API is strongly discouraged for use with eager execution and\n[`tf.function`](../../../tf/function). The primary use of this API is for testing computation wrapped\nwithin a [`tf.function`](../../../tf/function) where the input tensors might not have statically known\nfully-defined shapes. The same can be achieved by creating a\n[concrete function](https://www.tensorflow.org/guide/function#obtaining_concrete_functions)\nfrom the [`tf.function`](../../../tf/function) with a [`tf.TensorSpec`](../../../tf/TensorSpec) input which has partially\ndefined shapes. For example, the code \n\n @tf.function\n def f():\n x = tf.compat.v1.placeholder_with_default(\n tf.constant([[1., 2., 3.], [4., 5., 6.]]), [None, 3])\n y = tf.constant([[1.],[2.], [3.]])\n z = tf.matmul(x, y)\n assert z.shape[0] == None\n assert z.shape[1] == 1\n\n f()\n\ncan easily be replaced by \n\n @tf.function\n def f(x):\n y = tf.constant([[1.],[2.], [3.]])\n z = tf.matmul(x, y)\n assert z.shape[0] == None\n assert z.shape[1] == 1\n\n g = f.get_concrete_function(tf.TensorSpec([None, 3]))\n\nYou can learn more about [`tf.function`](../../../tf/function) at [Better\nperformance with tf.function](https://www.tensorflow.org/guide/function).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nDescription\n-----------\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------|--------------------------------------------------------------------------------------------------------------|\n| `input` | A `Tensor`. The default value to produce when output is not fed. |\n| `shape` | A [`tf.TensorShape`](../../../tf/TensorShape) or list of `int`s. The (possibly partial) shape of the tensor. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A `Tensor`. Has the same type as `input`. ||\n\n\u003cbr /\u003e"]]