Multiple values for argument

Tags: , ,

I am trying to convert this code passing it with pysyft refference

like this :

class SyNet(sy.Module):
  def __init__(self,embedding_size, num_numerical_cols, output_size, layers, p ,torch_ref):
    super(SyNet, self ).__init__(  embedding_size, num_numerical_cols , output_size , layers , p=0.4  ,torch_ref=torch_ref  )
    self.all_embeddings=self.torch_ref.nn.ModuleList([nn.Embedding(ni, nf) for ni, nf in embedding_size])

    all_layers= []
    num_categorical_cols = sum((nf for ni, nf in embedding_size))
    input_size = num_categorical_cols + num_numerical_cols

    for i in layers:
      input_size = i

    all_layers.append(self.torch_ref.nn.Linear(layers[-1], output_size))

    self.layers = self.torch_ref.nn.Sequential(*all_layers)

  def forward(self, x_categorical, x_numerical):
    embeddings= []
    for i,e in enumerate(self.all_embeddings):

    x_numerical = self.batch_norm_num(x_numerical)
    x =[x, x_numerical], 1)
    x = self.layers(x)
    return x

But when I try to create a instance of the model

model = SyNet( categorical_embedding_sizes, numerical_data.shape[1], 2, [200,100,50], p=0.4 ,torch_ref= th)

I got a TypeError

TypeError: multiple values for argument ‘torch_ref’

I tried to change the order of the arguments but i got an error about positional arguments . Can you help me , I am not very experienced in classes and functions (oop)

Thank you in advance !


Looking at PySyft source code for Module. The constructor of your class parent only takes a single argument: torch_ref.

You should therefore call the super constructor with:

super(SyNet, self).__init__(torch_ref=torch_ref) # line 3

removing all arguments but torch_ref from the call.

Source: stackoverflow