Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Load our libraries
- import matplotlib.pyplot as plt
- import numpy as np
- import tensorflow as tf
- sess = tf.Session()
- # We create our data, placeholders and variables
- x_val = np.random.normal(1, 0.1, 100) #input values
- y_val = np.repeat(10., 100) #target values
- # placeholders
- x_data = tf.placeholder(shape=[1], dtype=tf.float32)
- y_target = tf.placeholder(shape=[1], dtype=tf.float32)
- #Variables
- w = tf.Variable(0.)
- # Add linear function to the computational graph
- y_pred = tf.multiply(x_data, w)
- # Add a loss function(L2 norm)
- loss = tf.square(y_pred - y_target)
- # initialize our variables
- init = tf.global_variables_initializer()
- sess.run(init)
Add Comment
Please, Sign In to add comment