How to do regression using tensorflow with series output?
<p>I want to build a regression model with 2 output nodes using tensorflow. I search a code which can build regression model but with 1 output nodes.</p>

<p><a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/skflow/boston.py" rel="nofollow">https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/skflow/boston.py</a></p>

<pre><code>from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from sklearn import cross_validation
from sklearn import metrics
from sklearn import preprocessing
import tensorflow as tf
from tensorflow.contrib import learn


def main(unused_argv):
  # Load dataset
  boston = learn.datasets.load_dataset('boston')
  x, y = boston.data, boston.target

  # Split dataset into train / test
  x_train, x_test, y_train, y_test = cross_validation.train_test_split(
      x, y, test_size=0.2, random_state=42)

  # Scale data (training set) to 0 mean and unit standard deviation.
  scaler = preprocessing.StandardScaler()
  x_train = scaler.fit_transform(x_train)

  # Build 2 layer fully connected DNN with 10, 10 units respectively.
  feature_columns = learn.infer_real_valued_columns_from_input(x_train)
  regressor = learn.DNNRegressor(
      feature_columns=feature_columns, hidden_units=[10, 10])

  # Fit
  regressor.fit(x_train, y_train, steps=5000, batch_size=1)

  # Predict and score
  y_predicted = list(
      regressor.predict(scaler.transform(x_test), as_iterable=True))
  score = metrics.mean_squared_error(y_predicted, y_test)

  print('MSE: {0:f}'.format(score))


if __name__ == '__main__':
  tf.app.run()
</code></pre>

<p>I am new to tensorflow, so I searched for the code which has similarity to how mine works, but the output of the code is one.</p>

<p>In my model, the input is N*1000, and the output is N*2. I wonder are there effective and efficient code for regression. Please give me some example.</p>

<p>Actually, I find a workable code using DNNRegressor:</p>

<pre><code>import numpy as np
from sklearn.cross_validation import train_test_split
from tensorflow.contrib import learn
import tensorflow as tf
import logging
#logging.getLogger().setLevel(logging.INFO)

#Some fake data

N=200
X=np.array(range(N),dtype=np.float32)/(N/10)
X=X[:,np.newaxis]

#Y=np.sin(X.squeeze())+np.random.normal(0, 0.5, N)
Y = np.zeros([N,2])
Y[:,0] = X.squeeze()
Y[:,1] = X.squeeze()**2

X_train, X_test, Y_train, Y_test = train_test_split(X, Y,
                                                    train_size=0.8,
                                                    test_size=0.2)


reg=learn.DNNRegressor(hidden_units=[10,10])
reg.fit(X_train,Y_train[:,0],steps=500)
</code></pre>

<p>But, this code will work only if the shape of Y_train is N*1, and it will fail when the shape of Y_train is N*2.</p>

<p>However, I want to build a regress model and the input is N*1000, the output is N*2. And I can't fix it.</p>

python output tensorflow regression