Created
November 16, 2019 00:23
-
-
Save randcode-generator/a9d13e90ee2db0feb59088b014bdc73e to your computer and use it in GitHub Desktop.
This file contains 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
import tensorflow as tf | |
import numpy | |
# Parameters | |
learning_rate = 0.01 | |
training_epochs = 3500 | |
datapoints_count = 100 | |
# Training Data | |
train_X = [] | |
train_Y = [] | |
for i in range(datapoints_count): | |
train_X.append(i) | |
train_Y.append(5*i+8.0) | |
train_X = numpy.asarray(train_X) | |
train_Y = numpy.asarray(train_Y) | |
n_samples = train_X.shape[0] | |
imported_graph = tf.train.import_meta_graph('saved_variable.meta') | |
with tf.Session(graph=tf.get_default_graph()) as sess: | |
sess.run(tf.global_variables_initializer()) | |
imported_graph.restore(sess, './saved_variable') | |
print("value of W: ", sess.run("weight:0")) | |
print("value of b: ", sess.run("bias:0")) | |
for epoch in range(500, training_epochs): | |
for (x, y) in zip(train_X, train_Y): | |
sess.run('GradientDescent', feed_dict={"X:0": x, "Y:0": y}) | |
if (epoch+1) % 50 == 0: | |
training_cost = sess.run("cost:0", feed_dict={"X:0": train_X, "Y:0": train_Y}) | |
print("Epoch: %04d cost=%.9f W=%f b=%f" % \ | |
((epoch+1), training_cost, sess.run("weight:0"), sess.run("bias:0"))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment