oafolabi:

non_linearity(nn.Linear(size_list[i-1], size_list[i]))


your non_linearity is a module nn.ReLU whose first constructor arg is inplace, a boolean flag. To chain modules together, use nn.Sequential instead.