mirror of
https://github.com/zebrajr/tensorflow.git
synced 2025-12-06 12:20:11 +01:00
Add migration block for tf.compat.v1.placeholder
PiperOrigin-RevId: 381158940 Change-Id: I64aeae4cf3e0a3459c6d284e2a90c04b216b5984
This commit is contained in:
parent
ade35c112e
commit
a3b7535ec5
|
|
@ -3251,10 +3251,6 @@ def placeholder(dtype, shape=None, name=None):
|
|||
print(sess.run(y, feed_dict={x: rand_array})) # Will succeed.
|
||||
```
|
||||
|
||||
@compatibility(eager)
|
||||
Placeholders are not compatible with eager execution.
|
||||
@end_compatibility
|
||||
|
||||
Args:
|
||||
dtype: The type of elements in the tensor to be fed.
|
||||
shape: The shape of the tensor to be fed (optional). If the shape is not
|
||||
|
|
@ -3267,6 +3263,20 @@ def placeholder(dtype, shape=None, name=None):
|
|||
|
||||
Raises:
|
||||
RuntimeError: if eager execution is enabled
|
||||
|
||||
@compatibility(TF2)
|
||||
This API is not compatible with eager execution and `tf.function`. To migrate
|
||||
to TF2, rewrite the code to be compatible with eager execution. Check the
|
||||
[migration
|
||||
guide](https://www.tensorflow.org/guide/migrate#1_replace_v1sessionrun_calls)
|
||||
on replacing `Session.run` calls. In TF2, you can just pass tensors directly
|
||||
into ops and layers. If you want to explicitly set up your inputs, also see
|
||||
[Keras functional API](https://www.tensorflow.org/guide/keras/functional) on
|
||||
how to use `tf.keras.Input` to replace `tf.compat.v1.placeholder`.
|
||||
`tf.function` arguments also do the job of `tf.compat.v1.placeholder`.
|
||||
For more details please read [Better
|
||||
performance with tf.function](https://www.tensorflow.org/guide/function).
|
||||
@end_compatibility
|
||||
"""
|
||||
if context.executing_eagerly():
|
||||
raise RuntimeError("tf.placeholder() is not compatible with "
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user