title: tensorflowjs how to get inner layer output in a cnn prediction
body: <p>I am looking at tensorflow.js CNN example from <a href="https://js.tensorflow.org/tutorials/mnist.html" rel="nofollow noreferrer">tfjs</a>.</p>
  
  <p>The testing repo can be found here: <a href="https://github.com/tensorflow/tfjs-examples/tree/master/mnist" rel="nofollow noreferrer">testing repo</a>.</p>
  
  <p>Is there any way I can get outputs from each layer? </p>
  
  <pre><code> async showPredictions() {
      const testExamples = 1;
      // const testExamples = 100;
      const batch = this.data.nextTestBatch(testExamples);
  
      tf.tidy(() =&gt; {
          const output: any = this.model.predict(batch.xs.reshape([-1, 28, 28, 1]));
  
          output.print();
          const axis = 1;
          const labels = Array.from(batch.labels.argMax(axis).dataSync());
          const predictions = Array.from(output.argMax(axis).dataSync());
  
          // ui.showTestResults(batch, predictions, labels);
      });
  }
  </code></pre>
  
  <p>Above is the prediction method from the tfjs example, but only the last layer is printed. How can I get outputs from each layer (including conv, max pooling and fully connect layers) in a prediction?</p>