title: How to connect two models
body: <p>I have model A (autoencoder) which takes as input a batch of images A_in (original images), and outputs a batch of images A_out (reconstructed images). Then I have model B (binary classifier) which takes as input a batch of images B_in, which is a mixture of A_in and A_out. </p>
  
  <p>I want B to distinguish between A_in and A_out, to see if A is doing a good job reconstructing images. B_out is a probability that a given image is A_in. </p>
  
  <p>B trains in parallel with A to classify the two kinds of images. B_loss = (B_out - label). Labels are 0 or 1 (original or reconstructed). When we optimize B_loss we only update B parameters.</p>
  
  <p>I want to train model A so that it optimizes a combined loss function: Combined_Loss = reconstruction error (A_out - A_in) - classification error (B_out - label), so that it tries to reconstruct the images and fool B at the same time. Here I want to only update A parameters (we don't want to help B here). </p>
  
  <p>Now, my question is about constructing that mixture of A_in and A_out, and feeding it to B so that the graphs A and B are connected.</p>
  
  <p>Right now it's like this:</p>
  
  <pre><code>A_out = autoencoder(A_in: orig_images)
  B_out = classifier(B_in: numpy(mix(A_in, A_out))
  </code></pre>
  
  <p>How do I define it like this:</p>
  
  <pre><code>A_out = autoencoder(A_in: orig_images)
  B_out = classifier(mix(A_out, A_in))
  </code></pre>
  
  <p>So that when I train A and B at the same time:</p>
  
  <pre><code>sess.run([autoencoder_train_op, classifier_train_op], feed_dict=
              {A_in: orig_images, B_in: classifier_images, labels: classifier_labels})
  </code></pre>
  
  <p>I wouldn't need B_in placeholder (the graphs would be connected)?</p>
  
  <p>Here's my Numpy code that constructs classifier_images (mix(A_in, A_out)):</p>
  
  <pre><code>reconstr_images = sess.run(A_out, feed_dict={A_in: orig_images})
  
  half_and_half_images = np.concatenate((reconstr_images[:batch_size/2], orig_images[batch_size/2:]))
  
  half_and_half_labels = np.zeros(labels.shape)
  half_and_half_labels[batch_size/2:] = 1
  
  random_indices = np.random.permutation(batch_size)
  
  classifier_images = half_and_half_images[random_indices]
  classifier_labels = half_and_half_labels[random_indices]
  </code></pre>
  
  <p>How do I convert it into TensorFlow node? </p>