Google Colab中的Tensorflow联邦教程在初始化代码段中给出错误

2024-04-23 16:33:46 发布

您现在位置:Python中文网/ 问答频道 /正文

以下是开始本教程之前需要运行的单元格

#@test {"skip": true}

# tensorflow_federated_nightly also bring in tf_nightly, which
# can causes a duplicate tensorboard install, leading to errors.
!pip uninstall --yes tensorboard tb-nightly

!pip install --quiet --upgrade tensorflow_federated_nightly
!pip install --quiet --upgrade nest_asyncio
!pip install --quiet tb-nightly  # or tensorboard, but not both

import nest_asyncio
nest_asyncio.apply()

它给出了以下错误:

ERROR: tensorflow 2.4.1 requires tensorboard~=2.4, which is not installed.
ERROR: tensorflow 2.4.1 has requirement gast==0.3.3, but you'll have gast 0.4.0 which is incompatible.
ERROR: tensorflow 2.4.1 has requirement grpcio~=1.32.0, but you'll have grpcio 1.34.1 which is incompatible.
ERROR: tensorflow 2.4.1 has requirement h5py~=2.10.0, but you'll have h5py 3.1.0 which is incompatible.
ERROR: datascience 0.10.6 has requirement folium==0.2.1, but you'll have folium 0.8.3 which is incompatible.

需要帮助解决这个问题。我对Tensorflow上的库和类不太熟悉


Tags: installpipyouwhichistensorflowhaveerror
2条回答

您可以像下面这样导入tensorflow联邦。它解决了我的错误。我尝试使用联邦学习进行图像分类,当我尝试导入tensorflow_Federated时,它总是给我错误

from tensorflow_federated import python as tff

即使控制台说有错误,pip包也应该正确安装

这是因为笔记本使用tensorflow-federated-nightly,这取决于安装tf-nightly覆盖基本tensorflow安装。但是pip仍然认为TFF依赖项将与现在被覆盖的TensorFlow核心包冲突

tensorflow添加到!pip uninstall列表可能会消除此错误,但笔记本的功能不会改变

相关问题 更多 >