Skip to content

Commit c2359a2

Browse files
committed
second ci
1 parent f68b3a4 commit c2359a2

13 files changed

+176
-461
lines changed

CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
3+
project(deep-ctr)
4+
5+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fopenmp -msse2 -fPIC -O3 -ggdb -Wall -finline-functions")
6+
7+
message(STATUS "CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
8+
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
9+
10+
# Add Subdirectory
11+
add_subdirectory(src)

README.md

+49
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,51 @@
11
# deep-ctr
22
deep models for click through rate prediction
3+
4+
# Build
5+
6+
## Build TensorFlow
7+
Follow the instruction [build tensorflow from source](https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/makefile)
8+
```bash
9+
git clone --recursive https://github.com/tensorflow/tensorflow.git
10+
cd tensorflow
11+
sh tensorflow/contrib/makefile/build_all_ios.sh (depends on your platform)
12+
cd ..
13+
```
14+
15+
## Build deep-ctr
16+
```bash
17+
git clone https://github.com/formath/deep-ctr.git
18+
cd deep-ctr
19+
mkdir build && cd build
20+
cmake ..
21+
make
22+
```
23+
24+
# Demo
25+
26+
## Transform text file into TFRecord
27+
```bash
28+
cd demo
29+
sh trans_data_to_tfrecord.sh
30+
cd ..
31+
```
32+
33+
## Train model
34+
```bash
35+
cd demo
36+
sh train.sh
37+
cd ..
38+
```
39+
40+
## Predict using C++
41+
```bash
42+
cd demo
43+
sh test.sh
44+
cd ..
45+
```
46+
47+
# Reference
48+
* [Loading a TensorFlow graph with the C++ API](https://medium.com/jim-fleming/loading-a-tensorflow-graph-with-the-c-api-4caaff88463f)
49+
* [Loading a tensorflow graph with the C++ API by using Mnist](http://jackytung8085.blogspot.jp/2016/06/loading-tensorflow-graph-with-c-api-by.html)
50+
* [Tensorflow Different ways to Export and Run graph in C++](https://stackoverflow.com/questions/35508866/tensorflow-different-ways-to-export-and-run-graph-in-c/43639305#43639305)
51+

data.py

-160
This file was deleted.

test/libfm.data demo/libfm.data

File renamed without changes.

demo/test.py

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import tensorflow as tf
2+
import numpy as np
3+
4+
with tf.Session() as sess:
5+
a = tf.Variable(5.0, name='a')
6+
b = tf.Variable(6.0, name='b')
7+
c = tf.multiply(a, b, name="c")
8+
9+
sess.run(tf.global_variables_initializer())
10+
11+
print(a.eval()) # 5.0
12+
print(b.eval()) # 6.0
13+
print(c.eval()) # 30.0
14+
15+
tf.train.write_graph(sess.graph_def, 'model', 'graph.pb', as_text=False)

test/train.sh demo/train.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22

3-
python ../train.py \
3+
python ../python/train.py \
44
--dict dict.data \
55
--continuous_fields "" \
66
--sparse_fields "9,6,116" \

demo/trans_data_to_tfrecord.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
# generate field dict
4+
python ../python/dict.py '0' '9,6,116' '152,179' libfm.data dict.data
5+
6+
# transform libfm data into tfrecord
7+
python ../python/data.py dict.data '0' '9,6,116' '152,179' libfm.data libfm.tfrecord

dict.py

-68
This file was deleted.

0 commit comments

Comments
 (0)