Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save glhfgg1024/4ecffe35ce28e437cb77ccc1f81b8ceb to your computer and use it in GitHub Desktop.
Save glhfgg1024/4ecffe35ce28e437cb77ccc1f81b8ceb to your computer and use it in GitHub Desktop.
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)
for example in tf.python_io.tf_record_iterator('train.tfrecords'):
features = tf.parse_single_example(example, features={'image_raw':tf.FixedLenFeature([], tf.string)})
image = tf.decode_raw(features['image_raw'], tf.uint8)
image = tf.cast(image, tf.float64)
image_sum += tf.reshape(image, [32, 32, 32, 3])
count += 1
if count%1000==0:
print(count)
return count, image_sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment