当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Python PyTorch Store.set用法及代码示例


本文简要介绍python语言中 torch.distributed.Store.set 的用法。

用法:

torch.distributed.Store.set(self: torch._C._distributed_c10d.Store, arg0: str, arg1: str) → None

参数

  • key(str) -要添加到商店的 key 。

  • value(str) -key 关联的值将添加到存储中。

根据提供的 keyvalue 将键值对插入到存储中。如果 key 已存在于商店中,它将用新提供的 value 覆盖旧值。

例子:

>>> import torch.distributed as dist
>>> from datetime import timedelta
>>> store = dist.TCPStore("127.0.0.1", 0, 1, True, timedelta(seconds=30))
>>> store.set("first_key", "first_value")
>>> # Should return "first_value"
>>> store.get("first_key")

相关用法


注:本文由纯净天空筛选整理自pytorch.org大神的英文原创作品 torch.distributed.Store.set。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。