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

Problem in the generator named 'data_generator' and the corresponding generators in 'data_loader.py' file #6

Open
ShubhayuDas opened this issue Sep 17, 2018 · 1 comment

Comments

@ShubhayuDas
Copy link

I got an error at the very last section of the w_net_walk_through.ipynb file :

  2 depthmaps = []
  3 for i in tqdm(range(1)):

----> 4 dat = data_generator.next()
5
6 disparity_map_left, disparity_map_right = disp_maps_forward.predict(dat[0][0:10])

AttributeError: 'generator' object has no attribute 'next'

After going through https://stackoverflow.com/questions/1073396/is-generator-next-visible-in-python-3-0 , I found that on python 3 you need to use data_generator.next() or next(data_generator).

Note: I had to change this in the walk_through.ipynb file and the data_loader.py file as well

But even after this I get a Type Error:

TypeError: 'float' object cannot be interpreted as an integer

Here is the output:

TypeError Traceback (most recent call last)
in ()
2 depthmaps = []
3 for i in tqdm(range(1)):
----> 4 dat = data_generator.next()
5
6 disparity_map_left, disparity_map_right = disp_maps_forward.predict(dat[0][0:10])

~/PycharmProjects/tensorplay/venv/w-net-master/data_loader.py in train_generator_func()
50 def train_generator_func():
51 while True:
---> 52 X = train_generator1.next(self)
53 Y1 = train_generator2.next(self)
54 yield X, [Y1, np.zeros(shape=(Y1.shape[0], img_rows - 4, img_cols - 4)),

~/PycharmProjects/tensorplay/venv/lib/python3.6/site-packages/keras_preprocessing/image.py in next(self)
1817 # The transformation of images is not under thread lock
1818 # so it can be done in parallel
-> 1819 return self._get_batches_of_transformed_samples(index_array)

~/PycharmProjects/tensorplay/venv/lib/python3.6/site-packages/keras_preprocessing/image.py in _get_batches_of_transformed_samples(self, index_array)
1763 batch_x = np.zeros(
1764 (len(index_array),) + self.image_shape,
-> 1765 dtype=backend.floatx())
1766 # build batch of image data
1767 for i, j in enumerate(index_array):

TypeError: 'float' object cannot be interpreted as an integer

I am unable to fix this. Please help..

@tv12345
Copy link

tv12345 commented Nov 2, 2018

Managed to solve it by downgrading numpy to 1.11.0.

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