究极小白详解pymarl代码结构(第零篇,一些warning和bug的处理)

设置模式捕获

SETTINGS['CAPTURE_MODE'] = "sys" # "sys" for windows else "fd"

如注释,Windows系统就采用sys,其他系统采用fd

Experiment实例添加save_git_info参数

ex = Experiment("pymarl", save_git_info=False) 
# ValueError: Cannot import git (pip install GitPython).
# Either GitPython or the git executable is missing.
# You can disable git with:
#     sacred.Experiment(..., save_git_info=False)

load添加Loader=yaml.FullLoader参数

config_dict = yaml.load(f, Loader=yaml.FullLoader)

collections.Mapping改为collections.abc

from collections.abc import Mapping

......

def recursive_dict_update(d, u):
    for k, v in u.items():
        if isinstance(v, Mapping):
            d[k] = recursive_dict_update(d.get(k, {}), v)
        else:
            d[k] = v
    return d

先变array再变tonser

            v=np.array(v)
            v = th.as_tensor(v, dtype=dtype, device=self.device)

os.EX_OK

    # Making sure framework really exits
    try:
        OK = os.EX_OK # os.EX_OK旨在linux上面有,windows里面的os库里面没有这个函数
    except AttributeError:  # On a non-unix system
        OK = 0
    os._exit(OK) # os._exit(OK)是退出程序,不再执行之后的所有函数

TypeError: can't convert cuda:0 device type tensor to numpy. Use Tensor.cpu() to copy the tensor to host memory first.

        if dtype is None:
            return self.cpu().numpy()
        else:
            return self.cpu().numpy().astype(dtype, copy=False)

模型载入注意

checkpoint_path: "" # Load a checkpoint from this path,
# such as "results/models/qmix__2023-12-08_15-44-28",we must use '/' and we can't use Chinese 

只能使用正斜杠来表示路径,反斜杠或者r只读都会报错

另外不能使用中文,使用中文会有load的报错。

  • 6
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值