CompositionalNets icon indicating copy to clipboard operation
CompositionalNets copied to clipboard

Error when training from scratch

Open toshi2k2 opened this issue 3 years ago • 1 comments

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

toshi2k2 avatar Oct 04 '21 22:10 toshi2k2

Has anybody found the solution to this?

kalpazidis avatar Nov 17 '23 11:11 kalpazidis