diff --git a/example/tutorial_tfrecord3.py b/example/tutorial_tfrecord3.py index 0da7a8b83..b111bf127 100644 --- a/example/tutorial_tfrecord3.py +++ b/example/tutorial_tfrecord3.py @@ -15,15 +15,12 @@ """ -import io import json import os -import time import numpy as np import tensorflow as tf import tensorlayer as tl from PIL import Image -from tensorlayer.layers import set_keep def _int64_feature(value): @@ -326,7 +323,7 @@ def prefetch_input_data(reader, try: # for TensorFlow 0.11 img = tf.image.resize_images(img, size=(resize_height, resize_width), method=tf.image.ResizeMethod.BILINEAR) -except: +except Exception: # for TensorFlow 0.10 img = tf.image.resize_images(img, new_height=resize_height, new_width=resize_width, method=tf.image.ResizeMethod.BILINEAR) # Crop to final dimensions. diff --git a/tensorlayer/prepro.py b/tensorlayer/prepro.py index 85970e9f9..04af4c328 100644 --- a/tensorlayer/prepro.py +++ b/tensorlayer/prepro.py @@ -100,8 +100,10 @@ def apply_fn(results, i, data, kwargs): if thread_count is None: results = [None] * len(data) threads = [] - for i in range(len(data)): - t = threading.Thread(name='threading_and_return', target=apply_fn, args=(results, i, data[i], kwargs)) + # for i in range(len(data)): + # t = threading.Thread(name='threading_and_return', target=apply_fn, args=(results, i, data[i], kwargs)) + for i, d in enumerate(data): + t = threading.Thread(name='threading_and_return', target=apply_fn, args=(results, i, d, kwargs)) t.start() threads.append(t) else: @@ -120,7 +122,7 @@ def apply_fn(results, i, data, kwargs): if thread_count is None: try: return np.asarray(results) - except: + except Exception: return results else: return np.concatenate(results)