-
Notifications
You must be signed in to change notification settings - Fork 456
Description
I spent 5 hours getting the program running, which is a great waste of time. I hereby summarize all the necessary changes for this project to run in Python 3.x and TensorFlow r1.x environment.
I assume your working directory is ~/StackGAN/StageI.
1. Python 3.x compatibility issues
In addition to minor changes mentioned in #2, there are still a major issue:
Pickle Issue: The original pickle files are created in Python 2.7, and open it with Python 3 could lead to the following error:
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1: ordinal not in range(128)
The solution can be found here: Unpickle Python 2 object in Python 3
2. TensorFlow r1.x compatibility issues
tf.concat() Issue #11: If you encounter error message like this:
TypeError: Expected int32, got <prettytensor.pretty_tensor_class.Layer object at 0x7f74d41abd90> of type 'Layer' instead.
In TensorFlow r0.12, the function is like
tf.concat(axis, value)
while in TensorFlow r1.x version the argument order has been changed:
tf.concat(value, axis)
PrettyTensor Issue #27: This issue is cause in PrettyTensor module with error message like this:
File ".../site-packages/prettytensor/pretty_tensor_class.py", line 1335, in _strip_unnecessary_contents_from_stack for f, line_no, method, _ in result._traceback: ValueError: too many values to unpack (expected 4)
This issue has nothing to do with PrettyTensor package version, I use the latest 0.7.4 but 0.6.2 should also work.
The main cause of this problem is in _traceback format, in TensorFlow r1.3 the _traceback object is a list with each entry a 6-tuple like this:
('D:\\Anaconda3\\envs\\tensorflow\\lib\\site-packages\\spyder\\utils\\ipython\\start_kernel.py', 241, '<module>', {'__name__': '__main__', '__doc__': '\nFile used to start kernels for the IPython Console\n', '__package__': None, '__loader__': <_frozen_importlib_external.SourceFileLoader object at 0x0000021474E75CF8>, '__spec__': None, '__annotations__': {}, '__builtins__': <module 'builtins' (built-in)>, '__file__': 'D:\\Anaconda3\\envs\\tensorflow\\lib\\site-packages\\spyder\\utils\\ipython\\start_kernel.py', '__cached__': None, 'os': <module 'os' from 'D:\\Anaconda3\\envs\\tensorflow\\lib\\os.py'>, 'osp': <module 'ntpath' from 'D:\\Anaconda3\\envs\\tensorflow\\lib\\ntpath.py'>, 'sys': <module 'sys' (built-in)>, 'IS_EXT_INTERPRETER': True, 'sympy_config': <function sympy_config at 0x00000214799891E0>, 'kernel_config': <function kernel_config at 0x0000021479989268>, 'varexp': <function varexp at 0x00000214799892F0>, 'main': <function main at 0x0000021479989378>}, 9, None)
I guess in TensorFlow r0.12 the entry only contains 4 elements. But anyway here's a quick workaround:
Change
for f, line_no, method, _ in result._traceback:
to
for f, line_no, method, *_ in result._traceback:
*_ takes any number of arguments and resolve whatever left in the unpacked tuple.
3. Summary Issue:
TensorFlow r1.3 has a new summary class so many code should be adapted like this:
tf.merge_all_summaries() -> tf.summary.merge_all()
tf.scalar_summary(k,v) -> tf.summary.scalar(k,v)
summary_writer = tf.train.SummaryWriter(self.log_dir, sess.graph) ->
summary_writer = tf.summary.FileWriter(self.log_dir, sess.graph)
4. Slicing Index Issue:
The index must be integer, so in dataset.py line 80 something should be changed:
# cropped_image =\ # images[i][w1: w1 + self._imsize, h1: h1 + self._imsize, :] original_image = images[i] cropped_image = original_image[int(w1): int(w1 + imsize),\ int(h1): int(h1 + imsize), :]
That's all the major compatibility issues that are necessary for training. Enjoy :)
