WARNING:tensorflow
The warning is just telling you something used during the import is deprecated. Can be safely ignored Hi **@mominurr** ,

Could you please try again? I tried with TF2.15 and I cannot reproduce the error. Please check the [gist](https://colab.research.google.com/gist/Venkat6871/4c04c8ff77c5772c556693cefa913f48/62415_2-15-v.ipynb) here. 

Thank you! @mominurr This error is only showing to using older version just update the tensorflow to latest and this will be resolved. This issue will be resolved 

![image](https://github.com/tensorflow/tensorflow/assets/67970591/57385de8-ae15-4647-ad06-88d440d646db)
 I'm getting the same warning with tensorflow 2.15.0. Was installed with _pip install tensorflow==2.15.*_

```
WARNING:tensorflow:From [c:\Users\xxxxx\miniconda3\envs\xxxxx\lib\site-packages\keras\src\losses.py:2976](file:///C:/Users/xxxxx/miniconda3/envs/xxxxx/lib/site-packages/keras/src/losses.py:2976): The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.
```

The warning is being generated from keras.losses.py, Line 2976:

```
LABEL_DTYPES_FOR_LOSSES = {
    tf.compat.v1.losses.sparse_softmax_cross_entropy: "int32",
    sparse_categorical_crossentropy: "int32",
}
```

(so this warning doesn't make any sense because the code uses `tf.compat.v1.losses.sparse_softmax_cross_entropy`) This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. > ### Issue type
> Others
> 
> ### Have you reproduced the bug with TensorFlow Nightly?
> Yes
> 
> ### Source
> source
> 
> ### TensorFlow version
> 2.15.0
> 
> ### Custom code
> Yes
> 
> ### OS platform and distribution
> windows
> 
> ### Mobile device
> _No response_
> 
> ### Python version
> 3.10.10
> 
> ### Bazel version
> _No response_
> 
> ### GCC/compiler version
> _No response_
> 
> ### CUDA/cuDNN version
> _No response_
> 
> ### GPU model and memory
> _No response_
> 
> ### Current behavior?
> import os os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' import tensorflow as tf
> 
> node1 = tf.constant(3, dtype=tf.int64) node2 = tf.constant(4, dtype=tf.int64) node3= tf.add(node1, node2)
> 
> # Directly print the result
> print("sum of node1 and node2 is:", node3.numpy())
> 
> ### Standalone code to reproduce the issue
> ```shell
> for this code give me this warning. How I can fixed it.
> 
> WARNING:tensorflow:From D:\Learning-Module\Data science practise\deap-learning-with-tenserflow\env\lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.
> 
> 2023-11-17 18:31:23.771915: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
> To enable the following instructions: SSE SSE2 SSE3 SSE4.1 SSE4.2 AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
> ```
> 
> ### Relevant log output
> you can go to **\lib\site-packages\keras\src\losses.py  file and write 

 **import tensorflow.python as tf**  

and the last of file you can modify like this: 

 **LABEL_DTYPES_FOR_LOSSES = {
    tf.losses.sparse_softmax_cross_entropy: "int32",
    tf.keras.losses.sparse_categorical_crossentropy: "int32",
}**  

![for_losses](https://github.com/tensorflow/tensorflow/assets/58201720/aa9cda95-51e8-48c4-a998-c53671af726d)
![tf python](https://github.com/tensorflow/tensorflow/assets/58201720/105195fd-546e-4eb2-9969-e2db3346a4a6)

 @MaoMakara This solution does remove the console warning! Thank you. @MaoMakara thanks for suggesting a temporary solution for local/personal projects. Still looking for an official fix from the Tensorflow/Keras team > > ### Issue type
> > Others
> > ### Have you reproduced the bug with TensorFlow Nightly?
> > Yes
> > ### Source
> > source
> > ### TensorFlow version
> > 2.15.0
> > ### Custom code
> > Yes
> > ### OS platform and distribution
> > windows
> > ### Mobile device
> > _No response_
> > ### Python version
> > 3.10.10
> > ### Bazel version
> > _No response_
> > ### GCC/compiler version
> > _No response_
> > ### CUDA/cuDNN version
> > _No response_
> > ### GPU model and memory
> > _No response_
> > ### Current behavior?
> > import os os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' import tensorflow as tf
> > node1 = tf.constant(3, dtype=tf.int64) node2 = tf.constant(4, dtype=tf.int64) node3= tf.add(node1, node2)
> > # Directly print the result
> > print("sum of node1 and node2 is:", node3.numpy())
> > ### Standalone code to reproduce the issue
> > ```shell
> > for this code give me this warning. How I can fixed it.
> > 
> > WARNING:tensorflow:From D:\Learning-Module\Data science practise\deap-learning-with-tenserflow\env\lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.
> > 
> > 2023-11-17 18:31:23.771915: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
> > To enable the following instructions: SSE SSE2 SSE3 SSE4.1 SSE4.2 AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
> > ```
> > 
> > 
> >     
> >       
> >     
> > 
> >       
> >     
> > 
> >     
> >   
> > ### Relevant log output
> > you can go to **\lib\site-packages\keras\src\losses.py  file and write
> 
> **import tensorflow.python as tf**
> 
> and the last of file you can modify like this:
> 
> **LABEL_DTYPES_FOR_LOSSES = { tf.losses.sparse_softmax_cross_entropy: "int32", tf.keras.losses.sparse_categorical_crossentropy: "int32", }**
> 
> ![for_losses](https://private-user-images.githubusercontent.com/58201720/289242627-aa9cda95-51e8-48c4-a998-c53671af726d.PNG?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDI0NTQwMDUsIm5iZiI6MTcwMjQ1MzcwNSwicGF0aCI6Ii81ODIwMTcyMC8yODkyNDI2MjctYWE5Y2RhOTUtNTFlOC00OGM0LWE5OTgtYzUzNjcxYWY3MjZkLlBORz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzEyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMjEzVDA3NDgyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQyNjg1Mjc2N2M5NTNhZTg5YmM5YWJhZTBjNjc5OGUzODc1Yjk4MTg4NDdjMmQxNzQ0Mjk4MThiY2Y3ZTQwNGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.IZ2j_na8iiS02451UsKkM240Y5Extjg91HKARIdnMWA) ![tf python](https://private-user-images.githubusercontent.com/58201720/289242638-105195fd-546e-4eb2-9969-e2db3346a4a6.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDI0NTQwMDUsIm5iZiI6MTcwMjQ1MzcwNSwicGF0aCI6Ii81ODIwMTcyMC8yODkyNDI2MzgtMTA1MTk1ZmQtNTQ2ZS00ZWIyLTk5NjktZTJkYjMzNDZhNGE2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzEyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMjEzVDA3NDgyNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTBmOWFmYTFlY2I0MWMyZTU1YTA2ZDkxNTY0MjJmMzY4YTI2MzE4ZDJiNzJmOGFkOTEyZWRmMzU0NjNlOGJhODUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.HF9t5slKZ33u_DcNG02SeaqUn4PaslyJtF0r3y2wc3M)

Thanks. the changes directly to the code works. I am "not" annoyed now by tensorflow,even though i am not using the library, it fills my terminal with this warnings.  This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. @MaoMakara i got this error when do ur change to my code, AttributeError: module 'tensorflow.python' has no attribute '__internal__' This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62415">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/62415">No</a>
 Hi **@mominurr** ,

The warning is just telling users something about the deprecated during the import. Tensorflow will provide such warnings/info logs to the users for their understanding.
If users use that deprecated apis then also it will raise the warnings.

Thank you! The warnings as per are not the issue. We appreciate them. 

The issue is they filling the terminal up, and we are not able to suppress them somehow after recognising them. 

> Hi **@mominurr** ,
> 
> The warning is just telling users something about the deprecated during the import. Tensorflow will provide such warnings/info logs to the users for their understanding. If users use that deprecated apis then also it will raise the warnings.
> 
> Thank you!

 > ### Issue type
> Others
> 
> ### Have you reproduced the bug with TensorFlow Nightly?
> Yes
> 
> ### Source
> source
> 
> ### TensorFlow version
> 2.15.0
> 
> ### Custom code
> Yes
> 
> ### OS platform and distribution
> windows
> 
> ### Mobile device
> _No response_
> 
> ### Python version
> 3.10.10
> 
> ### Bazel version
> _No response_
> 
> ### GCC/compiler version
> _No response_
> 
> ### CUDA/cuDNN version
> _No response_
> 
> ### GPU model and memory
> _No response_
> 
> ### Current behavior?
> import os os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0' import tensorflow as tf
> 
> node1 = tf.constant(3, dtype=tf.int64) node2 = tf.constant(4, dtype=tf.int64) node3= tf.add(node1, node2)
> 
> # Directly print the result
> print("sum of node1 and node2 is:", node3.numpy())
> 
> ### Standalone code to reproduce the issue
> ```shell
> for this code give me this warning. How I can fixed it.
> 
> WARNING:tensorflow:From D:\Learning-Module\Data science practise\deap-learning-with-tenserflow\env\lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.
> 
> 2023-11-17 18:31:23.771915: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
> To enable the following instructions: SSE SSE2 SSE3 SSE4.1 SSE4.2 AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
> ```
> 
> ### Relevant log output
> _No response_

hi, were you able to fix the "The name tf.losses.sparse_softmax_cross_entropy is deprecated" ERROR? Hi @sujirou I am also getting the same error and the previously mentioned solution does not work since I get the error:
```AttributeError: module 'tensorflow.python' has no attribute '__internal__'```

I have expanded on my issue here: https://stackoverflow.com/questions/77936905/tensorflow-core-util-port-cc113-onednn-custom-operations-are-on-the-name-tf-l Hi all.
@Venkat6871 and @mihaimaruseac , yes, it's just a warning, but still annoying. It's not rooted in the user's code, and therefore, in addition to being annoying, it might be misleading and result in a waste of time. It needs to be fixed!
I'm getting this warning by just simply importing tensorflow and nothing else!

@MaoMakara Thanks for the quick fix. It worked at first, but as I developed my project, at some point, somehow, it resulted in an error in my code. Changing it back solved the problem, so be aware that the change you are suggesting might raise an error.
A safer solution looks like this:

# Quick fix
The warning is printed by [tensorflow/python/util/module_wrapper.py, Line 149-151](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/util/module_wrapper.py#L149-L151). Simply comment these lines and you are free of its warning's pain. If it results from simply importing TF, the good fix is to identify the code that causes the warning to occur and fix that. The code in `module_wrapper.py` is there to prevent such cases, supposedly. > # Quick fix
> The warning is printed by [tensorflow/python/util/module_wrapper.py, Line 149-151](https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/util/module_wrapper.py#L149-L151). Simply comment these lines and you are free of its warning's pain.

* yep. this works fine for me. thank you very much!

* previously i changed the code in `...\lib\site-packages\keras\src\losses.py`, the warning was gone, however, it then caused another error `AttributeError: module 'tensorflow.python' has no attribute '__internal__'` when i ran OpenAI `baselines`. for some reason i had to used older `tensorflow` version, so suppressing the warning function works the best for me.   

* in file `D:\Users\*\miniconda3\envs\drlnd_py311\Lib\site-packages\tensorflow\python\util\module_wrapper.py`:
```
  def _tfmw_add_deprecation_warning(self, name, attr):
    return False  ## ---------------------------------- 👈✅ i added this line to bypass the whole function.
    """Print deprecation warning for attr with given name if necessary."""
    if (self._tfmw_warning_count < _PER_MODULE_WARNING_LIMIT and
        name not in self._tfmw_deprecated_checked):

      self._tfmw_deprecated_checked.add(name)

      if self._tfmw_module_name:
        full_name = 'tf.%s.%s' % (self._tfmw_module_name, name)
      else:
        full_name = 'tf.%s' % name
      rename = get_rename_v2(full_name)
      if rename and not has_deprecation_decorator(attr):
        call_location = _call_location()
        # skip locations in Python source
        if not call_location.startswith('<'):
          logging.warning(
              'From %s: The name %s is deprecated. Please use %s instead.\n',
              _call_location(), full_name, rename)
          self._tfmw_warning_count += 1
          return True
    return False
```

 > The warning is just telling you something used during the import is deprecated. Can be safely ignored

I disagree with this statement.

If it is telling me that it is deprecated that means I should change it because at some point in the future deprecated name will be removed and my code will stop working. At least that's how developers use deprecation warnings in other languages.

Also, the warning doesn't make sense.
```
WARNING:
tensorflow:
From d:\AI\AUTOMATIC1111\venv\Lib\site-packages\keras\src\losses.py:2976:
The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.
```
How I read it, it is telling us to not use `tf.losses.sparse_softmax_cross_entropy` but `tf.compat.v1.losses.sparse_softmax_cross_entropy` instead.

However, from `d:\AI\AUTOMATIC1111\venv\Lib\site-packages\keras\src\losses.py:2976`
```
LABEL_DTYPES_FOR_LOSSES = {
    tf.compat.v1.losses.sparse_softmax_cross_entropy: "int32",
    sparse_categorical_crossentropy: "int32",
}
```
We can see that the correct name is already used. So why the warning then? Please clarify? Unsure (cannot check now) but is it possible that `tf.compat.v1.losses.sparse_softmax_cross_entropy` just calls the old `tf.losses.sparse_softmax_cross_entropy` and this causes the deprecation warning to trigger?

The deprecations are added as decorators, so they trigger at import time when the module is parsed. Maybe that's too eager.
### Issue type

Others

### Have you reproduced the bug with TensorFlow Nightly?

Yes

### Source

source

### TensorFlow version

2.15.0

### Custom code

Yes

### OS platform and distribution

windows

### Mobile device

_No response_

### Python version

3.10.10

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

import os
os.environ['TF_ENABLE_ONEDNN_OPTS'] = '0'
import tensorflow as tf

node1 = tf.constant(3, dtype=tf.int64)
node2 = tf.constant(4, dtype=tf.int64)
node3= tf.add(node1, node2)

# Directly print the result
print("sum of node1 and node2 is:", node3.numpy())



### Standalone code to reproduce the issue

```shell
for this code give me this warning. How I can fixed it.

WARNING:tensorflow:From D:\Learning-Module\Data science practise\deap-learning-with-tenserflow\env\lib\site-packages\keras\src\losses.py:2976: The name tf.losses.sparse_softmax_cross_entropy is deprecated. Please use tf.compat.v1.losses.sparse_softmax_cross_entropy instead.

2023-11-17 18:31:23.771915: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE SSE2 SSE3 SSE4.1 SSE4.2 AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
```


### Relevant log output

_No response_