I’m working on my first project with PyTorch and Syft. Here I am facing an issue of matrices expected. This same dataset works for training and it gets completed with no issue. As soon as I try to run test loop, it shows the above error.
The batch size is 1024, and input features 30.
class MLPUpdated(nn.Module):
def __init__(self):
super().__init__()
self.layers = nn.Sequential(
nn.Linear(30, 32),
nn.ReLU(),
nn.Dropout(0.2),
nn.Linear(32,16),
nn.ReLU(),
nn.Dropout(0.1),
nn.Linear(16, 8),
nn.ReLU(),
nn.Linear(8, 1),
nn.Sigmoid()
)
def forward(self, x):
return self.layers(x)
Error:
Traceback (most recent call last):
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\frameworks\torch\tensors\interpreters\native.py”, line 336, in handle_func_command
new_args, new_kwargs, new_type, args_type = hook_args.unwrap_args_from_function(
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\generic\frameworks\hook\hook_args.py”, line 167, in unwrap_args_from_function
new_args = args_hook_function(args_)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\generic\frameworks\hook\hook_args.py”, line 356, in
return lambda x: f(lambdas, x)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\generic\frameworks\hook\hook_args.py”, line 534, in three_fold
lambdas[0](args_[0], **kwargs),
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\generic\frameworks\hook\hook_args.py”, line 331, in
else lambda i: forward_functype(i)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\frameworks\torch\hook\hook_args.py”, line 27, in
else (_ for _ in ()).throw(PureFrameworkTensorFoundError),
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\frameworks\torch\hook\hook_args.py”, line 27, in
else (_ for _ in ()).throw(PureFrameworkTensorFoundError),
syft.exceptions.PureFrameworkTensorFoundError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “federated_learning.py”, line 274, in
test_loss, test_acc = test(args, model, device, test_loader, epoch)
File “federated_learning.py”, line 145, in test
output = model(data)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\nn\modules\module.py”, line 532, in call
result = self.forward(*input, **kwargs)
File “D:\internship\Indo_Aus\Federated Learning\Split-Learning-and-Federated-Learning\src\models.py”, line 213, in forward
return self.layers(x)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\nn\modules\module.py”, line 532, in call
result = self.forward(*input, **kwargs)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\nn\modules\container.py”, line 100, in forward
input = module(input)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\nn\modules\module.py”, line 532, in call
result = self.forward(*input, **kwargs)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\nn\modules\linear.py”, line 87, in forward
return F.linear(input, self.weight, self.bias)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\generic\frameworks\hook\hook.py”, line 335, in overloaded_func
response = handle_func_command(command)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\frameworks\torch\tensors\interpreters\native.py”, line 380, in handle_func_command
response = cls.get_response(cmd, args, kwargs_)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\frameworks\torch\tensors\interpreters\native.py”, line 414, in get_response
response = command_method(*args, **kwargs_)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\torch\nn\functional.py”, line 1370, in linear
ret = torch.addmm(bias, input, weight.t())
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\generic\frameworks\hook\hook.py”, line 335, in overloaded_func
response = handle_func_command(command)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\frameworks\torch\tensors\interpreters\native.py”, line 380, in handle_func_command
response = cls.get_response(cmd, args, kwargs_)
File “C:\Users\het\AppData\Local\Programs\Python\Python38\lib\site-packages\syft\frameworks\torch\tensors\interpreters\native.py”, line 414, in get_response
response = command_method(*args, **kwargs_)
RuntimeError: matrices expected, got 1D, 2D tensors at C:\w\1\s\windows\pytorch\aten\src\TH/generic/THTensorMath.cpp:131