title: How to add a trainable hadamard product layer in keras?
body: <p>I am trying to introduce sparsity in the training samples. My data matrix has a size of (say) NxP and I want to pass it through a layer (keras layer) which has weights of size same as the input size. That is trainable weight matrix W has a shape of NxP. I want to do an hadamard product (element-wise multiplication) of Input matrix to this layer. W multiplied element-wise with input. How to get a trainable layer for W in this case ?</p>
  
  <p>EDIT:
  By the way, thank you so much for the quick reply. However, the hadamard product I want to do is between two matrices, one is the input, lets call it X and my X is shape of NxP. And I want my kernel in the hadamard layer to be the same size as X. So kernel should have a size of NxP too. And element wise multiplication of two matrices is achived by the call function.</p>
  
  <p>But the current implementation gives the kernel size as P only. Also,I tried changing the shape of the kernel in the build as follows:</p>
  
  <pre><code>self.kernel = self.add_weight(name='kernel',
                                        shape=input_shape,
                                        initializer='uniform',
                                        trainable=True)
  </code></pre>
  
  <p>But it gives me the error below:</p>
  
  <p>TypeError: Failed to convert object of type to Tensor. Contents: (None, 16). Consider casting elements to a supported type.</p>
  
  <p>Here P is 16 and I will get my N during the runtime and N is similar to the number of training samples.</p>
  
  <p>Thank you in advance for the help.</p>