title: Can't train a keras model to approximate a simple function
body: <p>I just got started with machine learning and I tried to write a simple program where the nn will learn the simple function y = f(x) = 2x.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>#x is a 1D array of 1 to 1000
  x = np.arange(1,1000, 1)
  y = x*2
  
  xtrain = x[:750]
  ytrain = y[:750]
  xtest = x[750:]
  ytest = y[750:]
  
  from keras.models import Sequential
  from keras.layers import Dense, Dropout, Activation, Flatten, Conv2D
  
  model = Sequential()
  
  model.add(Dense(128, input_dim=1, activation='relu'))
  
  model.add(Dense(1, activation='relu'))
  
  model.compile(loss='mean_squared_error', 
            optimizer='sgd', 
            metrics=['accuracy'])
  
  model.summary()
  
  history = model.fit(xtrain, ytrain, 
                  batch_size=100, 
                  epochs=20, 
                  verbose=1, 
                  validation_split=0.2)
  </code></pre>
  
  <p>I get the following output, no matter how I change the architecture or the hyperparameters:</p>
  
  <pre><code>79999/79999 [==============================] - 1s 13us/step - loss: 8533120007.8465 - acc: 0.0000e+00 - val_loss: 32532613324.8000 - val_acc: 0.0000e+00
  </code></pre>
  
  <p>the accuracy is 0 all the time. what am I doing wrong?</p>