tf.keras.backend.is_keras_tensor
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
      
    
  
  
  
  
  
    
  
  
    
    
Returns whether x is a Keras tensor.
  View aliases
  
Compat aliases for migration
See
Migration guide for
more details.
`tf.compat.v1.keras.backend.is_keras_tensor`
tf.keras.backend.is_keras_tensor(
    x
)
A "Keras tensor" is a tensor that was returned by a Keras layer,
(Layer class) or by Input.
| Args | 
|---|
| x | A candidate tensor. | 
| Returns | 
|---|
| A boolean: Whether the argument is a Keras tensor. | 
| Raises | 
|---|
| ValueError | In case xis not a symbolic tensor. | 
Examples:
np_var = np.array([1, 2])
# A numpy array is not a symbolic tensor.
tf.keras.backend.is_keras_tensor(np_var)
Traceback (most recent call last):
ValueError: Unexpectedly found an instance of type
`<class 'numpy.ndarray'>`.
Expected a symbolic tensor instance.
keras_var = tf.keras.backend.variable(np_var)
# A variable created with the keras backend is not a Keras tensor.
tf.keras.backend.is_keras_tensor(keras_var)
False
keras_placeholder = tf.keras.backend.placeholder(shape=(2, 4, 5))
# A placeholder is a Keras tensor.
tf.keras.backend.is_keras_tensor(keras_placeholder)
True
keras_input = tf.keras.layers.Input([10])
# An Input is a Keras tensor.
tf.keras.backend.is_keras_tensor(keras_input)
True
keras_layer_output = tf.keras.layers.Dense(10)(keras_input)
# Any Keras layer output is a Keras tensor.
tf.keras.backend.is_keras_tensor(keras_layer_output)
True
  
  
 
  
    
    
      
       
    
    
  
  
  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 2023-10-06 UTC.
  
  
  
    
      [null,null,["Last updated 2023-10-06 UTC."],[],[]]