Skip to content

Instantly share code, notes, and snippets.

@Blaizzy
Last active March 27, 2019 16:19
Show Gist options
  • Select an option

  • Save Blaizzy/cae8377dbcd1c786f4b23b3e04ee51da to your computer and use it in GitHub Desktop.

Select an option

Save Blaizzy/cae8377dbcd1c786f4b23b3e04ee51da to your computer and use it in GitHub Desktop.
# First you might want to install & import tf 2.0
!pip install -q tensorflow==2.0.0-alpha0
import tensorflow as tf
# Let's implement a simple Linear layer (mx+b) using tf.function
@tf.function
def add(a,b):
return a + b
@tf.function
def linear_layer(m,x,b):
return add(tf.matmul(m,x), b) # mx + b
linear_layer(tf.ones([2,2]), tf.ones([2,2]), tf.ones([2,2]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment