Skip to content

Instantly share code, notes, and snippets.

@sol0invictus
Created March 11, 2020 20:52
Show Gist options
  • Save sol0invictus/03203007199cac49fb95ce2f486bf9be to your computer and use it in GitHub Desktop.
Save sol0invictus/03203007199cac49fb95ce2f486bf9be to your computer and use it in GitHub Desktop.
y_hat = tf.constant(36, name='y_hat') # Define y_hat constant. Set to 36.
y = tf.constant(39, name='y') # Define y. Set to 39
loss = tf.Variable((y - y_hat)**2, name='loss') # Create a variable for the loss
init = tf.global_variables_initializer() # When init is run later (session.run(init)),
# the loss variable will be initialized and ready to be computed
with tf.Session() as session: # Create a session and print the output
session.run(init) # Initializes the variables
print(session.run(loss)) # Prints the loss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment