Skip to content

Instantly share code, notes, and snippets.

@murayama333
Created June 7, 2017 08:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save murayama333/4d15390d27151a95fa7da87a3b25510b to your computer and use it in GitHub Desktop.
Save murayama333/4d15390d27151a95fa7da87a3b25510b to your computer and use it in GitHub Desktop.
import tensorflow as tf
import numpy as np
features = [tf.contrib.layers.real_valued_column("x", dimension=1)]
estimator = tf.contrib.learn.LinearRegressor(feature_columns=features)
x = np.array([1., 2., 3., 4.])
y = np.array([0., -1., -2., -3.])
input_fn = tf.contrib.learn.io.numpy_input_fn({"x": x}, y, batch_size=4, num_epochs=1000)
estimator.fit(input_fn=input_fn, steps=1000)
print(estimator.evaluate(input_fn=input_fn))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment