Skip to content

Instantly share code, notes, and snippets.

@cedricconol
Created May 23, 2020 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cedricconol/098f8f51fd00ade42de09f26761f8e0b to your computer and use it in GitHub Desktop.
Save cedricconol/098f8f51fd00ade42de09f26761f8e0b to your computer and use it in GitHub Desktop.
Linear regression TF2 init
class SimpleLinearRegression:
def __init__(self, initializer='random'):
if initializer=='ones':
self.var = 1.
elif initializer=='zeros':
self.var = 0.
elif initializer=='random':
self.var = tf.random.uniform(shape=[], minval=0., maxval=1.)
self.m = tf.Variable(1., shape=tf.TensorShape(None))
self.b = tf.Variable(self.var)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment