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 <module>
#     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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值