Git Product home page Git Product logo

fast_tffm's Introduction

Tensorflow-based Distributed Factorization Machine

An efficient distributed factoriazation machine implementation based on tensorflow (cpu only).

  1. Support both multi-thread local machine training and distributed training.
  2. Can easily benefit from numerous implementations of operators in tensorflow, e.g., different optimizors, loss functions.
  3. Customized c++ operators, significantly faster than pure python implementations. Comparable performance (actually faster according to my benchmark) with pure c++ implementation.

Quick Start

Compile

mkdir build
cd build
cmake ../
make
make test
cd ..

Local Training

python fast_tffm.py train sample.cfg

Distributed Training

Open 4 command line windows. Run the following commands on each window to start 2 parameter servers and 2 workers.

python fast_tffm.py dist_train sample.cfg ps 0
python fast_tffm.py dist_train sample.cfg ps 1
python fast_tffm.py dist_train sample.cfg worker 0
python fast_tffm.py dist_train sample.cfg worker 1

Local Prediction

python fast_tffm.py predict sample.cfg

Distributed Prediction

Open 4 command line windows. Run the following commands on each window to start 2 parameter servers and 2 workers.

python fast_tffm.py dist_predict sample.cfg ps 0
python fast_tffm.py dist_predict sample.cfg ps 1
python fast_tffm.py dist_predict sample.cfg worker 0
python fast_tffm.py dist_predict sample.cfg worker 1

Benchmark

  1. Local Mode. Training speed compared with difacto using the same configuration
  • Configuration: 36672494 training examples, 10 threads, factor_num = 8, batch_size = 10000, epoch_num = 1, vocabulary_size = 40000000
  • Difacto: 337 seconds. 108820 examples / second.
  • FastTffm: 157 seconds. 233582 examples / second.
  1. Distriubuted Mode. (I did not find other open source projects which support distributed training. Difacto claims so, but their distributed mode is not implemeted yet)
  • Configuration: 36672494 training examples, 10 threads, factor_num = 8, batch_size = 10000, epoch_num = 1, vocabulary_size = 40000000
  • Cluster: 1 ps, 4 workers.
  • FastTffm: 49 seconds. 748418 examples / second.

Input Data Format

  1. Data File
<label> <fid_0>[:<fval_0>] [<fid_1>[:<fval_1>] ...]

<label>: 0 or 1 if loss_type = logistic; any real number if loss_type = mse.

<fid_k>: An integer if hash_feature_id = False; Arbitrary string if hash_feature_id = True

<fval_k>: Any real number. Default value 1.0 if omitted.

  1. Weight File Should have the same line number with the corresponding data file. Each line contains one real number.

Check the data/weight files in the data folder for details. The data files are sampled from criteo lab dataset.

fast_tffm's People

Contributors

kopopt avatar snnn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fast_tffm's Issues

canot run

my tensorflow's version is 0.9, and when i command python fast_tffm.py train sample.cfg , the .py cant run. its bug info as below.

Traceback (most recent call last):
File "fast_tffm.py", line 2, in
from py.fm_ops import fm_ops
File "/root/wyb/tensorflow_benchmark/fast_tffm/fast_tffm-master/py/fm_ops.py", line 5, in
fm_ops = tf.load_op_library(os.path.dirname(os.path.realpath(file)) + '/../lib/libfast_tffm.so')
File "/usr/local/python2.7/lib/python2.7/site-packages/tensorflow/python/framework/load_library.py", line 71, in load_op_library
raise errors._make_specific_exception(None, None, error_msg, error_code)
tensorflow.python.framework.errors.NotFoundError: /root/wyb/tensorflow_benchmark/fast_tffm/fast_tffm-master/py/../lib/libfast_tffm.so: undefined symbol: _ZN10tensorflow8internal21CheckOpMessageBuilder9NewStringEv

how to modify souce code to support 0.9?

Is it actually using GPU?

Hi thank you very much for this great software! When I run the python fast_tffm.py train sample.cfg, I saw there is some GPU usage. So does this fm actually run on GPU despite that README says it is CPU-only?

Multinomial logloss

Can you use this library to predict multiple classes? The readme hints that you can only predict two classes.

Also, the documentation says that the default value of a missing feature is 1.0. Shouldn't it be 0?

Thanks!

how to get this results?

@kopopt
Hi,

According to the instructions

I am wondering how to get this result with distributed Tensorflow:
" Configuration: 36672494 training examples, 10 threads, factor_num = 8, batch_size = 10000, epoch_num = 1, vocabulary_size = 40000000
Cluster: 1 ps, 4 workers.
FastTffm: 49 seconds. 748418 examples / second."

Could you provide the dataset and detail running instructions?
Recently, we have a distributed version of RDMAable-Tensorflow and we would like to evaluated RDMA-based Tensorflow with this benchmark. Any help wolud be greatly appreciated! Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.