pkmital / CADL

ARCHIVED: Contains historical course materials/Homework materials for the FREE MOOC course on "Creative Applications of Deep Learning w/ Tensorflow" #CADL
https://www.kadenze.com/courses/creative-applications-of-deep-learning-with-tensorflow/info
Apache License 2.0
1.48k stars 732 forks source link

Index Error in Session 3 at Reorganize a grid. #42

Closed sunil-sangwan closed 7 years ago

sunil-sangwan commented 7 years ago

Code: examples_sorted = [] for i in indexes[1]: examples_sorted.append(examples[i]) plt.figure(figsize=(15, 15)) img = utils.montage(np.array(examples_sorted)).astype(np.uint8) plt.imshow(img, interpolation='nearest') plt.imsave(arr=img, fname='sorted.png')

Errror: IndexError: index 3479 is out of bounds for axis 0 with size 100.

pkmital commented 7 years ago

indexes[1] should index the grid element as a result of the assignment problem. I've just tested this and it works for my test case still. Are you using more than 100 images? In that case, at the beginning of "Reorganize to Grid", you should have properly set n_images = ... to the number of images you are using.

sunil-sangwan commented 7 years ago

I am using 100 images as you set n_images=100 in "Reorganize to Grid" part. index

pkmital commented 7 years ago

What do you see when you print out the "indexes" variable?

sunil-sangwan commented 7 years ago

in indexes[1] it gave values which are out of range for imgs, while indexes[0] gave values in range to create montage.

pkmital commented 7 years ago

Can you print and copy the output of idxs, xs, ys, grid and indexes here?

sunil-sangwan commented 7 years ago

output of idxs, xs, ys, grid and indexes

print (idxs)

[-2. -1.55555556 -1.11111111 -0.66666667 -0.22222222 0.22222222 0.66666667 1.11111111 1.55555556 2. ]

print (xs)

[[-2. -1.55555556 -1.11111111 -0.66666667 -0.22222222 0.22222222 0.66666667 1.11111111 1.55555556 2. ] [-2. -1.55555556 -1.11111111 -0.66666667 -0.22222222 0.22222222 0.66666667 1.11111111 1.55555556 2. ] [-2. -1.55555556 -1.11111111 -0.66666667 -0.22222222 0.22222222 0.66666667 1.11111111 1.55555556 2. ] [-2. -1.55555556 -1.11111111 -0.66666667 -0.22222222 0.22222222 0.66666667 1.11111111 1.55555556 2. ] [-2. -1.55555556 -1.11111111 -0.66666667 -0.22222222 0.22222222 0.66666667 1.11111111 1.55555556 2. ] [-2. -1.55555556 -1.11111111 -0.66666667 -0.22222222 0.22222222 0.66666667 1.11111111 1.55555556 2. ] [-2. -1.55555556 -1.11111111 -0.66666667 -0.22222222 0.22222222 0.66666667 1.11111111 1.55555556 2. ] [-2. -1.55555556 -1.11111111 -0.66666667 -0.22222222 0.22222222 0.66666667 1.11111111 1.55555556 2. ] [-2. -1.55555556 -1.11111111 -0.66666667 -0.22222222 0.22222222 0.66666667 1.11111111 1.55555556 2. ] [-2. -1.55555556 -1.11111111 -0.66666667 -0.22222222 0.22222222 0.66666667 1.11111111 1.55555556 2. ]]

print (ys)

[[-2. -2. -2. -2. -2. -2. -2. -2. -2. -2. ] [-1.55555556 -1.55555556 -1.55555556 -1.55555556 -1.55555556 -1.55555556 -1.55555556 -1.55555556 -1.55555556 -1.55555556] [-1.11111111 -1.11111111 -1.11111111 -1.11111111 -1.11111111 -1.11111111 -1.11111111 -1.11111111 -1.11111111 -1.11111111] [-0.66666667 -0.66666667 -0.66666667 -0.66666667 -0.66666667 -0.66666667 -0.66666667 -0.66666667 -0.66666667 -0.66666667] [-0.22222222 -0.22222222 -0.22222222 -0.22222222 -0.22222222 -0.22222222 -0.22222222 -0.22222222 -0.22222222 -0.22222222] [ 0.22222222 0.22222222 0.22222222 0.22222222 0.22222222 0.22222222 0.22222222 0.22222222 0.22222222 0.22222222] [ 0.66666667 0.66666667 0.66666667 0.66666667 0.66666667 0.66666667 0.66666667 0.66666667 0.66666667 0.66666667] [ 1.11111111 1.11111111 1.11111111 1.11111111 1.11111111 1.11111111 1.11111111 1.11111111 1.11111111 1.11111111] [ 1.55555556 1.55555556 1.55555556 1.55555556 1.55555556 1.55555556 1.55555556 1.55555556 1.55555556 1.55555556] [ 2. 2. 2. 2. 2. 2. 2.

      1. ]]

print (grid)

[[-2. -2. ] [-2. -1.55555556] [-2. -1.11111111] [-2. -0.66666667] [-2. -0.22222222] [-2. 0.22222222] [-2. 0.66666667] [-2. 1.11111111] [-2. 1.55555556] [-2. 2. ] [-1.55555556 -2. ] [-1.55555556 -1.55555556] [-1.55555556 -1.11111111] [-1.55555556 -0.66666667] [-1.55555556 -0.22222222] [-1.55555556 0.22222222] [-1.55555556 0.66666667] [-1.55555556 1.11111111] [-1.55555556 1.55555556] [-1.55555556 2. ] [-1.11111111 -2. ] [-1.11111111 -1.55555556] [-1.11111111 -1.11111111] [-1.11111111 -0.66666667] [-1.11111111 -0.22222222] [-1.11111111 0.22222222] [-1.11111111 0.66666667] [-1.11111111 1.11111111] [-1.11111111 1.55555556] [-1.11111111 2. ] [-0.66666667 -2. ] [-0.66666667 -1.55555556] [-0.66666667 -1.11111111] [-0.66666667 -0.66666667] [-0.66666667 -0.22222222] [-0.66666667 0.22222222] [-0.66666667 0.66666667] [-0.66666667 1.11111111] [-0.66666667 1.55555556] [-0.66666667 2. ] [-0.22222222 -2. ] [-0.22222222 -1.55555556] [-0.22222222 -1.11111111] [-0.22222222 -0.66666667] [-0.22222222 -0.22222222] [-0.22222222 0.22222222] [-0.22222222 0.66666667] [-0.22222222 1.11111111] [-0.22222222 1.55555556] [-0.22222222 2. ] [ 0.22222222 -2. ] [ 0.22222222 -1.55555556] [ 0.22222222 -1.11111111] [ 0.22222222 -0.66666667] [ 0.22222222 -0.22222222] [ 0.22222222 0.22222222] [ 0.22222222 0.66666667] [ 0.22222222 1.11111111] [ 0.22222222 1.55555556] [ 0.22222222 2. ] [ 0.66666667 -2. ] [ 0.66666667 -1.55555556] [ 0.66666667 -1.11111111] [ 0.66666667 -0.66666667] [ 0.66666667 -0.22222222] [ 0.66666667 0.22222222] [ 0.66666667 0.66666667] [ 0.66666667 1.11111111] [ 0.66666667 1.55555556] [ 0.66666667 2. ] [ 1.11111111 -2. ] [ 1.11111111 -1.55555556] [ 1.11111111 -1.11111111] [ 1.11111111 -0.66666667] [ 1.11111111 -0.22222222] [ 1.11111111 0.22222222] [ 1.11111111 0.66666667] [ 1.11111111 1.11111111] [ 1.11111111 1.55555556] [ 1.11111111 2. ] [ 1.55555556 -2. ] [ 1.55555556 -1.55555556] [ 1.55555556 -1.11111111] [ 1.55555556 -0.66666667] [ 1.55555556 -0.22222222] [ 1.55555556 0.22222222] [ 1.55555556 0.66666667] [ 1.55555556 1.11111111] [ 1.55555556 1.55555556] [ 1.55555556 2. ] [ 2. -2. ] [ 2. -1.55555556] [ 2. -1.11111111] [ 2. -0.66666667] [ 2. -0.22222222] [ 2. 0.22222222] [ 2. 0.66666667] [ 2. 1.11111111] [ 2. 1.55555556] [ 2. 2. ]]

print (indexes)

(array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99]), array([ 3479, 3445, 3151, 3112, 3100, 3097, 3038, 49962, 35480, 21123, 3031, 3028, 3019, 3016, 3014, 2965, 2943, 2940, 2935, 9397, 2916, 2896, 2881, 2818, 2655, 2524, 2460, 2455, 2450, 234, 2433, 2428, 2401, 2325, 2284, 2086, 2064, 2056, 2053, 1966, 1965, 1963, 1951, 1933, 1906, 1894, 1888, 1867, 1818, 1813, 2445, 1803, 1798, 1791, 1720, 1516, 1428, 1341, 1336, 1335, 2440, 2418, 1331, 1216, 1213, 1194, 988, 983, 939, 934, 48477, 2372, 1941, 912, 885, 851, 807, 789, 669, 427, 30147, 21133, 1897, 1877, 424, 405, 385, 363, 337, 334, 19511, 17929, 16856, 317, 343, 332, 319, 310, 309, 268]))

pkmital commented 7 years ago

Is the shape of zs (100, 2) ?

sunil-sangwan commented 7 years ago

yes

pkmital commented 7 years ago

I'm stumped. You should see something like this:

screen shot 2017-01-05 at 12 01 04 pm

You can attach the notebook and I'll have a look.

sunil-sangwan commented 7 years ago

sorry I made a mistake my zs shape is (53400, 2)

pkmital commented 7 years ago

So you have 53400 images. It's a lot for this algorithm but you can try. You just have to set n_images to that number. Good luck!

sunil-sangwan commented 7 years ago

Thank you for help