Guest User

Untitled

a guest
Jul 17th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #Load our libraries
  2. import matplotlib.pyplot as plt
  3. import numpy as np
  4. import tensorflow as tf
  5. sess = tf.Session()
  6.  
  7. # We create our data, placeholders and variables
  8. x_val = np.random.normal(1, 0.1, 100) #input values
  9. y_val = np.repeat(10., 100) #target values
  10.  
  11. # placeholders
  12. x_data = tf.placeholder(shape=[1], dtype=tf.float32)
  13. y_target = tf.placeholder(shape=[1], dtype=tf.float32)
  14.  
  15. #Variables
  16. w = tf.Variable(0.)
  17.  
  18. # Add linear function to the computational graph
  19. y_pred = tf.multiply(x_data, w)
  20.  
  21. # Add a loss function(L2 norm)
  22. loss = tf.square(y_pred - y_target)
  23.  
  24. # initialize our variables
  25. init = tf.global_variables_initializer()
  26. sess.run(init)
Add Comment
Please, Sign In to add comment