Skip to content

Commit 5439edf

Browse files
committed
demo
1 parent 2eef4e2 commit 5439edf

16 files changed

+63
-58
lines changed

README.md

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,35 @@ cmake ..
2121
make
2222
```
2323

24-
# Demo
24+
# Simple Demo
25+
This demo used `c=a+b` to show how to save the model and load it using C++ for prediction. [tensorflow_c++_api_prediction_basic](http://mathmach.com/2017/10/09/tensorflow_c++_api_prediction_basic/)
26+
```bash
27+
cd demo/simple_model
28+
# train
29+
sh train.sh
30+
# predict
31+
sh predict.sh
32+
```
2533

26-
## Transform text file into TFRecord
34+
# Deep CTR Model Demo
35+
This demo show a real-wrold deep model usage in click through rate prediction. [tensorflow_c++_api_prediction_advance](http://mathmach.com/2017/10/11/tensorflow_c++_api_prediction_advance/)
36+
37+
## Transform LibFM data into TFRecord
38+
* LibFM format: `label fieldId:featureId:value ...`
2739
```bash
28-
cd demo
40+
cd demo/deep_model
2941
sh trans_data_to_tfrecord.sh
3042
cd ..
3143
```
3244

3345
## Train model
3446
```bash
35-
cd demo
3647
sh train.sh
37-
cd ..
3848
```
3949

4050
## Predict using C++
4151
```bash
42-
cd demo
43-
sh test.sh
44-
cd ..
52+
sh predict.sh
4553
```
4654

4755
# Reference
File renamed without changes.

demo/freeze_graph.sh renamed to demo/deep_model/freeze_graph.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
# --output_node_names=cross_entropy
1212
#cd -
1313

14-
python ../python/freeze_graph.py \
15-
--model_dir=./model \
14+
python ../../python/freeze_graph.py \
15+
--model_dir=./saved_model \
1616
--output_node_names=Softmax

demo/deep_model/predict.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
# TODO

demo/deep_model/train.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env bash
2+
3+
python ../../python/train.py \
4+
--dict "./data/dict.data" \
5+
--continuous_fields "" \
6+
--sparse_fields "9,6,116" \
7+
--linear_fields "152,179" \
8+
--train_file "./data/libfm.tfrecord" \
9+
--valid_file "./data/libfm.tfrecord"
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
# generate field dict
4+
python ../../python/dict.py \
5+
'0' \
6+
'9,6,116' \
7+
'152,179' \
8+
./data/libfm.data \
9+
./data/dict.data
10+
11+
# transform libfm data into tfrecord
12+
python ../../python/data.py \
13+
./data/dict.data \
14+
'0' \
15+
'9,6,116' \
16+
'152,179' \
17+
./data/libfm.data \
18+
./data/libfm.tfrecord

demo/simple_model/predict.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
../../bin/simple_model.bin "./saved_model/graph.pb"

demo/simple_model/train.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
python ../../python/simple_model.py

demo/train.sh

Lines changed: 0 additions & 9 deletions
This file was deleted.

demo/trans_data_to_tfrecord.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)