Problem Description: when using the reader to read the training data, there is an error, and the error prompt is typeerror: ‘function’ object is not iterative
error message:
TypeError Traceback (most recent call last)
<ipython-input-12-0b74c209241b> in <module>
2 for pass_id in range(1):
----> 3 for batch_id, data in enumerate(train_reader):
4 train_cost, train_acc = exe.run(program=fluid.default_main_program(),
5 feed=feeder.feed(data),
TypeError: 'function' object is not iterable
Problem recurrence: when reading data in the loop, the reader defined by padding. Batch()
iterates over the data, and enumerate()
uses the defined variables. When the function is called, an error will be reported. The error code is as follows:
for batch_id, data in enumerate(train_reader):
train_cost, train_acc = exe.run(program=fluid.default_main_program(),
feed=feeder.feed(data),
fetch_list=[avg_cost, acc])
Problem-solving: the same as a data reading function obtained by pad DLE. Batch()
, the return value is a reader, and the reason for the above error is that it directly trains_ Reader
variable, which refers to a function, so you need to add a bracket to get the return value reader of the function
for batch_id, data in enumerate(train_reader()):
train_cost, train_acc = exe.run(program=fluid.default_main_program(),
feed=feeder.feed(data),
fetch_list=[avg_cost, acc])
In Python variables, when there are no parentheses, the function itself is called. It is a function object, and there is no need to wait for the function to be executed. With brackets, the result of the function is called, and the result of the function execution must be completed
Similar Posts:
- PaddlePaddle Error: ‘map’ object is not subscriptable
- Tensorflowcenter {typeerror} non hashable type: “numpy. Ndarray”
- How to Solve Python TypeError: ‘list’ object is not callable
- Fast locating nonetype ‘object is not Iterable in Python
- FileReader Object Error: FileReader Error: Object is already busy reading blob
- Chinese character handwriting recognition based on densenetensorflow
- How to Solve Libpng warning ICCP error
- Tensorflow error due to uninitialized variable [How to Fix]
- RuntimeError: DataLoader worker (pid(s) 24632, 26892, 10480, 2964) exited unexpectedly
- Convert Object to List>, avoiding Unchecked cast: ‘java.lang.Object’ to ‘java.util.List