title: Keras dense layer outputs are 'nan'
body: <p>I'm using Keras to build a RNN model with CTC loss. </p>
  
  <p>I found that when passed a tensor to a Dense layer with <code>activation=None</code>, and the outputs of this layer were all <code>nan</code>. </p>
  
  <p>But when set <code>activation='softmax'</code>, the outputs were <code>normal</code> not <code>nan</code>. </p>
  
  <p>problem code (elements of logits are all <code>nan</code>):</p>
  
  <pre><code>logits = Dense(out_shape, activation = None, name="logits")(x_permute)#x_permute is a tensor with shape (?,1876,96)
  loss_ctc = Lambda(ctc_lambda_func, name='ctc_my')(
      [logits, labels, x_len, lab_len])
  model = Model(inputs=[x, labels, x_len, lab_len], outputs=[loss_ctc])
  model.compile(loss={'ctc_my': lambda y_true,y_pred: y_pred}, optimizer='adadelta')
  </code></pre>
  
  <p>normal code(elements of logits are not <code>nan</code>):</p>
  
  <pre><code>logits = Dense(out_shape, activation = None, name="logits")(x_permute)#x_permute is a tensor with shape (?,1876,96)
  output = Activation(activation="softmax", name="softmax")(logits)
  loss_ctc = Lambda(ctc_lambda_func, name='ctc_my')(
      [output, labels, x_len, lab_len])
  model = Model(inputs=[x, labels, x_len, lab_len], outputs=[loss_ctc])
  model.compile(loss={'ctc_my': lambda y_true,y_pred: y_pred}, optimizer='adadelta')
  
  def ctc_lambda_func(args):
  
      y_pred, y_true, input_length, label_length = args
  
      return ctc_batch_cost(y_true, y_pred,input_length,label_length)
  </code></pre>
  
  <p>Anyone helps? many thanks.</p>