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
The following two pieces of code are not the same. The second one is correct. | |
image_node = tf.placeholder(tf.float32, shape=[None, DEPTH, HEIGHT, WIDTH, 2]) | |
image_node = tf.map_fn(lambda frame: frame - tf.reduce_mean(frame, axis=[0,1,2], keep_dims=True), image_node) | |
image_node = tf.placeholder(tf.float32, shape=[None, DEPTH, HEIGHT, WIDTH, 2]) | |
image_node_new = tf.map_fn(lambda frame: frame - tf.reduce_mean(frame, axis=[0,1,2], keep_dims=True), image_node) | |
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 numpy as np | |
import tensorflow as flow | |
from tensorflow.python.saved_model import loader | |
# first, read the pretrained weights into a dictionary | |
variables = {} | |
g1 = tf.Graph() | |
with g1.as_default(): | |
restore_from = 'pretrained_model/1513006564' | |
with tf.Session() as sess: |
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
from inspect import getmembers, isfunction | |
mylib = tf.load_op_library('mylib.so') | |
functions_list = [o for o in getmembers(mylib) if isfunction(o[1])] |
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 vgg16_fc_convolution(in_put, out_channel, layer_name, use_relu=True): | |
with tf.variable_scope(layer_name): | |
input_shape = in_put.get_shape() | |
assert len(input_shape) == 4 | |
height, width, in_channel = input_shape[1:] | |
print(height, width, in_channel) | |
weights = tf.get_variable(name="weights", shape=[height*width*in_channel, out_channel]) | |
biases = tf.get_variable(name="biases", shape=[out_channel]) | |
reshape_weights = tf.reshape(weights, | |
shape=[tf.to_int32(height), tf.to_int32(width), |
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 as np | |
sess = tf.Session() | |
init_op = tf.group(tf.global_variables_initializer(), tf.local_variables_initializer()) | |
sess.run(init_op) | |
def compute_mean_op(): | |
count = 0 | |
image_sum = tf.zeros([32,32,32,3], dtype=tf.float64) |