The ticket Is

  

      github.com/tensorflow/tensorflow
  

  
    
  
	  
  

  
    
      Dtype error when using Mixed Precision and building EfficientNetB0 Model 48
    

    
      
        opened 
        
          
        
        May 26, 2021
      
      


      
        
          
          gauravreddy08
        
      
    

    
        TF 2.5
        comp:keras
        type:bug
    
  


  
    **System information**
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04…): MacOS
- TensorFlow installed from (source or binary): Colab
- TensorFlow version (use command below): 2.5.0
- Python version: python 3.7
- GPU model and memory: Tesla T4

**Error**
`TypeError: Input 'y' of 'Sub' Op has type float16 that does not match type float32 of argument 'x'`

**Current behaviour**

While using Mixed Precision and building a Keras Functional API model (EfficientNet B0), it shows the below error

<img width="935" alt="image" src="https://user-images.githubusercontent.com/57211163/119546314-6669c180-bdb1-11eb-918f-3cb13d225759.png">
<img width="1248" alt="image" src="https://user-images.githubusercontent.com/57211163/119546338-6c5fa280-bdb1-11eb-844d-91175160e6e5.png">

**Describe the expected behaviour**
The Global Policy I set in the previous cell was `mixed_float16`. The problem works fine when running on `tensorflow 2.4.1` so the bug is with `tensorflow 2.5.0`


You can reproduce the same error using the below notebook :
https://colab.research.google.com/drive/1TfNZSIJ_I7IZI35RsGFnTdj-6beMHV2_?usp=sharing