Skip to content

Instantly share code, notes, and snippets.

View irdanish11's full-sized avatar
🎯
Focusing

Irfan Danish irdanish11

🎯
Focusing
View GitHub Profile
@irdanish11
irdanish11 / Gradient_tape.py
Last active June 21, 2020 09:55
Gradient Tape
inputs = Input(shape=(7))
fc = Dense(units=72)(inputs)
fc = Dense(units=1, activation='sigmoid')(fc)
model = Model(inputs, fc)
#generating data
X = np.random.rand(1024, 7)
#generating labels
y = np.conacatenate(np.zeros((512)), np.ones((512)))
optimizer = Adam()
g = tf.Graph()
with g.as_default():
a = tf.constant([[10,10],[11.,1.]])
x = tf.constant([[1.,0.],[0.,1.]])
b = tf.Variable(12.)
y = tf.matmul(a, x) + b
init_op = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init_op)
a = tf.constant([[10,10],[11.,1.]])
x = tf.constant([[1.,0.],[0.,1.]])
b = tf.Variable(12.)
y = tf.matmul(a, x) + b
print(y.numpy())
def f():
a = tf.constant([[10,10],[11.,1.]])
x = tf.constant([[1.,0.],[0.,1.]])
b = tf.Variable(12.)
y = tf.matmul(a, x) + b
return y
@tf.function
def f():
a = tf.constant([[10,10],[11.,1.]])
x = tf.constant([[1.,0.],[0.,1.]])
b = tf.Variable(12.)
y = tf.matmul(a, x) + b
print("PRINT: ", y)
tf.print("TF-PRINT: ", y)
return y
b = None
@tf.function
def f():
a = tf.constant([[10, 10], [11., 1.]])
x = tf.constant([[1., 0.], [0., 1.]])
global b
if b is None:
b = tf.Variable(12.)
y = tf.matmul(a, x) + b
class F():
def __init__(self):
self._b = None
@tf.function
def __call__(self):
a = tf.constant([[10, 10], [11., 1.]])
x = tf.constant([[1., 0.], [0., 1.]])
if self._b is None:
self._b = tf.Variable(12.)
@tf.function
def f(b):
a = tf.constant([[10,10],[11.,1.]])
x = tf.constant([[1.,0.],[0.,1.]])
y = tf.matmul(a, x) + b
print("PRINT: ", y)
tf.print("TF-PRINT: ", y)
return y
b = tf.Variable(12.)
a = tf.Variable(0)
@tf.function
def g(x):
x.assign_add(1)
return x
print(g(a))
print(g(a))
print(g(a))
@irdanish11
irdanish11 / Installing miniconda on raspberry pi4-b.md
Last active October 8, 2024 00:19
Installing miniconda on raspberry pi4-b