title: Keras/Tensorflow: ValueError: Shape (?,12) must have rank 1
body: <p>(Keras <code>1.0.7</code>, Tensorflow <code>r0.10</code>)</p>
  
  <p>I am trying to implement my own activation function:</p>
  
  <pre><code># Custom activation function (Radial Basis Function - RBF)
  l2_norm = lambda a, b: K.sqrt(((a - b) ** 2).sum())
  def rbf(x, gamma=1.0):
       return K.exp(-1 * gamma * l2_norm(x[0], x[1]) ** 2)
  </code></pre>
  
  <p>Here is the relevant section of my model where I specify my custom activation function:</p>
  
  <pre><code>model = Sequential()
  # Some other layers go here
  model.add(Dense(n_classes, activation=rbf))
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>/raid/home/user/anaconda2/envs/tensorflow/lib/python2.7/site-packages/tensorflow/python/framework/tensor_shape.pyc in assert_has_rank(self, rank)
  619     """
  620     if self.ndims not in (None, rank):
  --&gt; 621       raise ValueError("Shape %s must have rank %d" % (self, rank))
  622 
  623   def with_rank(self, rank):
  
  ValueError: Shape (?, 12) must have rank 1
  </code></pre>
  
  <p>The error occurs on the line <code>return K.exp(-1 * gamma * l2_norm(x[0], x[1]) ** 2)</code> when trying to slice <code>x</code> (which has shape <code>(?, 12)</code>) into <code>x[0]</code> and <code>x[1]</code>.</p>
  
  <p>Why does the Tensorflow <code>slice</code> method throw this error?</p>