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
cd /Users/yaroslavvb/tfimmediate_hood.cpu_three | |
git clone https://github.com/yaroslavvb/tensorflow.git | |
export clonedir=/Users/yaroslavvb/tfimmediate_hood.cpu_three/tensorflow | |
export dev_branch=hood-devel | |
export pr_branch=hood | |
git fetch --all | |
git checkout $dev_branch | |
git pull |
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 | |
from tensorflow.core.framework import op_def_pb2 | |
from google.protobuf import text_format | |
def get_op_types(op): | |
for attr in op.attr: | |
if attr.type != 'type': | |
continue | |
return list(attr.allowed_values.list.type) | |
return [] |
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
a = tf.constant([[1,2],[3,4]]) | |
row_to_add = tf.constant([[1, 1]]) | |
updated_row = a[0]+row_to_add | |
updated_a = tf.concat(0, [updated_row, a[1:]]) | |
sess.run(updated_a) |
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 | |
fn = "/tmp/efs/yaroslav/g/train_1/events.out.tfevents.1476852642.g-w-1-vblgv" | |
for summary in tf.train.summary_iterator(): | |
print(summary) |
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 | |
from numpy.testing.utils import nulp_diff | |
import time | |
n = 1024 | |
v1 = tf.Variable(tf.ones_initializer((n, n))) | |
v2 = tf.Variable(tf.ones_initializer((n, n))) | |
op = v1.assign(tf.matmul(v1, v2)/n).op | |
norm = tf.reduce_sum(v1) |
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
def sessrun(fetches): | |
values = tf.get_default_session().run(fetches) | |
return {fetches[i]: values[i] for i in range(len(values))} | |
a = tf.constant(1) | |
b = tf.constant(2) | |
c = tf.constant(3) | |
sess = tf.InteractiveSession() | |
result1 = sessrun([a, b]) |
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 | |
a = tf.ones((10, 10)) | |
b = tf.ones((10, 10)) | |
c = tf.matmul(a, b) | |
ss = tf.contrib.stat_summarizer.NewStatSummarizer(tf.get_default_graph().as_graph_def().SerializeToString()) | |
sess = tf.Session() | |
for i in range(10): | |
run_metadata = tf.RunMetadata() | |
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE) |
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
# GPU picking | |
# http://stackoverflow.com/a/41638727/419116 | |
# Nvidia-smi GPU memory parsing. | |
# must set | |
# CUDA_DEVICE_ORDER=PCI_BUS_ID | |
# see https://github.com/tensorflow/tensorflow/issues/152#issuecomment-273663277 | |
# Tested on nvidia-smi 370.23 | |
def run_command(cmd): |
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
def copy_initializer(from_var, to_var): | |
from tensorflow.contrib import graph_editor as ge | |
assert ge.reroute_a2b_ts(from_var.initial_value, to_var.initial_value), "No copy took place" |
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
# Try to copy "a" value to "c" while simultaneously adding vector of 1's to a. | |
# If the copy is started before the first assign_add, the copied value will be inconsistent. | |
# | |
# Running it on macbook my "c" ends up with a mix of values between 1 and 6 | |
# | |
# | |
# 16.017478 copy 1 (0) starting | |
# 17.006894 write 1 (0) starting | |
# 28.431654 write 1 ending (11.4247 sec) | |
# 29.436692 write 1 (1) starting |
OlderNewer