PathomicFusion
PathomicFusion copied to clipboard
TypeError: scatter_mean() takes from 2 to 5 positional arguments but 6 were given
Hi @Richarizardd
Great Day!
I was trying to train GCN model but facing
TypeError: scatter_mean() takes from 2 to 5 positional arguments but 6 were given
while trying to run the following command.
python train_cv.py --exp_name surv_15_rnaseq --task surv --mode graph --model_name graph --niter 0 --niter_decay 50 --lr 0.002 --init_type max --reg_type none --lambda_reg 0 -use_vgg_features 1 --gpu_ids 0
Installation : torch-cluster-1.6.0 torch-geometric-1.3.0 torch-scatter-2.0.9 torch-sparse-0.6.15 torch-spline-conv-1.2.1 cudatoolkit-11.3.1 pytorch-1.10.1-py3.9_cuda11.3_cudnn8.2.0
Can you please suggest.
Hi @shubhaminnani - At the time of this publication, one of the earliest versions of torch-geometric
was used. Your torch-scatter
, torch-sparse
, and other packages are of the latest update and may not have good backwards compatibility with previous versions of PyG.
For this study: the dependencies for PyG==1.3.0 may have been torch-scatter==1.3.1, torch-sparse==0.4.0, torch-cluster==1.4.4. Though this codebase depends on legacy code, I would recommend updating everything to the most recent versions of PyG, which may require some minor modifications to the forward pass of some of the model architectures. In addition, note that there may be some minor instabilities with previous versions of PyG, e.g. - https://github.com/pytorch/pytorch/issues/50469.
Thanks for update. Will check and revert with you!
Hi @Richarizardd , I am pretty much new to Pathology, if you can help to update the code, it will be really helpful. Thanks!
Hi @Richarizardd
I was not able to understand whats needs to be changed here.
class GraphNet(torch.nn.Module):
def __init__(self, features=1036, nhid=128, grph_dim=32, nonlinearity=torch.tanh,
dropout_rate=0.25, GNN='GCN', use_edges=0, pooling_ratio=0.20, act=None, label_dim=1, init_max=True):
super(GraphNet, self).__init__()
self.dropout_rate = dropout_rate
self.use_edges = use_edges
self.act = act
self.conv1 = SAGEConv(features, nhid)
self.pool1 = SAGPooling(nhid, ratio=pooling_ratio, gnn=GNN)#, nonlinearity=nonlinearity)
self.conv2 = SAGEConv(nhid, nhid)
self.pool2 = SAGPooling(nhid, ratio=pooling_ratio, gnn=GNN)#, nonlinearity=nonlinearity)
self.conv3 = SAGEConv(nhid, nhid)
self.pool3 = SAGPooling(nhid, ratio=pooling_ratio, gnn=GNN)#, nonlinearity=nonlinearity)
self.lin1 = torch.nn.Linear(nhid*2, nhid)
self.lin2 = torch.nn.Linear(nhid, grph_dim)
self.lin3 = torch.nn.Linear(grph_dim, label_dim)
self.output_range = Parameter(torch.FloatTensor([6]), requires_grad=False)
self.output_shift = Parameter(torch.FloatTensor([-3]), requires_grad=False)
if init_max:
init_max_weights(self)
print("Initialzing with Max")
def forward(self, **kwargs):
data = kwargs['x_grph']
data = NormalizeFeaturesV2()(data)
data = NormalizeEdgesV2()(data)
x, edge_index, edge_attr, batch = data.x, data.edge_index, data.edge_attr, data.batch
#x, edge_index, edge_attr, batch = data.x.type(torch.cuda.FloatTensor), data.edge_index.type(torch.cuda.LongTensor), data.edge_attr.type(torch.cuda.FloatTensor), data.batch
x = F.relu(self.conv1(x, edge_index)) ##need to check this
From above code, it seem we are passing 5 values only, but torch_scatter throws the Error.
Can you please suggest?
I also encountered this problem. Have you solved it?
@shubhaminnani
This is version dependencies of PyG. I was not able to look into this further. Thanks!
i have solved. you should change the ''scatter.py'' file.
Hi @zqy396
Can you please post the changes from the scatter.py? It will be really helpful.
Thanks!
Is this the correct thing to be updated?
@zqy396 May I ask how you made modifications in the scatter.py file?
https://blog.csdn.net/m0_37052320/article/details/118368656
@zqy396 May I ask how you made modifications in the scatter.py file?