TianzhongSong / C3D-keras

train C3D with keras for action recognition
http://www.tianzsong.xyz/2018/04/08/c3d-keras/
MIT License
119 stars 60 forks source link

why transpose the data #9

Closed b-hakim closed 5 years ago

b-hakim commented 5 years ago

I wonder why is the input transposed:

x = np.transpose(x, (0,2,3,1,4))

in both the val and the training stacks generation

b-hakim commented 5 years ago

Okay, I figured it out. In that piece of code (loading the data) the input has the following shape:

(batch_size, stack_size, height, weight, channels) -- (1)

However, the model is defined with the following channels:

def c3d_model(): input_shape = (112,112,16,3)

which will have at the end the following shape:

(batch_size, height, width, stack_size, channels) -- (2)

So to adjust the dimensions from (1) to (2), that is from the loaded data to the desired model input's format, we need to do that transpose which alternate the dimensions as shown here: https://stackoverflow.com/a/42154026/871418