deep-spin / understanding-spigot

Code for the paper "Understanding the Mechanics of SPIGOT: Surrogate Gradients for Latent Structure Learning"
11 stars 0 forks source link

SparseMAP error in SST #3

Open jzhang38 opened 3 years ago

jzhang38 commented 3 years ago

Hi, I encounter the following error while running with SparseMAP in SST: Traceback (most recent call last): File "main.py", line 293, in args.latent_step_size, args.latent_grad_updates, args.latent_model_type) File "main.py", line 148, in main run_baseline, learning_rate, latent_step_size, latent_grad_updates) File "main.py", line 194, in run_model pred = model(x.t(), y, latent_config) File "/home/peiyuan_zhang/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(*input, *kwargs) File "/home/peiyuan_zhang/SparseLantent+ContrastiveLearning/understanding-spigot/sst/models.py", line 161, in forward parser_output = self.parser(encoded, latent_type, latent_config, self.decoder, embedded, y) File "/home/peiyuan_zhang/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 722, in _call_impl result = self.forward(input, **kwargs) File "/home/peiyuan_zhang/SparseLantent+ContrastiveLearning/understanding-spigot/sst/models.py", line 99, in forward parser_output = sparsemap(arc_scores) File "/home/peiyuan_zhang/SparseLantent+ContrastiveLearning/understanding-spigot/sst/structured_ste.py", line 44, in sparsemap return sparsemap_batched(arc_scores) File "/home/peiyuan_zhang/SparseLantent+ContrastiveLearning/understanding-spigot/sst/sparsemap.py", line 21, in sparsemap_batched sparsemap_proj = sparsemap_projection(arc_scores) File "/home/peiyuan_zhang/SparseLantent+ContrastiveLearning/understanding-spigot/sst/sparsemap.py", line 13, in sparsemap_projection fg.solve(max_iter=1, max_inner_iter=50, step_size=0) File "/home/peiyuan_zhang/SparseLantent+ContrastiveLearning/understanding-spigot/pytorch-struct/lp-sparsemap/lpsmap/api/autograd.py", line 84, in solve offset, pvars, scores = self._make_variables(pfg) File "/home/peiyuan_zhang/SparseLantent+ContrastiveLearning/understanding-spigot/pytorch-struct/lp-sparsemap/lpsmap/api/api.py", line 82, in _make_variables scores.append(self._ravel(var._scores)) File "/home/peiyuan_zhang/SparseLantent+ContrastiveLearning/understanding-spigot/pytorch-struct/lp-sparsemap/lpsmap/api/autograd.py", line 52, in _ravel return x.view(-1) RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

if I change the x.view(-1) to x.reshape(-1), following warning apprears: W TensorIterator.cpp:924] Warning: Mixed memory format inputs detected while calling the operator. The operator will output channels_last tensor even if some of the inputs are not in channels_last format. (function operator()) Loss: 0.20527401566505432 Train Accuracy: 0.7736994219653179 Validation Accuracy: 0.8061926605504587 Test Accuracy: 0.7935200439319056

Thank you.