def testLinearRegression(self):
    true_w = [[1.0], [(- 0.5)], [2.0]]
    true_b = [1.0]
    model = linear_regression.LinearModel()
    dataset = linear_regression.synthetic_dataset(true_w, true_b, noise_level=0.0, batch_size=64, num_batches=40)
    with tf.device(device()):
        optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.1)
        linear_regression.fit(model, dataset, optimizer, logdir=self._tmp_logdir)
        self.assertAllClose(true_w, model.variables[0].numpy(), rtol=0.01)
        self.assertAllClose(true_b, model.variables[1].numpy(), rtol=0.01)
        self.assertTrue(glob.glob(os.path.join(self._tmp_logdir, 'events.out.*')))
def testLinearRegression(self):
    true_w = [[1.0], [(- 0.5)], [2.0]]
    true_b = [1.0]
    model = linear_regression.LinearModel()
    dataset = linear_regression.synthetic_dataset(true_w, true_b, noise_level=0.0, batch_size=64, num_batches=40)
    with tf.device(device()):
        optimizer = tf.train.GradientDescentOptimizer(learning_rate=0.1)
        linear_regression.fit(model, dataset, optimizer, logdir=self._tmp_logdir)
        self.assertAllClose(true_w, model.variables[0].numpy(), rtol=0.01)
        self.assertAllClose(true_b, model.variables[1].numpy(), rtol=0.01)
        self.assertTrue(glob.glob(os.path.join(self._tmp_logdir, 'events.out.*')))