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

Error when training from scratch #12

Open
toshi2k2 opened this issue Oct 4, 2021 · 1 comment
Open

Error when training from scratch #12

toshi2k2 opened this issue Oct 4, 2021 · 1 comment

Comments

@toshi2k2
Copy link

toshi2k2 commented Oct 4, 2021

The model runs into following error if training from scratch and not running train.py:

Total imgs for test of occ_level ZERO and occ_type  4341
Testing
  0%|                                                                                         | 0/4341 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "/home/CompositionalNets/Code/test.py", line 138, in <module>
    acc,scores = test(models=nets, test_data=test_imgset, batch_size=1)
  File "/home/CompositionalNets/Code/test.py", line 40, in test
    output, *_ = models[0](input)
  File "/home/toshi/base/lib/python3.9/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/CompositionalNets/Code/model.py", line 62, in forward
    mix_likeli = self.pointwiseinference(vmf_activations)
  File "/home/toshi/base/lib/python3.9/site-packages/torch/nn/modules/module.py", line 889, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/CompositionalNets/Code/model.py", line 223, in forward
    foreground = foreground.reshape((-1, self.num_classes,
RuntimeError: shape '[-1, 10, 4, 1, 7, 12]' is invalid for input of size 3612

Steps to recreate -

  1. Add to (top of) vMF_clustering.py, comptSimMat.py, Learn_mix_model_vMF_view.py, Code/test.py files:
import os, sys 
p = os.path.abspath('.') 
sys.path.insert(1, p) 
  1. In comptSimMat.py, change (due to TypeError) -
imgset = Imgset(imgs, masks, labels, imgLoader, bool_square_images=False,bool_cutout=False,bool_pytorch=bool_pytorch) 

To -

imgset = Imgset(imgs, masks, labels, imgLoader, bool_square_images=False) 
  1. mv models/init_vgg/dictionary_vgg/dictionary_pool5_512.pickle models/init_vgg/dictionary_vgg/dictionary_pool5.pickle
@kalpazidis
Copy link

Has anybody found the solution to this?

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