KFrank:

import torch
>>> import torch.nn as nn
>>> torch.__version__
'1.9.0'
>>> 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)
...
>>> _ = torch.manual_seed (2021)
>>> MLPUpdated() (torch.randn (1024, 30))



Hey KFrank,
Thanks for the reply.
The model is working perfectly, and the data passed inside the forward function is also tensor. But still I’m getting this error.
Traceback (most recent call last):
  File "federated_learning.py", line 283, in <module>
    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 206, 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)

This error is indicating that something is wrong in the self.layers
Given below are the tensors being passed inside the self.layers function.
[ 3.9251e+00,  6.7676e-01,  1.3711e+00,  ...,  4.6753e-01,
         -8.6226e-02, -3.1110e-02],
        [ 8.0766e+00, -1.7748e-01,  1.2341e-01,  ..., -2.9790e-01,
         -9.5155e-02,  1.1550e-01],
        [-2.8701e-01, -9.5842e-02, -3.6565e+00,  ...,  3.8841e-01,
         -2.5426e+00, -2.0138e+00]])

The test function is given below.
def test(args, model, device, test_loader, epoch):
    """Evaluate the model

    Args:
        args: Hyper-parameters for testing
        model: The model to be evaluated
        device: Training device (e.g. cpu/gpu)
        test_loader: Federated data loader for testing
        epoch: Current epoch

    Returns:
        test_loss: Test loss for current epoch
        test_acc: Test accuracy for current epoch
    """
    model.eval()
    test_loss, correct = 0.0, 0

    with torch.no_grad():
        for data, target in test_loader:
            data, target = data.to(device), target.to(device)

            # Feed-forward data through the model
            # print("Test: ", data.location.size)
            # print("Test Type: ", type(target))
            output = model(data)

            # Sum up the batch loss
            binary_loss = torch.nn.BCEWithLogitsLoss()
            target = target.unsqueeze(1)
            target = target.float()
            test_loss += binary_loss(output, target, reduction="sum").item()
            # test_loss += F.nll_loss(output, target, reduction="sum").item()

            # Retrieve the index of the maximum log-probability
            pred = output.argmax(1, keepdim=True)

            # Get the number of correct classifications
            correct += pred.eq(target.view_as(pred)).sum().item()

    # Average the test_loss
    test_loss /= len(test_loader.dataset)

    # Test accuracy
    test_acc = correct / len(test_loader.dataset)

    print("\nTest set - Epoch: {} - Loss: {:.4f}, Acc: {:.2f}%\n".format(
        epoch, test_loss, 100 * test_acc))

    return test_loss, test_acc

Test Loader is given below.
test_ds = PeopleDataset(test_file)
    # train_loader = torch.utils.data.DataLoader(train_ds,batch_size=args.batch_size, shuffle=True)

test_loader = sy.FederatedDataLoader(test_ds.federate(workers),
                  batch_size=args.batch_size, shuffle=True, **kwargs)