title: Construct new keras model with logits as output
body: <p>I have <code>Sequential</code> model defined. Here are the <code>input=model.input</code> and <code>output=model.output</code> of the model:</p>
  
  <pre><code>(Pdb) input
  &lt;tf.Tensor 'input_img_1:0' shape=(?, 28, 28, 1) dtype=float32&gt;
  (Pdb) output
  &lt;tf.Tensor 'model_1/activation_7/Softmax:0' shape=(?, 10) dtype=float32&gt;
  </code></pre>
  
  <p>After that I extract the logits as follows: <code>logits, = output.op.inputs</code>, then here is the <code>logits</code>:</p>
  
  <pre><code>(Pdb) logits
  &lt;tf.Tensor 'model_1/dense_3/BiasAdd:0' shape=(?, 10) dtype=float32&gt;
  </code></pre>
  
  <p>Why does this work?</p>
  
  <pre><code>(Pdb) Model(input, output)
  &lt;keras.engine.training.Model object at 0x7f6917272198&gt;
  </code></pre>
  
  <p>But this does not?</p>
  
  <pre><code>(Pdb) Model(input, logits)
  *** TypeError: Output tensors to a Model must be Keras tensors. Found: Tensor("model_1/dense_3/BiasAdd:0", shape=(?, 10), dtype=float32)
  </code></pre>
  
  <p>Given that both <code>logits</code> and <code>output</code> are a <code>tf.Tensor</code>. I also tried to wrap <code>logits</code> around a <code>Lambda</code> layer, like so <code>logits = Lambda((lambda x: x))(logits)</code>.</p>
  
  <p>Now the error of <code>Model(input, logits)</code> is <code>*** AttributeError: 'Tensor' object has no attribute '_keras_history'</code></p>