Created
November 28, 2019 10:29
-
-
Save sergei-mironov/b3f6e18eab51210a39c153417f033179 to your computer and use it in GitHub Desktop.
demo_ll.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @tf.function | |
| def model(x, w0, b0, w1, b1, ...): | |
| x = tf.nn.sigmoid(tf.matmul(x, w0) + b0) | |
| x = tf.nn.sigmoid(tf.matmul(x, w1) + b1) | |
| return x | |
| def train(...): | |
| for (x,y) in train_ds: | |
| with tf.GradientTape() as tape: | |
| loss = compute_loss(model(x, ...), y) | |
| grads = tape.gradient(loss, model.trainable_variables) | |
| optimizer.apply_gradients(zip(grads, model.trainable_variables)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment