axon-research / c3d-keras

C3D for Keras + TensorFlow
Other
176 stars 77 forks source link

Mismatch to Caffe implementation #15

Closed gyglim closed 7 years ago

gyglim commented 7 years ago

First, thanks a lot for providing this tensorflow implementation. I successfully run it and got the same probabilities as given in the script. However I compared on the snippet used in https://github.com/Lasagne/Recipes/blob/master/examples/Video%20features%20with%20C3D.ipynb

and get quite different probabilities compared to the caffe reference implementation. This code:

         wiffle ball: 30.72%
      knife throwing: 22.49%
           boomerang: 5.09%
             croquet: 4.96%
           disc golf: 3.22%
            wallball: 3.10%
            rounders: 2.98%
             archery: 1.96%
      skeet shooting: 1.91%
               bocce: 1.87%

Caffe:

     wiffle ball: 29.91%
  knife throwing: 13.11%
         croquet: 11.27%
       disc golf: 5.29%
        kickball: 5.18%
        rounders: 4.48%
           bocce: 3.53%
       dodgeball: 2.27%
       boomerang: 1.71%
        tee ball: 1.39%

did you ever verify the output against the caffe implementation? Any idea what the reason for this might be?

gyglim commented 7 years ago

I made some progress regarding this. The padding here is incorrect: https://github.com/axon-research/c3d-keras/blob/master/c3d_model.py#L49

The original has no padding: https://github.com/facebook/C3D/blob/master/C3D-v1.0/src/caffe/layers/pool3d_layer.cpp#L46 or, rather it has right only padding, through this: https://github.com/facebook/C3D/blob/master/C3D-v1.0/src/caffe/layers/pool3d_layer.cpp#L92

by changing above line to model.add(ZeroPadding3D(padding=((0, 0), (0, 1), (0, 1)), name='zeropad5')) I now get probablities that are closer to the reference implementation:

         wiffle ball: 28.18%
      knife throwing: 13.11%
             croquet: 10.82%
           disc golf: 7.88%
            rounders: 4.97%
            kickball: 4.46%
               bocce: 3.11%
           boomerang: 2.02%
           dodgeball: 1.78%
      pitch and putt: 1.40%

Also, I used the mean from here, which helped getting more accurate results: https://github.com/Lasagne/Recipes/blob/master/examples/Video%20features%20with%20C3D.ipynb

chuckcho commented 7 years ago

@gyglim thanks for your effort. i was puzzled myself. right-padding instead of symmetric padding did make it close to reference results.

chuckcho commented 7 years ago

@gyglim : made this change. thanks for your contribution!