Skip to content

Instantly share code, notes, and snippets.

@jvmncs
Created October 24, 2019 13:13
Show Gist options
  • Save jvmncs/5e5f0627c580386561d6de45d31c26c2 to your computer and use it in GitHub Desktop.
Save jvmncs/5e5f0627c580386561d6de45d31c26c2 to your computer and use it in GitHub Desktop.
x = tf.expand_dims(id[0], 0)
# Initialize the weight
w_init = tf.initializers.glorot_normal()
w = tf.Variable(w_init(shape=(2, 1), dtype=tf.float32)).send(alice)
z = tf.matmul(x, w)
# Manual differentiation & update
dzdx = tf.transpose(x)
w.assign_sub(dzdx)
print("Updated: ", w.get())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment