No gradients provided for any variable: ['Variable:0', 'Variable:0']
tw = tf.Variable(initial_value=np.random.randn(), dtype=tf.float32, trainable=True)
tb = tf.Variable(initial_value=0, dtype=tf.float32, trainable=True)

cost =  lambda :tf.reduce_mean(tf.square(tx*tw+tb-ty))
optimizer = tf.keras.optimizers.SGD(0.01)
train = optimizer.minimize(cost, var_list = [tw,tb])

Reference to tw and tb directly in cost function rather than through yhat. It will work.