运行个性化联邦项目

一、首次直接运行 使用pcas数据集

PersonalizedFL-main   针对fedclip项目文件夹

1、选好torch环境 python=3.8

2、根据requirements.txt下载相关包

运行  pip install -r .\requirements.txt

 3、fed_at_clip.py文件包报红

使用命令下载pip install utils -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com

 安装不对 ,这是从文件中导入的,

应该改为导入的完整目录

4、安装的clip有问题,不能直接pip安装

 -在此卸载clip:pip install clip

-通过使用openAI提供的github安装源安装

pip install ftfy regex tqdm
pip install git+https://github.com/openai/CLIP.git

-再报错: error: RPC failed; curl 28 Recv failure: Connection was reset
                  fatal: expected flush after ref listing
                  error: subprocess-exited-with-error

-输入命令:git config --global http.sslVerify "false"

-再下载clip 成功

 5、小绿三角运行

在下载

6、 报错 AssertionError: Torch not compiled with CUDA enabled

将cuda改为cpu,本电脑没有装cuda

在models.py里,device=“cpu”

 7、数据集找不到错误,因为没有下载数据集

 去https://wjdcloud.blob.core.windows.net/dataset/PACS.zip下载PACS数据集

另外,昨天在命令行使用wget下载,发现下完之后找不到该文件,不知道下载到哪里了

数据集那里改了下地址,是org.root_dir 没有定义

后续 读到了在fed_at_clip中,有定义root_dir的参数,在此处修改即可

8、pip install git+https://github.com/openai/CLIP.git报错没有git

在该pytorch下conda Install git 就可,不能pip install git

9、配pytorch环境,选择

 

10、pip安装requirement文件报错  ERROR: Could not find a version that satisfies the requirement numpy==1.22.0 (from versions: none) E

 使用镜像源安装,即可,都手动安装

pip install numpy -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com

11、下载的clip模型

二、第二次运行 运行其他baseline项目,使用covid19数据集

1、运行Fed》main.py

2、报错:AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
是因为np.int 在 NumPy 1.20 中已弃用,在 NumPy 1.24 中已删除

改:在datasplit.py中将np.int改为np.int_即可

 3、报错ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (15,) + inhomogeneous part.

改:更换了numpy版本,从原来的numpy1.24.3替换为numpy1.22.0

pip uninstall numpy

再安装一下pip install numpy==1.22.0 成功

4、报了个警告:VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  tmparr = np.array(tmparr)

可见弃用警告:不推荐使用从参差不齐的嵌套序列(这是具有不同长度或形状的列表或元组或 ndarray 的列表或元组)创建 ndarray。如果要执行此操作,则必须在创建 ndarray 时指定“dtype=object”。
  tmparr = np.array(tmparr)

不过能正常训练

5、发现一个事情fed_at_clip.py的当前目录 ./ 是指fedclip

猜你喜欢

转载自blog.csdn.net/qq_51141671/article/details/131911199