tf.experimental.numpy.experimental_enable_numpy_behavior
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
      
    
  
  
  
  
  
    
  
  
    
    
Enable NumPy behavior on Tensors.
tf.experimental.numpy.experimental_enable_numpy_behavior(
    prefer_float32=False, dtype_conversion_mode='legacy'
)
Enabling NumPy behavior has three effects:
- It adds to 
tf.Tensor some common NumPy methods such as T,
reshape and ravel. 
- It changes dtype promotion in 
tf.Tensor operators to be
compatible with NumPy. For example,
tf.ones([], tf.int32) + tf.ones([], tf.float32) used to throw a
"dtype incompatible" error, but after this it will return a
float64 tensor (obeying NumPy's promotion rules). 
- It enhances 
tf.Tensor's indexing capability to be on par with
NumPy's. 
Args | 
prefer_float32
 | 
Controls whether dtype inference will use float32 for Python
floats, or float64 (the default and the NumPy-compatible behavior).
 | 
dtype_conversion_mode
 | 
a string that specifies promotion mode. This string
corresponds to a PromoMode Enum and can be 'off', 'legacy', 'safe', or
'all'. 'safe' or 'all' mode enables the auto dtype conversion semantics.
 | 
  
  
 
  
    
    
      
       
    
    
  
  
  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."],[],[]]