ulvis.paste.net

Paste Search Dynamic
Recent pastes
Create input functions.
  1. # 1. Create input functions.
  2.   training_input_fn = # YOUR CODE HERE
  3.   predict_training_input_fn = # YOUR CODE HERE
  4.   predict_validation_input_fn = # YOUR CODE HERE
  5.  
  6. #I've replaced the above with
  7.   #training_input_fn = lambda: my_input_fn(training_examples, training_targets, batch_size=batch_size, shuffle=True, num_epochs=None)
  8.   #predict_training_input_fn = lambda: my_input_fn(training_examples, training_targets, batch_size=1, shuffle=False, num_epochs=1)
  9.   #predict_validation_input_fn = lambda: my_input_fn(validation_examples, validation_targets, batch_size=1, shuffle=False, num_epochs=1)
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.   # Train the model, but do so inside a loop so that we can periodically assess
  17.   # loss metrics.
  18.   print "Training model..."
  19.   print "RMSE (on training data):"
  20.   training_rmse = []
  21.   validation_rmse = []
  22.   for period in range (0, periods):
  23.     # Train the model, starting from the prior state.
  24.     linear_regressor.train(
  25.         input_fn=training_input_fn,
  26.         steps=steps_per_period,
  27.     )
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.     # 2. Take a break and compute predictions.
  35.     training_predictions = # YOUR CODE HERE
  36.     validation_predictions = # YOUR CODE HERE
  37.  
  38. #I've replaced these with the above with
  39. #    training_predictions = linear_regressor.predict(input_fn=predict_training_input_fn)
  40. #    validation_predictions = linear_regressor.predict(input_fn=predict_validation_input_fn)
  41.  
  42.  
  43.  
  44. #In summary when I run
  45. linear_regressor = train_model(
  46.     # TWEAK THESE VALUES TO SEE HOW MUCH YOU CAN IMPROVE THE RMSE
  47.     learning_rate=0.00001,
  48.     steps=100,
  49.     batch_size=1,
  50.     training_examples=training_examples,
  51.     training_targets=training_targets,
  52.     validation_examples=validation_examples,
  53.     validation_targets=validation_targets)
  54.  
  55. #It gives me an error at line: validation_targets=validation_targets
  56. #I checked if there was an error with the data or variable but validation_targets does return the median_house value data.
  57. #any advice would be much appreciated.
Parsed in 0.014 seconds