GithubHelp home page GithubHelp logo

douban / fast_tffm Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kopopt/fast_tffm

3.0 13.0 3.0 6.47 MB

fast_tffm: Tensorflow-based Distributed Factorization Machine

License: Apache License 2.0

CMake 4.07% C++ 35.33% Python 59.70% Cuda 0.90%

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

Build

python setup.py build_ext -i

Local Training

python run_tffm.py train sample.cfg [-m] [-t trace_file_name]

for CPU version, use

CUDA_VISIBLE_DEVICES=-1 python ...

Distributed Training

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

python run_tffm.py train sample.cfg --dist ps 0 localhost:2333,localhost:2334 localhost:2335,localhost:2336
python run_tffm.py train sample.cfg --dist ps 1 localhost:2333,localhost:2334 localhost:2335,localhost:2336
python run_tffm.py train sample.cfg --dist worker 0 localhost:2333,localhost:2334 localhost:2335,localhost:2336
python run_tffm.py train sample.cfg --dist worker 1 localhost:2333,localhost:2334 localhost:2335,localhost:2336

Local Prediction

python run_tffm.py predict sample.cfg

Distributed Prediction (not supported by most recent update)

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

python run_tffm.py predict sample.cfg --dist ps 0 localhost:2333,localhost:2334 localhost:2335,localhost:2336
python run_tffm.py predict sample.cfg --dist ps 1 localhost:2333,localhost:2334 localhost:2335,localhost:2336
python run_tffm.py predict sample.cfg --dist worker 0 localhost:2333,localhost:2334 localhost:2335,localhost:2336
python run_tffm.py predict sample.cfg --dist worker 1 localhost:2333,localhost:2334 localhost:2335,localhost:2336

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.

Run with TFMesos

tfrun -w 4 -s 1 -m ${MESOS_MASTER} -- python run_tffm.py [train, predict] sample.cfg --dist_train {job_name} {task_index} {ps_hosts} {worker_hosts}

Export Model to Saved_Model_CLI

To generate a new model (export path must not be a pre-existing directory):

python run_tffm.py generate sample.cfg --export_path saved_model

To use the model for prediction:

saved_model_cli run --dir /home2/libingqing/fast_tffm/saved_model_simplified/ --tag_set serve --signature_def serving_default --inputs data_lines=data.npy --outdir=./scores

For detailed instructions on using SavedModel CLI, refer to TensorFlow official documentation.

Tensorboard Visualization

Set the empty log directory path in sample.cfg. The default log saving frequency is 10 global steps per save.

Saving content includes RMSE and total RMSE of training and validation data over the last 10 steps.

Find the directory of your tensorflow then use the following command to activate tensorboard:

python .../site-packages/tensorflow/tensorboard/tensorboard.py --logdir==your_log_dir

The default port is 6060.

fast_tffm's People

Contributors

kopopt avatar snnn avatar sybil-li avatar windreamer avatar

Stargazers

 avatar  avatar  avatar

Watchers

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

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.