PySyft从Jupyter笔记本到Python脚本

2024-09-28 19:21:59 发布

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

我正试图按照PySyft的指示来启动一个 duet

我的实际问题是无法在.py文件中执行以下命令

duet.store.pandas
duet.store[key]

这是一个重现错误的演示

首先是“数据所有者”

import syft as sy 
import torch as th
import time

duet=sy.launch_duet("network_url=http://localhost:5000",loopback=True)
print(duet)
x=th.Tensor([1,2,3]).tag("data")
x_p=x.send(duet,pointable=True)
print(x_p)

具有以下输出

♫♫♫ > CONNECTED!

<DomainClient: <UID: daf0e0361efa494f860ce451e780f084>>
<syft.proxy.torch.TensorPointer object at 0x000002627F06F790>

其次是“数据科学家”

import syft as sy
import torch as th 
import time 

time.sleep(20)
duet=sy.join_duet("network_url=http://localhost:5000",loopback=True)
print(duet)
print("sleep")
time.sleep(30)
if duet is not None:
    print("before exec")
    ptr=duet.store["data"]
    print("its executed")

具有以下输出


♫♫♫ > CONNECTED!
<Duet: <UID: daf0e0361efa494f860ce451e780f084>>
sleep
before exec

“其已执行”永远不会打印,程序也不会完成其执行


Tags: 数据storeimporttrueurltimeassleep