title: How to build this custom layer in Keras?
body: <p>I'm building a NN that supports complex numbers. Currently working on complex activation. According to a Benjio paper, this is a good one:</p>
  
  <p><a href="https://i.stack.imgur.com/kKi6M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kKi6M.png" alt="enter image description here"></a></p>
  
  <p><strong>Where b is a trainable parameter to be learnt</strong>. So I'm building a special layer to do this activation. I'm new to Keras and stuck already. I created this code below, but it gives an error with the build function. I have no idea what's happening, I just tried to copy the template. Please help.</p>
  
  <pre><code>class modrelu(Layer):
      def __init__(self, **kwargs):
          super(modrelu, self).__init__(**kwargs)
  
      def build(self):
          self.b= K.variable(value=np.random.rand()-0.5, dtype='float64')
          super(modrelu, self).build()  # Be sure to call this at the end
  
      def call(self, x):
          assert isinstance(x, list)
          ip_r, ip_i = x
          comp= tf.complex(ip_r, ip_i ) 
          ABS= tf.math.abs(comp)
          ANG= tf.math.angle(comp)
  
          ABS= K.relu( self.b + ABS) 
  
          op_r=  ABS * K.sin(angle) #K.dot ??
          op_i= ABS * K.cos(angle)
          return [op_r, op_i]
  
      def compute_output_shape(self, input_shape):
          assert isinstance(input_shape, list)
          shape_a, shape_b = input_shape
          return [shape_a, shape_b]
  </code></pre>
  
  <p>Comments on my code:
  In the <strong>init</strong> I didn't add anything, cause it is an activation layer that takes no input when instantiated.</p>
  
  <p>In the build method, I tried to add the b's. Not sure if I should use the self.add_weight method. Ideally, I want to have as many b's as the dimension of input.</p>
  
  <p>In the call method, this one, I'm pretty sure what I'm doing. It is easy, I just implemented the function.</p>
  
  <p>The last one, compute_output_shape, I just copied-pasted the template. The output should be the same as the input, cause it is just an activation layer.</p>
  
  <p>Finally, the error for what its worth, I know it is nonsense</p>
  
  <pre><code>TypeError                                 Traceback (most recent call last)
  &lt;ipython-input-5-3101a9226da5&gt; in &lt;module&gt;
        1 a=K.variable(np.array([1,2]))
        2 b=K.variable(np.array([3,4]))
  ----&gt; 3 act([a,b])
  
  ~\AppData\Local\conda\conda\envs\python36\lib\site-packages\keras\engine\base_layer.py in __call__(self, inputs, **kwargs)
      429                                          'You can build it manually via: '
      430                                          '`layer.build(batch_input_shape)`')
  --&gt; 431                 self.build(unpack_singleton(input_shapes))
      432                 self.built = True
      433 
  
  TypeError: build() takes 1 positional argument but 2 were given
  </code></pre>