This file contains hidden or 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
message Person { | |
required string name = 1; | |
required int32 id = 2; | |
optional string email = 3; | |
} |
This file contains hidden or 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 numpy as np | |
import tensorflow as tf | |
# create dummy data | |
X_raw = np.array([2013, 2014, 2015, 2016, 2017], dtype=np.float32) | |
y_raw = np.array([12000, 14000, 15000, 16500, 17500], dtype=np.float32) | |
X_data = (X_raw - X_raw.min()) / (X_raw.max() - X_raw.min()) | |
Y_data = (y_raw - y_raw.min()) / (y_raw.max() - y_raw.min()) | |
X_data = np.expand_dims(X_data, axis=1) | |
Y_data = np.expand_dims(Y_data, axis=1) |
This file contains hidden or 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
tf.saved_model.simple_save(session, | |
export_dir, | |
inputs={"x": x, "y": y}, | |
outputs={"z": z}) |
This file contains hidden or 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 | |
# Let's load a previously saved meta graph in the default graph | |
# This function returns a Saver | |
saver = tf.train.import_meta_graph('results/model.ckpt-1000.meta') | |
# We can now access the default graph where all our metadata has been loaded | |
graph = tf.get_default_graph() | |
# Finally we can retrieve tensors, operations, collections, etc. |
This file contains hidden or 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 | |
v1 = tf.Variable(80., name="v1") | |
v2 = tf.Variable(10., name="v2") | |
a = tf.add(v1, v2) | |
saver0 = tf.train.Saver(var_list=[v1, v2]) | |
saver1 = tf.train.Saver(var_list={'myVar1': v1, 'myVar2': v2}) | |
saver2 = tf.train.Saver(var_list={'myVar1': v1}) | |
saver3 = tf.train.Saver(var_list=tf.trainable_variables()) |
This file contains hidden or 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 | |
v1 = tf.Variable(9., name="v1") | |
v2 = tf.Variable(10., name="v2") | |
a = tf.add(v1, v2) | |
ckpnt = tf.train.Checkpoint() | |
with tf.Session() as sess: | |
sess.run(tf.global_variables_initializer()) | |
ckpnt.save('./test/myVar', sess) |
This file contains hidden or 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
tf.train.Checkpoint(myOptimizer=optimizer, myModel=model, myVar=var1) |
This file contains hidden or 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 | |
v1 = tf.Variable(80., name="v1") | |
v2 = tf.Variable(10., name="v2") | |
a = tf.add(v1, v2) | |
ckpnt = tf.train.Checkpoint(firstVar=v1, secondVar=v2) | |
status = ckpnt.restore(tf.train.latest_checkpoint('./test/')) | |
status.assert_consumed() |
This file contains hidden or 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 | |
v1 = tf.Variable(9., name="v1") | |
v2 = tf.Variable(2., name="v2") | |
a = tf.add(v1, v2) | |
#create checkpoint object... We not save anything yet! | |
ckpnt = tf.train.Checkpoint(firstVar=v1, secondVar=v2) | |
with tf.Session() as sess: |
This file contains hidden or 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 random | |
from collections import deque | |
import gym | |
import numpy as np | |
import tensorflow as tf | |
tf.enable_eager_execution() | |
num_episodes = 3000 |