Awesome Open Source
Awesome Open Source


It is the generic golden program for deep learning with TensorFlow.


Generate TFRecords

If your data is in CSV format, generate TFRecords like this.

cd ./data/cancer/


If your data is in LIBSVM format, generate TFRecords like this.

cd ./data/a8a/


For large dataset, you can use Spark to do that. Please refer to data.

Run Training

You can train with the default configuration.



Using different models or hyperparameters is easy with TensorFlow flags.

./ --batch_size 1024 --epoch_number 1000 --step_to_validate 10 --optmizier adagrad --model dnn --model_network "128 32 8"

If you use other dataset like iris, no need to modify the code. Just run with parameters to specify the TFRecords files.

./ --train_file ./data/iris/iris_train.csv.tfrecords --validate_file ./data/iris/iris_test.csv.tfrecords --feature_size 4 --label_size 3  --enable_colored_log

./ --train_file ./data/iris/iris_train.csv --validate_file ./data/iris/iris_test.csv --feature_size 4 --label_size 3 --input_file_format csv --enable_colored_log

If you want to use CNN model, try this command.

./ --train_file ./data/lung/fa7a21165ae152b13def786e6afc3edf.dcm.csv.tfrecords --validate_file ./data/lung/fa7a21165ae152b13def786e6afc3edf.dcm.csv.tfrecords --feature_size 262144 --label_size 2 --batch_size 2 --validate_batch_size 2 --epoch_number -1 --model cnn

For boston housing dataset.

./ --train_file ./data/boston_housing/train.csv.tfrecords --validate_file ./data/boston_housing/train.csv.tfrecords --feature_size 13 --label_size 1 --scenario regression  --batch_size 1 --validate_batch_size 1

Export The Model

After training, it will export the model automatically. Or you can export manually.

./ --mode savedmodel

Validate The Model

If we want to run inference to validate the model, you can run like this.

./ --mode inference

Use TensorBoard

The program will generate TensorFlow event files automatically.

tensorboard --logdir ./tensorboard/

Then go to in the browser.

Serving and Predicting

The exported model is compatible with TensorFlow Serving. You can follow the document and run the tensorflow_model_server.

./tensorflow_model_server --port=9000 --model_name=dense --model_base_path=./model/

We have provided some gRPC clients for dense and sparse models, such as Python predict client and Java predict client.

./ --host --port 9000 --model_name dense --model_version 1

mvn compile exec:java -Dexec.mainClass="com.tobe.DensePredictClient" -Dexec.args=" 9000 dense 1"


This project is widely used for different tasks with dense or sparse data.

If you want to make contributions, feel free to open an issue or pull-request.

Alternatives To Tensorflow_template_application
Select To Compare

Alternative Project Comparisons
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Python (806,114
Machine Learning (37,040
Deep Learning (36,421
Tensorflow (22,338
Csv (15,109
Convolutional Neural Networks (12,511
Lstm (5,528
Grpc (5,085
Tensorboard (1,329
Mlp (1,061
Libsvm (473
Tfrecords (63
Wide And Deep (21