我试图从其高级示例中重现 Pysyft Asynchronous-federated-learning-on-MNIST。where@torch.jit.script
在损失函数之前使用。我收到这个错误,不知道这是怎么回事
RuntimeError:未定义的值_Reduction:在/home/ab/.virtualenvs/aic/lib/python3.6/site-packages/syft/generic/frameworks/hook/hook.py:1829:20
reduction = _Reduction.legacy_get_string(size_average, reduce)
它实际上是由这些行引起的
@torch.jit.script
def loss_fn(pred, target):
return F.nll_loss(input=pred, target=target)
train_config = sy.TrainConfig(
model=traced_model,
loss_fn=loss_fn,
batch_size=batch_size,
shuffle=True,
max_nr_batches=max_nr_batches,
epochs=1,
optimizer="SGD",
optimizer_args={"lr": lr},
)