I'd like to implement the Spatiotemporal Fully Convolutional Network (STFCN) in Keras. I need to feed each depth column of a 3D convolutional output, e.g. a tensor with shape (64, 16, 16)
, as input to a separate LSTM.
To make this clear, I have a (64 x 16 x 16)
tensor of dimensions (channels, height, width)
. I need to split (explicitly or implicitly) the tensor into 16 * 16 = 256 tensors of shape (64 x 1 x 1)
.
Here is a diagram from the STFCN paper to illustrate the Spatio-Temporal module. What I described above is the arrow between 'Spatial Features' and 'Spatio-Temporal Module'.
How would this idea be best implemented in Keras?
You can use
tf.split
from Tensorflow using KerasLambda
layerUse Lambda to split a tensor of shape
(64,16,16)
into(64,1,1,256)
and then subset any indexes you need.