The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Error in TensorFlow_Audiobooks_Machine_learning_Homework

Error in TensorFlow_Audiobooks_Machine_learning_Homework

0
Votes
1
Answer

Hi,
I’ve tried to run TensorFlow_Audiobooks_Machine_learning_Homework, but I’ve gotten the following error message (I’m using Python 2 and Tensorflow 1.4.0):
 

TypeErrorTraceback (most recent call last)
<ipython-input-2-c3f67ecae46a> in <module>()
     72     # As a reminder, it batches samples together, one-hot encodes the targets, and returns
     73     # inputs and targets batch by batch
---> 74     for input_batch, target_batch in train_data:
     75         _, batch_loss = sess.run([optimize, mean_loss], 
     76             feed_dict={inputs: input_batch, targets: target_batch})

TypeError: instance has no next() method

 
The first cell of this code run without errors.

How could I solve the problem?
 
Thanks a lot,
Ligia Batista

 
edit delete flag

1 Answer

365 Team
0
Votes

Hi Ligia,
The error states ‘instance has no next() method’.
The point is that in Python 2 and Python 3, classes and methods are defined in different ways. You can read more about that here: https://portingguide.readthedocs.io/en/latest/classes.html
If I remember correctly, to make it work, you needed to place double underscore before and after a method. So when you define

def next()

you should write:

def __next__()

instead.
Iliya