Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Encountering ValueError with Tensor Dimension #3

Open
isolated-paul opened this issue May 10, 2023 · 2 comments
Open

Encountering ValueError with Tensor Dimension #3

isolated-paul opened this issue May 10, 2023 · 2 comments

Comments

@isolated-paul
Copy link

isolated-paul commented May 10, 2023

Hi,
Thank you for sharing the code. I am trying to run the experimentation on Google Colab. But I keep running into a problem when I am trying to train or test the model.

Could you please help me understand what is the source of this problem because I am having difficulty understanding it.

Basically, Colab gives me the following error:

`ValueError Traceback (most recent call last)

in <cell line: 5>()
5 with torch.no_grad():
6 for i, sample in enumerate(tqdm.tqdm(test_loader, desc="Visualising")):
----> 7 prediction = model.to(device)(sample.to(device)) ## Don't understand this line
8 # target = sample.y.clone()
9 # print('\n')

6 frames

/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py in _call_impl(self, *args, **kwargs)
1499 or _global_backward_pre_hooks or _global_backward_hooks
1500 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1501 return forward_call(*args, **kwargs)
1502 # Do not call functions when jit is used
1503 full_backward_hooks, non_full_backward_hooks = [], []

in forward(self, data)
95 # Downstream
96 copy0 = x.clone()
---> 97 x = self.pool1(x, data)
98 x = self.conv11(x, *scale_attr[1])
99 x = self.conv12(x, *scale_attr[1])

/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py in _call_impl(self, *args, **kwargs)
1499 or _global_backward_pre_hooks or _global_backward_hooks
1500 or _global_forward_hooks or _global_forward_pre_hooks):
-> 1501 return forward_call(*args, **kwargs)
1502 # Do not call functions when jit is used
1503 full_backward_hooks, non_full_backward_hooks = [], []

/usr/local/lib/python3.10/dist-packages/gem_cnn/nn/pool.py in forward(self, x, data)
44 size = (num_fine, num_coarse)
45
---> 46 out = self.propagate(edge_index=edge_index, x=x, connection=connection, size=size)
47 return out
48

/usr/local/lib/python3.10/dist-packages/torch_geometric/nn/conv/message_passing.py in propagate(self, edge_index, size, **kwargs)
457 kwargs[arg] = decomp_kwargs[arg][i]
458
--> 459 coll_dict = self._collect(self._user_args, edge_index, size,
460 kwargs)
461

/usr/local/lib/python3.10/dist-packages/torch_geometric/nn/conv/message_passing.py in _collect(self, args, edge_index, size, kwargs)
333
334 if isinstance(data, Tensor):
--> 335 self._set_size(size, dim, data)
336 data = self._lift(data, edge_index, dim)
337

/usr/local/lib/python3.10/dist-packages/torch_geometric/nn/conv/message_passing.py in _set_size(self, size, dim, src)
243 size[dim] = src.size(self.node_dim)
244 elif the_size != src.size(self.node_dim):
--> 245 raise ValueError(
246 (f'Encountered tensor with size {src.size(self.node_dim)} in '
247 f'dimension {self.node_dim}, but expected size {the_size}.'))

ValueError: Encountered tensor with size 24269 in dimension 0, but expected size 9708.`

@isolated-paul
Copy link
Author

isolated-paul commented May 10, 2023

Is the problem related to how the dataset is being transformed under the "pre-computed graph transform" set up and how the datasets are being transformed and loaded?

The ValueError shown above is with respect to the first dimension, in this case the dimension 0 value 24269.

Here are two samples from the "test_loader" :

(device = 'cpu')

Visualising: 100%|██████████| 5/5 [00:00<00:00, 77.37it/s]

sample 0
MultiscaleDataBatch(y=[24269, 3], pos=[24269, 3], face=[3, 48534], inlet_index=[1626], normal=[24269, 3], edge_index=[2, 271008], geo=[24269], mask=[24269], node_mask=[24269], edge_mask=[271008], edge_coords=[271008, 2], connection=[271008], weight=[271008], frame=[24269, 3, 3], matrix_features=[24269, 7, 5], batch=[24269], ptr=[2])

sample 1
MultiscaleDataBatch(y=[18737, 3], pos=[18737, 3], face=[3, 37470], inlet_index=[923], normal=[18737, 3], edge_index=[2, 207999], geo=[18737], mask=[18737], node_mask=[18737], edge_mask=[207999], edge_coords=[207999, 2], connection=[207999], weight=[207999], frame=[18737, 3, 3], matrix_features=[18737, 7, 5], batch=[18737], ptr=[2])

@sukjulian
Copy link
Owner

Hi! It might be that the version of PyG that Google colab is using is incompatible with gem_cnn (see here). Could you try resetting PyG to version 2.0.3?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants