0

How can I code my own MaxPooling_1D layer in google Trax? I understand that current max pooling is based on 2D max pooling.

Here's how I tried using Keras 1d layer

   import trax.layers as tl
   def computePool(max_pool_1d,in_tensor):
      #print(in_tensor)
      return max_pool_1d(in_tensor)
   def maxPooling1D():
      max_pool_1d = tf.keras.layers.GlobalMaxPooling1D()
      return tl.Fn('maxPooling1D', lambda x: computePool(max_pool_1d, x))

But this wouldn't go through in the model. I want to create a layer with pool size = 2

1 Answers1

0

The answer is

tl.MaxPool(pool_size=(2,), strides=(1,), padding='SAME'),
desertnaut
  • 57,590
  • 26
  • 140
  • 166
  • Remember that Stack Overflow isn't just intended to solve the immediate problem, but also to help future readers find solutions to similar problems, which requires understanding the underlying code. This is especially important for members of our community who are beginners, and not familiar with the syntax. Given that, **can you [edit] your answer to include an explanation of what you're doing** and why you believe it is the best approach? – Jeremy Caney Jul 26 '22 at 08:56