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

indices error while training #21

Open
moeinsamadi opened this issue Apr 19, 2019 · 2 comments
Open

indices error while training #21

moeinsamadi opened this issue Apr 19, 2019 · 2 comments

Comments

@moeinsamadi
Copy link

Hi. I encountered with the following error while training:
`Prepare Data...

Traceback (most recent call last):
File "main.py", line 53, in
tf.app.run()
File "/home/hermes/.local/lib/python3.6/site-packages/tensorflow/python/platform/app.py", line 124, in run
sys.exit(main(argv))
File "main.py", line 45, in main
rdn.train(FLAGS)
File "/home/hermes/RDN-TensorFlow-master/model.py", line 272, in train
input_setup(config)
File "/home/hermes/RDN-TensorFlow-master/utils.py", line 194, in input_setup
make_sub_data(data, config)
File "/home/hermes/RDN-TensorFlow-master/utils.py", line 126, in make_sub_data
input
, label_, = preprocess(data[i], config.scale, eng, mdouble)
File "/home/hermes/RDN-TensorFlow-master/utils.py", line 55, in preprocess
label_ = modcrop(img, scale)
File "/home/hermes/RDN-TensorFlow-master/utils.py", line 45, in modcrop
img = img[0:h, 0:w, :]
TypeError: slice indices must be integers or None or have an index method`

I used python3 branch. Also I should mention that I put all images to RDN-TensorFlow/Train/DIV2K_train_HR.
What should I do now?
Thanks

@LiUzHiAn
Copy link

@moeinsamadi
hi, this error is caused by python3 version. In python3 branch, the / is float number division , while // is division for integer. So, you have to complete this modification of line (43、44、48、49、155、156) in utils.py.
BTW, could you please share your hyperprameters configuration?

@moeinsamadi
Copy link
Author

@LiUzHiAn
Thank you very much. It is working now!
These are the hyperparameters:
flags.DEFINE_integer("image_size", 32, "the size of image input")
flags.DEFINE_integer("c_dim", 3, "the size of channel")
flags.DEFINE_integer("scale", 3, "the size of scale factor for preprocessing input image")
flags.DEFINE_integer("stride", 16, "the size of stride")
flags.DEFINE_integer("epoch", 2, "number of epoch")
flags.DEFINE_integer("batch_size", 128, "the size of batch")
flags.DEFINE_float("learning_rate", 1e-4 , "the learning rate")
flags.DEFINE_integer("D", 5, "D")
flags.DEFINE_integer("C", 3, "C")
flags.DEFINE_integer("G", 64, "G")
flags.DEFINE_integer("G0", 64, "G0")
flags.DEFINE_integer("kernel_size", 3, "the size of kernel")

Training seems to be so time consuming! I ran the training on a laptop with Intel R Core i5 CPU M 480 2.67GHz × 4 and 3.7 GiB Memory. Training time for each epoch was approximately 3 hour!
I only changed "batch_size" from 64 (default) to 128.

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

2 participants