deepspline icon indicating copy to clipboard operation
deepspline copied to clipboard

tensor shape error in do_all_multi_vary_spline.py

Open trissim opened this issue 4 years ago • 0 comments

Hello,

Thank you for sharing the code. The dataset generation works fine but running do_all_multi_vary_spline.py results in an error. I attempted a fix, but this led to another error.

The first error is in "multi_vary_spline_model.py" on line 270 in match_lines_sequence i_n_line = int(line_mask[i_batch].sum().data[0]) IndexError: invalid index of a 0-dim tensor. Use tensor.item() to convert a 0-dim tensor to a Python number

A quick google search lead to this page, where they suggest that I replace data[0], with item()

Trying that lead to the next error "in multi_vary_spline_model.py" on line 274 in match_lines_sequence pos_t[i_batch] = target_pos[i_batch].data RuntimeError: The expanded size of the tensor (6) must match the existing size (18) at non-singleton dimension 1. Target sizes: [3, 6, 2]. Tensor sizes: [18, 2]

I tried fixing this by reshaping the tensor by replacing pos_t[i_batch] = target_pos[i_batch].data with pos_t[i_batch] = torch.reshape(target_pos[i_batch].data, (3, 6, 2))

This led to the following error again in "multi_vary_spline_model.py" but line 314 in match_lines_sequence pos_t[i_batch, :i_n_line] = tmp_target.data RuntimeError: The expanded size of the tensor (6) must match the existing size (2) at non-singleton dimension 1. Target sizes: [2, 6, 2]. Tensor sizes: [2, 2]

At this point I am stuck at a dead end. I believe the issue is in the forward function since there is a mismach between the prediction and truth. The fact that the tensor shrinks in dimension to [2,2] after being reshaped from [18,2] to [3,6,2] also suggests that some bug in forward() might be erroneously shrinking the prediction tensor dimensions.

trissim avatar Aug 24 '20 16:08 trissim