OpenMined / KotlinSyft

The official Syft worker for secure on-device machine learning
https://www.openmined.org
Apache License 2.0
85 stars 28 forks source link

Hosting the plans on PyGrid shows torchscript error #285

Closed mustansarsaeed closed 3 years ago

mustansarsaeed commented 3 years ago

Question

Hosting Plan for workers showing torchscript error

Further Information

Hi, I am using pysyft 0.2.x and PyGrid. I have hosted a plan that I want to run on Mobile worker. Plan is as follows:

@sy.func2plan()
def evaluate_model_plan(X, y, batch_size, model_params):
    # Load model params into the model
    set_model_params(model, model_params)
    # Test
    with th.no_grad():
        logits = model(X)
    preds = th.argmax(logits, dim=1)
    target = th.argmax(y, dim=1)
    test_accuracy = preds.eq(target).sum().float() / batch_size
    #acc = preds.eq(target).float().mean()
    return test_accuracy
test_x = th.randn(3, 28 * 28)
test_y = nn.functional.one_hot(th.tensor([1, 2, 3]), 10)
p = evaluate_model_plan.build(test_x, test_y, 64, model_params)

Plan built successfully. print(evaluate_model_plan.code) displays the code but print(evaluate_model_plan.torchscript.code) , Torchscipt shows the following error.

---------------------------------------------------------------------------
 AttributeError                            Traceback (most recent call last)
 <ipython-input-126-7912977015b3> in <module>
 ----> 1 print(evaluate_model_plan.torchscript.code)
 AttributeError: 'NoneType' object has no attribute 'code'

What can be the issue? I am following https://github.com/OpenMined/PyGrid/blob/dev/examples/model-centric/01-Create-plan.ipynb . Training plan is working fine.

Screenshots

Screenshot from 2020-11-26 18-33-19

System Information

Additional Context

Add any other context about the problem here.

vkkhare commented 3 years ago

@mustansarsaeed your pygrid version is newer one I think. Please use the pygrid version at the commit 0e93aa645a63a02f45ae72b4ff3106c6402dbadf