Example #1
0
 def __init__(self, input_shape, graph):
     with graph.as_default():
         self.global_step = tf.Variable(0, name="global_step", trainable=False)
         self.inp = tf.placeholder(tf.float32, [None, input_shape], name="input")
         self.out = tf.placeholder(tf.float32, [None], name="output")
         self.weights = tf.get_variable("weights", [input_shape, 1])
         self.bias = tf.get_variable("bias", [1])
         self.predictions, self.loss = mean_squared_error_regressor(
             self.inp, self.out, self.weights, self.bias)
Example #2
0
def linear_regression(X, y):
    """Creates linear regression TensorFlow subgraph.
    
    Args:
        X: tensor or placeholder for input features.
        y: tensor or placeholder for target.

    Returns:
        Predictions and loss tensors.
    """
    with tf.variable_scope('linear_regression'):
        weights = tf.get_variable('weights', [X.get_shape()[1], 1])
        bias = tf.get_variable('bias', [1])
        return mean_squared_error_regressor(X, y, weights, bias)
Example #3
0
def linear_regression(X, y):
    """Creates linear regression TensorFlow subgraph.

    Args:
        X: tensor or placeholder for input features.
        y: tensor or placeholder for target.

    Returns:
        Predictions and loss tensors.
    """
    with tf.variable_scope('linear_regression'):
        weights = tf.get_variable('weights', [X.get_shape()[1], 1])
        bias = tf.get_variable('bias', [1])
        return mean_squared_error_regressor(X, y, weights, bias)
Example #4
0
def linear_regression(X, y):
    """Creates linear regression TensorFlow subgraph.

    Args:
        X: tensor or placeholder for input features.
        y: tensor or placeholder for target.

    Returns:
        Predictions and loss tensors.
    """
    with tf.variable_scope('linear_regression'):
        tf.histogram_summary('linear_regression.X', X)
        tf.histogram_summary('linear_regression.y', y)
        y_shape = y.get_shape()
        if len(y_shape) == 1:
            output_shape = 1
        else:
            output_shape = y_shape[1]
        weights = tf.get_variable('weights', [X.get_shape()[1], output_shape])
        bias = tf.get_variable('bias', [output_shape])
        tf.histogram_summary('linear_regression.weights', weights)
        tf.histogram_summary('linear_regression.bias', bias)
        return mean_squared_error_regressor(X, y, weights, bias)
Example #5
0
def linear_regression(X, y):
    """Creates linear regression TensorFlow subgraph.

    Args:
        X: tensor or placeholder for input features.
        y: tensor or placeholder for target.

    Returns:
        Predictions and loss tensors.
    """
    with tf.variable_scope('linear_regression'):
        tf.histogram_summary('linear_regression.X', X)
        tf.histogram_summary('linear_regression.y', y)
        y_shape = y.get_shape()
        if len(y_shape) == 1:
            output_shape = 1
        else:
            output_shape = y_shape[1]
        weights = tf.get_variable('weights', [X.get_shape()[1], output_shape])
        bias = tf.get_variable('bias', [output_shape])
        tf.histogram_summary('linear_regression.weights', weights)
        tf.histogram_summary('linear_regression.bias', bias)
        return mean_squared_error_regressor(X, y, weights, bias)