when I use this command python src/main.py GAT, error occured
Parsing Arguments
Parsed arguments: Namespace(gnn='HeteroGNN', train='/mnt/afs/koin/GNN_OPF/Data/train', val='/mnt/afs/koin/GNN_OPF/Data/val', test='/mnt/afs/koin/GNN_OPF/Data/test', save_model=True, model_name='477uOTwV', plot=True, optimizer='Adam', criterion='MSELoss', batch_size=32, n_epochs=200, learning_rate=0.001, weight_decay=0.05, mixed_loss_weight=0.1, n_hidden_gnn=2, gnn_hidden_dim=32, n_hidden_lin=2, lin_hidden_dim=8, patience=40, plot_node_error=False, normalize=False, no_linear=False, loss_type='standard', value_mode='all', pretrain=False, from_checkpoint=None)
Training data not found, loading from json files...
210it [01:00, 3.47it/s]
Training data loaded and saved to pkl file
Validation data not found, loading from json files...
100it [00:30, 3.25it/s]
Validation data loaded and saved to pkl file
Test data not found, loading from json files...
100it [00:28, 3.48it/s]
Test data loaded and saved to pkl file
Data Loaded
Number of training samples = 210
Number of validation samples = 100
Training Model
GNN:
HeteroGNN(
(convs): ModuleList(
(0-1): 2 x HeteroConv(num_relations=32)
)
(input_lins): ModuleDict(
(load): Linear(-1, 24, bias=True)
(gen): Linear(-1, 24, bias=True)
(load_gen): Linear(-1, 24, bias=True)
(ext): Linear(-1, 24, bias=True)
)
(lins): ModuleDict(
(0): ModuleDict(
(load): Linear(24, 38, bias=True)
(gen): Linear(24, 38, bias=True)
(load_gen): Linear(24, 38, bias=True)
)
(1): ModuleDict(
(load): Linear(38, 2, bias=True)
(gen): Linear(38, 1, bias=True)
(load_gen): Linear(38, 1, bias=True)
)
)
)
Current device: cuda
0%| | 0/200 [00:00<?, ?it/s]/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/nn/dense/linear.py:130: UserWarning: An output with one or more elements was resized since it had shape [1, 24], which does not match the required output shape [24]. This behavior is deprecated, and in a future PyTorch release outputs will not be resized unless they have zero elements. You can explicitly reuse an out tensor t by resizing it, inplace, to zero elements with t.resize_(0). (Triggered internally at ../aten/src/ATen/native/Resize.cpp:28.)
return F.linear(x, self.weight, self.bias)
0%| | 0/200 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/mnt/afs/koin/GNN_OPF/src/main.py", line 63, in <module>
main()
File "/mnt/afs/koin/GNN_OPF/src/main.py", line 48, in main
model, losses, val_losses, last_batch = train_model_hetero(arguments, train, val)
File "/mnt/afs/koin/GNN_OPF/src/train/train_hetero.py", line 48, in train_model_hetero
epoch_loss += train_batch_hetero(data=batch, model=gnn, optimizer=optimizer, criterion=criterion, loss_type=arguments.loss_type, device=device)
File "/mnt/afs/koin/GNN_OPF/src/train/train_hetero.py", line 85, in train_batch_hetero
out_dict = model(data.x_dict, data.edge_index_dict, data.edge_attr_dict)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/mnt/afs/koin/GNN_OPF/src/models/HeterogenousGNN.py", line 121, in forward
x_dict = conv(x_dict, edge_index_dict, edge_attr_dict)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/nn/conv/hetero_conv.py", line 159, in forward
out = self.convs[edge_type](*args, **kwargs)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl
return forward_call(*args, **kwargs)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/nn/conv/gin_conv.py", line 179, in forward
out = self.propagate(edge_index, x=x, edge_attr=edge_attr, size=size)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/nn/conv/message_passing.py", line 463, in propagate
out = self.message(**msg_kwargs)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/nn/conv/gin_conv.py", line 194, in message
edge_attr = self.lin(edge_attr)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1568, in _call_impl
result = forward_call(*args, **kwargs)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/nn/dense/linear.py", line 130, in forward
return F.linear(x, self.weight, self.bias)
IndexError: Dimension out of range (expected to be in range of [-1, 0], but got 1)
please help me for dealing with it
I just followed the instrustion in homepage for dataset generating
neither HeteroGNNand GAT can launch training, abeve exception is hetero's, and below is homo's
Parsing Arguments
Parsed arguments: Namespace(gnn='GAT', train='/mnt/afs/koin/GNN_OPF/Data/train', val='/mnt/afs/koin/GNN_OPF/Data/val', test='/mnt/afs/koin/GNN_OPF/Data/test', save_model=True, model_name='4L54oAxk', plot=True, optimizer='Adam', criterion='MSELoss', batch_size=32, n_epochs=200, learning_rate=0.001, weight_decay=0.05, mixed_loss_weight=0.1, n_hidden_gnn=2, gnn_hidden_dim=32, n_hidden_lin=2, lin_hidden_dim=8, patience=40, plot_node_error=False, normalize=False, no_linear=False, loss_type='standard', value_mode='all', pretrain=False, from_checkpoint=None)
Training data not found, loading from json files...
210it [00:44, 4.68it/s]
Training data loaded and saved to pkl file
Validation data not found, loading from json files...
100it [00:19, 5.07it/s]
Validation data loaded and saved to pkl file
Test data not found, loading from json files...
100it [00:19, 5.00it/s]
Test data loaded and saved to pkl file
Data Loaded
Number of training samples = 210
Number of validation samples = 100
Training Model
Input shape: 8
Output shape: 4
GNN:
GAT(
(convs): ModuleList(
(0): GATv2Conv(8, 32, heads=8)
(1-2): 2 x GATv2Conv(256, 32, heads=8)
)
(lins): ModuleList(
(0): Linear(in_features=256, out_features=16, bias=True)
(1-2): 2 x Linear(in_features=16, out_features=16, bias=True)
(3): Linear(in_features=16, out_features=4, bias=True)
)
)
Current device: cuda
0%| | 0/200 [00:00<?, ?it/s]
Traceback (most recent call last):
File "/mnt/afs/koin/GNN_OPF/src/main.py", line 63, in <module>
main()
File "/mnt/afs/koin/GNN_OPF/src/main.py", line 46, in main
model, losses, val_losses, last_batch = train_model(arguments, train, val)
File "/mnt/afs/koin/GNN_OPF/src/train/train_homo.py", line 62, in train_model
epoch_val_loss += evaluate_batch(data=batch, model=gnn, criterion=criterion, loss_type=arguments.loss_type, device=device)
File "/mnt/afs/koin/GNN_OPF/src/train/train_homo.py", line 140, in evaluate_batch
loss = vector_loss(out, data, criterion)
File "/mnt/afs/koin/GNN_OPF/src/train/train_homo.py", line 115, in vector_loss
data_mag_and_data_angle = data[:,-2:]
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/data/batch.py", line 177, in __getitem__
return self.index_select(idx)
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/data/batch.py", line 165, in index_select
return [self.get_example(i) for i in idx]
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/data/batch.py", line 165, in <listcomp>
return [self.get_example(i) for i in idx]
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/data/batch.py", line 120, in get_example
data = separate(
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/data/separate.py", line 38, in separate
data_store[attr] = _separate(attr, batch_store[attr], idx, slices,
File "/usr/local/lib/miniconda3/envs/pytorch2.1/lib/python3.10/site-packages/torch_geometric/data/separate.py", line 65, in _separate
start, end = int(slices[idx]), int(slices[idx + 1])
ValueError: only one element tensors can be converted to Python scalars
I found the reason why the hetero's demo can not run:
as shown in pic, edge_attr appears to be empty list which made nn.linear can not determine the dimension to use
So, any suggestion about it?
when I use this command
python src/main.py GAT
, error occuredplease help me for dealing with it
I just followed the instrustion in homepage for dataset generating
neither
HeteroGNN
andGAT
can launch training, abeve exception is hetero's, and below is homo'sI'd appreciate it if you could help, thanks