python3.8 安装tensorflow2.6问题

import tensorflow as tf

loss_obj_scc = tf.keras.losses.SparseCategoricalCrossentropy()

使用如下方法直接报出如下问题: 原因是keras版本是2.8版本,可能与tf2.6不兼容,

pip install keras==2.6.0 即可解决

2022-03-27 22:41:02.116859: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.

2022-03-27 22:41:02.338609: E tensorflow/core/lib/monitoring/collection_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers
Traceback (most recent call last):
  File "C:/Users/yinchen/PycharmProjects/pythonExercise/tensorflow2exercise.py", line 8, in
    loss_obj_scc = tf.keras.losses.SparseCategoricalCrossentropy(
  File "C:\anaconda\envs\python38base\lib\site-packages\tensorflow\python\util\lazy_loader.py", line 62, in __getattr__
    module = self._load()
......

  File "C:\anaconda\envs\python38base\lib\site-packages\tensorflow\python\eager\monitoring.py", line 135, in __init__
    self._metric = self._metric_methods[self._label_length].create(*args)
tensorflow.python.framework.errors_impl.AlreadyExistsError: Another metric with the same name already exists.

#
Process finished with exit code 1

Original: https://blog.csdn.net/sa726663676/article/details/123783775
Author: sa726663676
Title: python3.8 安装tensorflow2.6问题

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/509073/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球