How do I remove the first element of a tensor in keras as a layer?

Viewed 1493

How do I remove the first element of a tensor in keras as a layer? For example:

layer = Input(input_shape=(100,),name='input')
layer = Conv1D(97,kernel_size=10,strides=10)(layer)
layer = >something that removes the first element<(layer)
layer = Flaten()(layer)
model = Model(input,layer)

This model would have 97*9 outputs. 97 from the Conv layer, and each conv filter would output 10 nodes, but the first of those nodes would be removed by the layer I am looking for. Because the conv layer has shape (batch_size,10,97) I am looking for a way to remove the first element of axis=1.

How would I go about doing this? I tried using the Lambda layer but I can't quite figger out how to make this work.

Edit: I'm asking this question because what I want to do is if I have a layer of shape (batch_size, x, y) I want to transform this to the shape (batch_size, 0.5x, 2y) in such a way that if x is for example 10, the elements 0,2,4,6,8 and 1,3,5,7,9 are stacked on top of each other. Right now I'm doing this with Maxpooling1D(pool_size=1, strides=2) to generate 0,2,4,6,8. To generate 1,3,5,7,9 I'd have to remove 1 element from the start in the manner explained above before applying the maxpooling layer. Thank you so much for your time!

3 Answers
Related