We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
model/text_classification 使用内置语料集训练模型后，预测时出错，具体如下
```text
I1123 09:23:54.320137    84 Util.cpp:166] commandline:  --use_gpu=False --trainer_count=1 
Traceback (most recent call last):
  File "infer.py", line 91, in <module>
    batch_size=10)
  File "infer.py", line 58, in infer
    for idx, item in enumerate(test_reader):
TypeError: 'function' object is not iterable
```
paddle镜像用的是https://hub.docker.com/r/paddlepaddle/paddle/tags/ latest的，model下载的最新的

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `text_classification/infer.py`
Content:
```
1 import sys
2 import os
3 import gzip
4 
5 import paddle.v2 as paddle
6 
7 import reader
8 from network_conf import fc_net, convolution_net
9 from utils import logger, load_dict, load_reverse_dict
10 
11 
12 def infer(topology, data_dir, model_path, word_dict_path, label_dict_path,
13           batch_size):
14     def _infer_a_batch(inferer, test_batch, ids_2_word, ids_2_label):
15         probs = inferer.infer(input=test_batch, field=["value"])
16         assert len(probs) == len(test_batch)
17         for word_ids, prob in zip(test_batch, probs):
18             word_text = " ".join([ids_2_word[id] for id in word_ids[0]])
19             print("%s\t%s\t%s" % (ids_2_label[prob.argmax()],
20                                   " ".join(["{:0.4f}".format(p)
21                                             for p in prob]), word_text))
22 
23     logger.info("begin to predict...")
24     use_default_data = (data_dir is None)
25 
26     if use_default_data:
27         word_dict = paddle.dataset.imdb.word_dict()
28         word_reverse_dict = dict((value, key)
29                                  for key, value in word_dict.iteritems())
30         label_reverse_dict = {0: "positive", 1: "negative"}
31         test_reader = paddle.dataset.imdb.test(word_dict)
32     else:
33         assert os.path.exists(
34             word_dict_path), "the word dictionary file does not exist"
35         assert os.path.exists(
36             label_dict_path), "the label dictionary file does not exist"
37 
38         word_dict = load_dict(word_dict_path)
39         word_reverse_dict = load_reverse_dict(word_dict_path)
40         label_reverse_dict = load_reverse_dict(label_dict_path)
41 
42         test_reader = reader.test_reader(data_dir, word_dict)()
43 
44     dict_dim = len(word_dict)
45     class_num = len(label_reverse_dict)
46     prob_layer = topology(dict_dim, class_num, is_infer=True)
47 
48     # initialize PaddlePaddle
49     paddle.init(use_gpu=False, trainer_count=1)
50 
51     # load the trained models
52     parameters = paddle.parameters.Parameters.from_tar(
53         gzip.open(model_path, "r"))
54     inferer = paddle.inference.Inference(
55         output_layer=prob_layer, parameters=parameters)
56 
57     test_batch = []
58     for idx, item in enumerate(test_reader):
59         test_batch.append([item[0]])
60         if len(test_batch) == batch_size:
61             _infer_a_batch(inferer, test_batch, word_reverse_dict,
62                            label_reverse_dict)
63             test_batch = []
64 
65     if len(test_batch):
66         _infer_a_batch(inferer, test_batch, word_reverse_dict,
67                        label_reverse_dict)
68         test_batch = []
69 
70 
71 if __name__ == "__main__":
72     model_path = "models/dnn_params_pass_00000.tar.gz"
73     assert os.path.exists(model_path), "the trained model does not exist."
74 
75     nn_type = "dnn"
76     test_dir = None
77     word_dict = None
78     label_dict = None
79 
80     if nn_type == "dnn":
81         topology = fc_net
82     elif nn_type == "cnn":
83         topology = convolution_net
84 
85     infer(
86         topology=topology,
87         data_dir=test_dir,
88         word_dict_path=word_dict,
89         label_dict_path=label_dict,
90         model_path=model_path,
91         batch_size=10)
92
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/text_classification/infer.py b/text_classification/infer.py
--- a/text_classification/infer.py
+++ b/text_classification/infer.py
@@ -28,7 +28,7 @@
         word_reverse_dict = dict((value, key)
                                  for key, value in word_dict.iteritems())
         label_reverse_dict = {0: "positive", 1: "negative"}
-        test_reader = paddle.dataset.imdb.test(word_dict)
+        test_reader = paddle.dataset.imdb.test(word_dict)()
     else:
         assert os.path.exists(
             word_dict_path), "the word dictionary file does not exist"

{"golden_diff": "diff --git a/text_classification/infer.py b/text_classification/infer.py\n--- a/text_classification/infer.py\n+++ b/text_classification/infer.py\n@@ -28,7 +28,7 @@\n         word_reverse_dict = dict((value, key)\n                                  for key, value in word_dict.iteritems())\n         label_reverse_dict = {0: \"positive\", 1: \"negative\"}\n-        test_reader = paddle.dataset.imdb.test(word_dict)\n+        test_reader = paddle.dataset.imdb.test(word_dict)()\n     else:\n         assert os.path.exists(\n             word_dict_path), \"the word dictionary file does not exist\"\n", "issue": "model/text_classification \u4f7f\u7528\u5185\u7f6e\u8bed\u6599\u96c6\u8bad\u7ec3\u6a21\u578b\u540e\uff0c\u9884\u6d4b\u65f6\u51fa\u9519\uff0c\u5177\u4f53\u5982\u4e0b\n```text\r\nI1123 09:23:54.320137    84 Util.cpp:166] commandline:  --use_gpu=False --trainer_count=1 \r\nTraceback (most recent call last):\r\n  File \"infer.py\", line 91, in <module>\r\n    batch_size=10)\r\n  File \"infer.py\", line 58, in infer\r\n    for idx, item in enumerate(test_reader):\r\nTypeError: 'function' object is not iterable\r\n```\r\npaddle\u955c\u50cf\u7528\u7684\u662fhttps://hub.docker.com/r/paddlepaddle/paddle/tags/ latest\u7684\uff0cmodel\u4e0b\u8f7d\u7684\u6700\u65b0\u7684\n", "before_files": [{"content": "import sys\nimport os\nimport gzip\n\nimport paddle.v2 as paddle\n\nimport reader\nfrom network_conf import fc_net, convolution_net\nfrom utils import logger, load_dict, load_reverse_dict\n\n\ndef infer(topology, data_dir, model_path, word_dict_path, label_dict_path,\n          batch_size):\n    def _infer_a_batch(inferer, test_batch, ids_2_word, ids_2_label):\n        probs = inferer.infer(input=test_batch, field=[\"value\"])\n        assert len(probs) == len(test_batch)\n        for word_ids, prob in zip(test_batch, probs):\n            word_text = \" \".join([ids_2_word[id] for id in word_ids[0]])\n            print(\"%s\\t%s\\t%s\" % (ids_2_label[prob.argmax()],\n                                  \" \".join([\"{:0.4f}\".format(p)\n                                            for p in prob]), word_text))\n\n    logger.info(\"begin to predict...\")\n    use_default_data = (data_dir is None)\n\n    if use_default_data:\n        word_dict = paddle.dataset.imdb.word_dict()\n        word_reverse_dict = dict((value, key)\n                                 for key, value in word_dict.iteritems())\n        label_reverse_dict = {0: \"positive\", 1: \"negative\"}\n        test_reader = paddle.dataset.imdb.test(word_dict)\n    else:\n        assert os.path.exists(\n            word_dict_path), \"the word dictionary file does not exist\"\n        assert os.path.exists(\n            label_dict_path), \"the label dictionary file does not exist\"\n\n        word_dict = load_dict(word_dict_path)\n        word_reverse_dict = load_reverse_dict(word_dict_path)\n        label_reverse_dict = load_reverse_dict(label_dict_path)\n\n        test_reader = reader.test_reader(data_dir, word_dict)()\n\n    dict_dim = len(word_dict)\n    class_num = len(label_reverse_dict)\n    prob_layer = topology(dict_dim, class_num, is_infer=True)\n\n    # initialize PaddlePaddle\n    paddle.init(use_gpu=False, trainer_count=1)\n\n    # load the trained models\n    parameters = paddle.parameters.Parameters.from_tar(\n        gzip.open(model_path, \"r\"))\n    inferer = paddle.inference.Inference(\n        output_layer=prob_layer, parameters=parameters)\n\n    test_batch = []\n    for idx, item in enumerate(test_reader):\n        test_batch.append([item[0]])\n        if len(test_batch) == batch_size:\n            _infer_a_batch(inferer, test_batch, word_reverse_dict,\n                           label_reverse_dict)\n            test_batch = []\n\n    if len(test_batch):\n        _infer_a_batch(inferer, test_batch, word_reverse_dict,\n                       label_reverse_dict)\n        test_batch = []\n\n\nif __name__ == \"__main__\":\n    model_path = \"models/dnn_params_pass_00000.tar.gz\"\n    assert os.path.exists(model_path), \"the trained model does not exist.\"\n\n    nn_type = \"dnn\"\n    test_dir = None\n    word_dict = None\n    label_dict = None\n\n    if nn_type == \"dnn\":\n        topology = fc_net\n    elif nn_type == \"cnn\":\n        topology = convolution_net\n\n    infer(\n        topology=topology,\n        data_dir=test_dir,\n        word_dict_path=word_dict,\n        label_dict_path=label_dict,\n        model_path=model_path,\n        batch_size=10)\n", "path": "text_classification/infer.py"}], "after_files": [{"content": "import sys\nimport os\nimport gzip\n\nimport paddle.v2 as paddle\n\nimport reader\nfrom network_conf import fc_net, convolution_net\nfrom utils import logger, load_dict, load_reverse_dict\n\n\ndef infer(topology, data_dir, model_path, word_dict_path, label_dict_path,\n          batch_size):\n    def _infer_a_batch(inferer, test_batch, ids_2_word, ids_2_label):\n        probs = inferer.infer(input=test_batch, field=[\"value\"])\n        assert len(probs) == len(test_batch)\n        for word_ids, prob in zip(test_batch, probs):\n            word_text = \" \".join([ids_2_word[id] for id in word_ids[0]])\n            print(\"%s\\t%s\\t%s\" % (ids_2_label[prob.argmax()],\n                                  \" \".join([\"{:0.4f}\".format(p)\n                                            for p in prob]), word_text))\n\n    logger.info(\"begin to predict...\")\n    use_default_data = (data_dir is None)\n\n    if use_default_data:\n        word_dict = paddle.dataset.imdb.word_dict()\n        word_reverse_dict = dict((value, key)\n                                 for key, value in word_dict.iteritems())\n        label_reverse_dict = {0: \"positive\", 1: \"negative\"}\n        test_reader = paddle.dataset.imdb.test(word_dict)()\n    else:\n        assert os.path.exists(\n            word_dict_path), \"the word dictionary file does not exist\"\n        assert os.path.exists(\n            label_dict_path), \"the label dictionary file does not exist\"\n\n        word_dict = load_dict(word_dict_path)\n        word_reverse_dict = load_reverse_dict(word_dict_path)\n        label_reverse_dict = load_reverse_dict(label_dict_path)\n\n        test_reader = reader.test_reader(data_dir, word_dict)()\n\n    dict_dim = len(word_dict)\n    class_num = len(label_reverse_dict)\n    prob_layer = topology(dict_dim, class_num, is_infer=True)\n\n    # initialize PaddlePaddle\n    paddle.init(use_gpu=False, trainer_count=1)\n\n    # load the trained models\n    parameters = paddle.parameters.Parameters.from_tar(\n        gzip.open(model_path, \"r\"))\n    inferer = paddle.inference.Inference(\n        output_layer=prob_layer, parameters=parameters)\n\n    test_batch = []\n    for idx, item in enumerate(test_reader):\n        test_batch.append([item[0]])\n        if len(test_batch) == batch_size:\n            _infer_a_batch(inferer, test_batch, word_reverse_dict,\n                           label_reverse_dict)\n            test_batch = []\n\n    if len(test_batch):\n        _infer_a_batch(inferer, test_batch, word_reverse_dict,\n                       label_reverse_dict)\n        test_batch = []\n\n\nif __name__ == \"__main__\":\n    model_path = \"models/dnn_params_pass_00000.tar.gz\"\n    assert os.path.exists(model_path), \"the trained model does not exist.\"\n\n    nn_type = \"dnn\"\n    test_dir = None\n    word_dict = None\n    label_dict = None\n\n    if nn_type == \"dnn\":\n        topology = fc_net\n    elif nn_type == \"cnn\":\n        topology = convolution_net\n\n    infer(\n        topology=topology,\n        data_dir=test_dir,\n        word_dict_path=word_dict,\n        label_dict_path=label_dict,\n        model_path=model_path,\n        batch_size=10)\n", "path": "text_classification/infer.py"}]}