tf.keras.ops.binary_crossentropy
    
    
      
    
    
      
      Stay organized with collections
    
    
      
      Save and categorize content based on your preferences.
    
  
  
      
    
  
  
  
  
  
    
  
  
    
    
Computes binary cross-entropy loss between target and output tensor.
tf.keras.ops.binary_crossentropy(
    target, output, from_logits=False
)
The binary cross-entropy loss is commonly used in binary
classification tasks where each input sample belongs to one
of the two classes. It measures the dissimilarity between the
target and output probabilities or logits.
| Args | 
|---|
| target | The target tensor representing the true binary labels.
Its shape should match the shape of the outputtensor. | 
| output | The output tensor representing the predicted probabilities
or logits. Its shape should match the shape of the targettensor. | 
| from_logits | (optional) Whether outputis a tensor of logits or
probabilities.
Set it toTrueifoutputrepresents logits; otherwise,
set it toFalseifoutputrepresents probabilities.
Defaults toFalse. | 
| Returns | 
|---|
| Integer tensor: The computed binary cross-entropy loss between targetandoutput. | 
Example:
target = keras.ops.convert_to_tensor([0, 1, 1, 0])
output = keras.ops.convert_to_tensor([0.1, 0.9, 0.8, 0.2])
binary_crossentropy(target, output)
array([0.10536054 0.10536054 0.22314355 0.22314355],
      shape=(4,), dtype=float32)
  
  
 
  
    
    
      
       
    
    
  
  
  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 2024-06-07 UTC.
  
  
  
    
      [null,null,["Last updated 2024-06-07 UTC."],[],[]]