Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'map' object is not subscriptable #1

Open
ghost opened this issue Jul 16, 2017 · 4 comments
Open

'map' object is not subscriptable #1

ghost opened this issue Jul 16, 2017 · 4 comments

Comments

@ghost
Copy link

ghost commented Jul 16, 2017

I followed all your instructions, but when trying to train, I get this output:

./train.sh The mode is train. complete initializing model. A2B/Generator/conv1/weights:0 A2B/Generator/conv2/weights:0 A2B/Generator/conv2/batch_norm/beta:0 A2B/Generator/conv3/weights:0 A2B/Generator/conv3/batch_norm/beta:0 A2B/Generator/conv4/weights:0 A2B/Generator/conv4/batch_norm/beta:0 A2B/Generator/convt2/weights:0 A2B/Generator/convt2/batch_norm/beta:0 A2B/Generator/convt3/weights:0 A2B/Generator/convt3/batch_norm/beta:0 A2B/Generator/convt4/weights:0 A2B/Generator/convt4/batch_norm/beta:0 A2B/Generator/convt5/weights:0 B2A/Generator/conv1/weights:0 B2A/Generator/conv2/weights:0 B2A/Generator/conv2/batch_norm/beta:0 B2A/Generator/conv3/weights:0 B2A/Generator/conv3/batch_norm/beta:0 B2A/Generator/conv4/weights:0 B2A/Generator/conv4/batch_norm/beta:0 B2A/Generator/convt2/weights:0 B2A/Generator/convt2/batch_norm/beta:0 B2A/Generator/convt3/weights:0 B2A/Generator/convt3/batch_norm/beta:0 B2A/Generator/convt4/weights:0 B2A/Generator/convt4/batch_norm/beta:0 B2A/Generator/convt5/weights:0 A/Discriminator/conv1/weights:0 A/Discriminator/conv2/weights:0 A/Discriminator/conv2/batch_norm/beta:0 A/Discriminator/conv3/weights:0 A/Discriminator/conv3/batch_norm/beta:0 A/Discriminator/conv4/weights:0 A/Discriminator/conv4/batch_norm/beta:0 A/Discriminator/conv5/weights:0 B/Discriminator/conv1/weights:0 B/Discriminator/conv2/weights:0 B/Discriminator/conv2/batch_norm/beta:0 B/Discriminator/conv3/weights:0 B/Discriminator/conv3/batch_norm/beta:0 B/Discriminator/conv4/weights:0 B/Discriminator/conv4/batch_norm/beta:0 B/Discriminator/conv5/weights:0 complete model build. 2017-07-16 20:31:36.540850: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations. 2017-07-16 20:31:36.540880: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations. 2017-07-16 20:31:36.540890: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations. 2017-07-16 20:31:36.540899: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations. Traceback (most recent call last): File "train.py", line 236, in <module> tf.app.run() File "/Users/me/miniconda3/envs/face-extract/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "train.py", line 193, in main data_A, data_B = data.get_data() File "/Users/me/Documents/python/discoGAN.tensorflow.slim-master/data.py", line 76, in get_data n_test=FLAGS.n_test) File "/Users/me/Documents/python/discoGAN.tensorflow.slim-master/data.py", line 40, in _get_celebA_files image_data = _read_attr_file( attr_file, image_dir ) File "/Users/me/Documents/python/discoGAN.tensorflow.slim-master/data.py", line 27, in _read_attr_file columns = ['image_path'] + lines[1].split() TypeError: 'map' object is not subscriptable

@ilguyi
Copy link
Owner

ilguyi commented Jul 17, 2017

Thank you for using my discoGAN code and your question.

I think above error, TypeError: 'map' object is not subscriptable, is related to python 3.
My codes are based on python 2 and there is any problem using python 2.
TypeError: 'map' object is not subscriptable error is caused by a return format map of python 3.
To avoid this error, I change the line 26 in data.py, and use list instead of map.

(-) lines = map(lambda line: line.strip(), lines)
(+) lines = [line.strip() for line in lines]

Let me know if you have another problem.

@ghost
Copy link
Author

ghost commented Jul 17, 2017

Thank you =)

On to the next problem:
./train.sh The mode is train. complete initializing model. A2B/Generator/conv1/weights:0 A2B/Generator/conv2/weights:0 A2B/Generator/conv2/batch_norm/beta:0 A2B/Generator/conv3/weights:0 A2B/Generator/conv3/batch_norm/beta:0 A2B/Generator/conv4/weights:0 A2B/Generator/conv4/batch_norm/beta:0 A2B/Generator/convt2/weights:0 A2B/Generator/convt2/batch_norm/beta:0 A2B/Generator/convt3/weights:0 A2B/Generator/convt3/batch_norm/beta:0 A2B/Generator/convt4/weights:0 A2B/Generator/convt4/batch_norm/beta:0 A2B/Generator/convt5/weights:0 B2A/Generator/conv1/weights:0 B2A/Generator/conv2/weights:0 B2A/Generator/conv2/batch_norm/beta:0 B2A/Generator/conv3/weights:0 B2A/Generator/conv3/batch_norm/beta:0 B2A/Generator/conv4/weights:0 B2A/Generator/conv4/batch_norm/beta:0 B2A/Generator/convt2/weights:0 B2A/Generator/convt2/batch_norm/beta:0 B2A/Generator/convt3/weights:0 B2A/Generator/convt3/batch_norm/beta:0 B2A/Generator/convt4/weights:0 B2A/Generator/convt4/batch_norm/beta:0 B2A/Generator/convt5/weights:0 A/Discriminator/conv1/weights:0 A/Discriminator/conv2/weights:0 A/Discriminator/conv2/batch_norm/beta:0 A/Discriminator/conv3/weights:0 A/Discriminator/conv3/batch_norm/beta:0 A/Discriminator/conv4/weights:0 A/Discriminator/conv4/batch_norm/beta:0 A/Discriminator/conv5/weights:0 B/Discriminator/conv1/weights:0 B/Discriminator/conv2/weights:0 B/Discriminator/conv2/batch_norm/beta:0 B/Discriminator/conv3/weights:0 B/Discriminator/conv3/batch_norm/beta:0 B/Discriminator/conv4/weights:0 B/Discriminator/conv4/batch_norm/beta:0 B/Discriminator/conv5/weights:0 complete model build. Traceback (most recent call last): File "train.py", line 236, in <module> tf.app.run() File "/Users/me/miniconda3/envs/face-extract/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "train.py", line 193, in main data_A, data_B = data.get_data() File "/Users/me/Documents/python/discoGAN.tensorflow.slim-master/data.py", line 76, in get_data n_test=FLAGS.n_test) File "/Users/me/Documents/python/discoGAN.tensorflow.slim-master/data.py", line 40, in _get_celebA_files image_data = _read_attr_file( attr_file, image_dir ) File "/Users/me/Documents/python/discoGAN.tensorflow.slim-master/data.py", line 31, in _read_attr_file df = pd.DataFrame( items, columns=columns ) File "/Users/me/miniconda3/envs/face-extract/lib/python3.6/site-packages/pandas/core/frame.py", line 334, in __init__ raise TypeError("data argument can't be an iterator") TypeError: data argument can't be an iterator

@ilguyi
Copy link
Owner

ilguyi commented Jul 18, 2017

This error is also caused by map function of python 3.
You can solve the problem in the same way which means my first comment.
Change the line 30 in data.py, and use list instead of map.

(-) items = map(lambda line: line.split(), lines)
(+) items = [line.split() for line in lines]

Enjoy the code!

@ghost
Copy link
Author

ghost commented Jul 18, 2017

oh I didn't see that XD fixed it and all the other parts where map() could be a problem, but now I'm getting:

  File "mtrand.pyx", line 4835, in mtrand.RandomState.shuffle (numpy/random/mtrand/mtrand.c:39530)
TypeError: 'range' object does not support item assignment

It seems like your project is just not compatible with my python and package versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant