|  View source on GitHub | 
A placeholder op that passes through input when its output is not fed.
tf.compat.v1.placeholder_with_default(
    input, shape, name=None
)
Migrate to TF2
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
@tf.functiondef f():x = tf.compat.v1.placeholder_with_default(tf.constant([[1., 2., 3.], [4., 5., 6.]]), [None, 3])y = tf.constant([[1.],[2.], [3.]])z = tf.matmul(x, y)assert z.shape[0] == Noneassert z.shape[1] == 1
f()can easily be replaced by
@tf.functiondef f(x):y = tf.constant([[1.],[2.], [3.]])z = tf.matmul(x, y)assert z.shape[0] == Noneassert z.shape[1] == 1
g = f.get_concrete_function(tf.TensorSpec([None, 3]))You can learn more about tf.function at Better
performance with tf.function.
Description
| Args | |
|---|---|
| input | A Tensor. The default value to produce when output is not fed. | 
| shape | A tf.TensorShapeor list ofints. The (possibly partial) shape of
the tensor. | 
| name | A name for the operation (optional). | 
| Returns | |
|---|---|
| A Tensor. Has the same type asinput. |