cipriancorneanu / dnn-topology

Computing topological cavities of deep neural networks
66 stars 12 forks source link

AttributeError because DataParallel does not forward call to 'forward_features(..)' #3

Open nickstheisen opened 4 years ago

nickstheisen commented 4 years ago

Dear Ciprian, first of all, thanks for this great project!

I think i found a bug when following the 'Quick Start'-section in the README.md. When running

python main.py --net lenet --dataset mnist --trial 0 --lr 0.0005  --n_epochs_train 50 --epochs_test '1 5 10 20 30 40 50' --graph_type functional --train 1 --build_graph 1

i receive this AttributeError

AttributeError: 'DataParallel' object has no attribute 'forward_features'

originating from the following line https://github.com/cipriancorneanu/dnn-topology/blob/9c50a0883c6bfd92675a67828926196a6f95ffcc/passers.py#L93

I resolved it by replacing self.network.forward_features(inputs) with self.network.module.forward_features(inputs).

The problem seems to be that DataParallel does only forward specific function to the encapsulated model. This might also be a problem in other parts of the project (e.g. passers.py line 95).

keivanB commented 3 years ago

got the same error when training on GPU.