提交 298bb590 编写于 作者: M MRXLT

add readme for imdb examples

上级 1bc973e8
...@@ -254,7 +254,7 @@ std::vector<std::vector<std::vector<float>>> PredictorClient::predict_for_batch( ...@@ -254,7 +254,7 @@ std::vector<std::vector<std::vector<float>>> PredictorClient::predict_for_batch(
fetch_result_batch[bi][idx].resize(len); fetch_result_batch[bi][idx].resize(len);
for (int i = 0; i < len; ++i) { for (int i = 0; i < len; ++i) {
fetch_result_batch[bi][idx][i] = fetch_result_batch[bi][idx][i] =
*(const float *)res.insts(0).tensor_array(idx).data(i).c_str(); *(const float *)res.insts(bi).tensor_array(idx).data(i).c_str();
} }
} }
} }
......
...@@ -10,4 +10,7 @@ cat test.data | python test_client.py > result ...@@ -10,4 +10,7 @@ cat test.data | python test_client.py > result
``` ```
python test_client_multithread.py inference.conf test.data 4 > result python test_client_multithread.py inference.conf test.data 4 > result
``` ```
batch clienit batch clienit,若batch size为4
```
cat test.data | python test_client_batch inference.conf 4 > result
```
...@@ -161,6 +161,7 @@ class Client(object): ...@@ -161,6 +161,7 @@ class Client(object):
int_feed_names = [] int_feed_names = []
float_feed_names = [] float_feed_names = []
fetch_names = [] fetch_names = []
counter = 0
for feed in feed_batch: for feed in feed_batch:
int_slot = [] int_slot = []
float_slot = [] float_slot = []
...@@ -168,11 +169,14 @@ class Client(object): ...@@ -168,11 +169,14 @@ class Client(object):
if key not in self.feed_names_: if key not in self.feed_names_:
continue continue
if self.feed_types_[key] == int_type: if self.feed_types_[key] == int_type:
int_feed_names.append(key) if counter == 0:
int_feed_names.append(key)
int_slot.append(feed[key]) int_slot.append(feed[key])
elif self.feed_types_[key] == float_type: elif self.feed_types_[key] == float_type:
float_feed_names.append(key) if counter == 0:
float_feed_names.append(key)
float_slot.append(feed[key]) float_slot.append(feed[key])
counter += 1
int_slot_batch.append(int_slot) int_slot_batch.append(int_slot)
float_slot_batch.append(float_slot) float_slot_batch.append(float_slot)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册