title: weights of keras model are nan
body: <p>I'm using below model for regression purpose; with input of size 2 and output of size 28. </p>
  
  <pre><code>from keras.models import Sequential
  from keras.layers import Dense
  from keras.optimizers import SGD
  
  model = Sequential()
  model.add(Dense(16, input_dim=2, activation='relu'))
  model.add(Dense(16, activation='relu'))
  model.add(Dense(28, activation='linear'))
  sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)
  model.compile(loss='mean_squared_error',optimizer=sgd)
  </code></pre>
  
  <p>In training all going well, but when I save and reload the model; I'm getting weights as a nan. </p>
  
  <pre><code>from keras.models import model_from_json
  
  model_json = model.to_json()
  with open('/models/model_ar.json', "w") as json_file:
       json_file.write(model_json)
  model.save_weights('/models/model_wt.h5')
  
  json_file = open('/models/model_ar.json', 'r')
  loaded_model_json = json_file.read()
  json_file.close()
  new_model = model_from_json(loaded_model_json)
  # load weights into new model
  new_model.load_weights('/models/model_wt.h5')
  </code></pre>
  
  <p>getting weights as 'nan'. What is reason to get the all weights as nan</p>
  
  <pre><code>    new_model.get_weights()
  [array([[nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan, nan],
          [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan, nan]], dtype=float32),
   array([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
          nan, nan, nan], dtype=float32),
   array([[nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan, nan],
          [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan, nan],
          [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan, nan],
          [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan, nan],
          [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan, nan],
          [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan, nan]], dtype=float32),
   array([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
          nan, nan, nan], dtype=float32),
   array([[nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan],
          [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan],
          [nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
           nan, nan]], dtype=float32),
   array([nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
          nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan,
          nan, nan], dtype=float32)]
  </code></pre>