title: Confusion Matrix in transfer learning with keras
body: <p>I was going to draw confusion matrix in my model and I used Transfer learning concept based on Deep Learning model.</p>
  <p><strong>Confusion Matrix's code</strong></p>
  <pre><code>def plot_confusion_matrix(cm, classes, normalize=False,title='Confusion Matrix', cmap=plt.cm.Blues):
    plt.imshow(cm, interpolation='nearest', cmap=cmap)
    plt.title(title)
    plt.colorbar()
    tick_marks = np.arange(len(classes))
    plt.xticks(tick_marks, classes, rotation=45)
    plt.yticks(tick_marks, classes)
  
    if normalize:
      cm=cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
      print(&quot;Normalized Confusion Matrix&quot;)
    else:
      print(&quot;Confusion matrix, without normalization&quot;)
    print(cm)
  
    thresh = cm.max() / 2
    for i, j in itertools.product(range(cm.shape[0]),range(cm.shape[1])):
      plt.text(j, i, cm[i, j],
               horizontalalignment=&quot;center&quot;,
               color=&quot;white&quot; if cm[i,j] &gt; thresh else &quot;black&quot;)
    plt.tight_layout()
    plt.ylabel('True Label')
    plt.xlabel('Predicted Label')
  </code></pre>
  <p>Now below the shape of <strong>test_labels</strong> and <strong>Predictions</strong> are given,</p>
  <pre><code>test_labels.shape
  (12,)
  predictions.shape
  (10,2)
  </code></pre>
  <p>The above code is perfectly working but I saw error in below. So please concern below code,</p>
  <pre><code>cm = confusion_matrix(test_labels, predictions.argmax(axis=1))
  </code></pre>
  <p><strong>and here is the error,</strong></p>
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-40-79fd4e2e074c&gt; in &lt;module&gt;()
  ----&gt; 1 cm = confusion_matrix(test_labels, predictions.argmax(axis=1))
  
  2 frames
  /usr/local/lib/python3.6/dist-packages/sklearn/utils/validation.py in check_consistent_length(*arrays)
      210     if len(uniques) &gt; 1:
      211         raise ValueError(&quot;Found input variables with inconsistent numbers of&quot;
  --&gt; 212                          &quot; samples: %r&quot; % [int(l) for l in lengths])
      213 
      214 
  
  ValueError: Found input variables with inconsistent numbers of samples: [12, 10]
    
  </code></pre>
  <p><strong>Note:</strong> This is value error and I am confused about it I try more and more but I failed. So I need help to solve this error.</p>