aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/examples/image_retraining
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <bsteiner@google.com>2016-08-12 15:02:49 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2016-08-12 16:16:31 -0700
commita92da9e09fb476a9b267499e326919a89b826fb7 (patch)
tree37c257b0d2d5e82b6f8caa8ad97e4f4de2b39a75 /tensorflow/examples/image_retraining
parent9ace75c7c88f30a488ce022be03b8f6dc1c9c990 (diff)
Merge changes from github.
Change: 130150683
Diffstat (limited to 'tensorflow/examples/image_retraining')
-rw-r--r--tensorflow/examples/image_retraining/retrain.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tensorflow/examples/image_retraining/retrain.py b/tensorflow/examples/image_retraining/retrain.py
index 6a3024d5bc..be2d7e715a 100644
--- a/tensorflow/examples/image_retraining/retrain.py
+++ b/tensorflow/examples/image_retraining/retrain.py
@@ -82,6 +82,8 @@ from tensorflow.python.framework import tensor_shape
from tensorflow.python.platform import gfile
+import struct
+
FLAGS = tf.app.flags.FLAGS
# Input and output file flags.
@@ -371,6 +373,38 @@ def ensure_dir_exists(dir_name):
os.makedirs(dir_name)
+def write_list_of_floats_to_file(list_of_floats , file_path):
+ """Writes a given list of floats to a binary file.
+
+ Args:
+ list_of_floats: List of floats we want to write to a file.
+ file_path: Path to a file where list of floats will be stored.
+
+ """
+
+ s = struct.pack('d' * BOTTLENECK_TENSOR_SIZE, *list_of_floats)
+ with open(file_path, 'wb') as f:
+ f.write(s)
+
+
+def read_list_of_floats_from_file(file_path):
+ """Reads list of floats from a given file.
+
+ Args:
+ file_path: Path to a file where list of floats was stored.
+ Returns:
+ Array of bottleneck values (list of floats).
+
+ """
+
+ with open(file_path, 'rb') as f:
+ s = struct.unpack('d' * BOTTLENECK_TENSOR_SIZE, f.read())
+ return list(s)
+
+
+bottleneck_path_2_bottleneck_values = {}
+
+
def get_or_create_bottleneck(sess, image_lists, label_name, index, image_dir,
category, bottleneck_dir, jpeg_data_tensor,
bottleneck_tensor):