title: tensorflow: Changing n_classes to 2 yields "ValueError: Shapes (?, 1) and (?,) are incompatible; "
body: <p>I'm using my own data in the tutorial from <a href="https://www.tensorflow.org/versions/r0.11/tutorials/tflearn/index.html#tf-contrib-learn-quickstart" rel="nofollow">https://www.tensorflow.org/versions/r0.11/tutorials/tflearn/index.html#tf-contrib-learn-quickstart</a>.  They use the Iris dataset; I've got my own data that is sort of made up but it should still work.  I'm getting an incompatible shapes error.</p>
  
  <p>The error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "./kidTraining_stripped.py", line 36, in &lt;module&gt;
  classifier.fit(x = training_set.data, y = training_set.target, steps = 2000)  ########## THROWS UP HERE.
    File "/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py", line 435, in fit
  max_steps=max_steps)
    File "/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 333, in fit
  max_steps=max_steps)
    File "/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 662, in _train_model
  train_op, loss_op = self._get_train_ops(features, targets)
    File "/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 963, in _get_train_ops
  _, loss, train_op = self._call_model_fn(features, targets, ModeKeys.TRAIN)
    File "/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 944, in _call_model_fn
  return self._model_fn(features, targets, mode=mode, params=self.params)
    File "/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py", line 258, in _dnn_classifier_model_fn
  weight=_get_weight_tensor(features, weight_column_name))
    File "/usr/local/lib/python3.4/dist-packages/tensorflow/contrib/losses/python/losses/loss_ops.py", line 329, in sigmoid_cross_entropy
  logits.get_shape().assert_is_compatible_with(multi_class_labels.get_shape())
    File "/usr/local/lib/python3.4/dist-packages/tensorflow/python/framework/tensor_shape.py", line 750, in assert_is_compatible_with
  raise ValueError("Shapes %s and %s are incompatible" % (self, other))
  ValueError: Shapes (?, 1) and (?,) are incompatible
  </code></pre>
  
  <p>My program is strikingly similar; I just changed the variable names to be accurate:</p>
  
  <pre><code>from __future__ import absolute_import
  from __future__ import division
  from __future__ import print_function
  
  import tensorflow as tf
  import numpy as np
  
  # Data sets
  KID_TRAINING = "kid_data_training_nn.csv"
  KID_TEST = "kid_data_test_nn.csv"
  
  # load datasets
  training_set = tf.contrib.learn.datasets.base.load_csv_with_header(filename = KID_TRAINING, target_dtype = np.int, features_dtype=np.float32)
  
  test_set = tf.contrib.learn.datasets.base.load_csv_with_header(filename=KID_TEST, target_dtype = np.int, features_dtype=np.float32)
  
  # specify that all features have real-value data
  feature_columns = [tf.contrib.layers.real_valued_column("", dimension=11)]
  
  # build 3 layer DNN with 10, 20, 10 units respectively
  classifier = tf.contrib.learn.DNNClassifier(feature_columns=feature_columns, hidden_units=[10, 20, 10], n_classes=2, model_dir="./kid_model")
  
  # Fit model
  print("It blows up here, so this is x and y:")
  print(training_set.data)
  print(training_set.data.dtype)
  print(training_set.data.shape)
  
  # (18, 11)
  
  print(training_set.target)
  print(training_set.target.dtype)
  print(training_set.target.shape)
  # (18,)
  
  classifier.fit(x = training_set.data, y = training_set.target, steps = 2000)  ########## THROWS UP HERE.
  </code></pre>
  
  <p>The data doesn't look funny to me; I've stripped it down to 4 columns, made the floats only 2 decimal points long, etc., tried reshaping the tensor, and nothing seems to work.  When I print out the shapes before it gets to classifier.fit, they seem compatible, (18, 11) and (18,).  But when I run the fit function, the error says the shapes are ?.   When I paste the data it becomes incomprehensible, but for an example here are the first 3 lines of the training data:</p>
  
  <p>18  11  NT  ASD</p>
  
  <p>0   132 1   15.28333    2.66667 3.48333 2.26667 3.33333 1.2 0.98333 1.35    0</p>
  
  <p>0   138 1   9.95    1.25    2.73333 0.83333 1.95    0.83333 1   1.35    0</p>
  
  <p>There are 18 rows of data, only 2 classes, and 11 columns (not including the label at the end).  The test data is similar, only I only have 6 samples, so the first column in the first row contains a 6.</p>
  
  <p>What's wrong?  Do I need differently shaped data?  Do I need to reshape it?  Is there an entry in the program that is incorrect based on my input data?  Hope someone can help.</p>
  
  <p>=======
  Edit: I know it has to do with n_classes; it seems to take any value greater than 2, except that I only have 2 classes so I would like my model to actually use the correct parameters.  </p>