MCPcopy
hub / github.com/tobegit3hub/tensorflow_template_application

github.com/tobegit3hub/tensorflow_template_application @main sqlite

repository ↗ · DeepWiki ↗
129 symbols 412 edges 56 files 36 documented · 28%
README

Introduction

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

Usage

Generate TFRecords

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

cd ./data/cancer/

./generate_csv_tfrecords.py

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

cd ./data/a8a/

./generate_libsvm_tfrecord.py

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

Run Training

You can train with the default configuration.

./dense_classifier.py

./sparse_classifier.py

Using different models or hyperparameters is easy with TensorFlow flags.

./dense_classifier.py --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.

./dense_classifier.py --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

./dense_classifier.py --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.

./dense_classifier.py --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.

./dense_classifier.py --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.

./dense_classifier.py --mode savedmodel

Validate The Model

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

./dense_classifier.py --mode inference

Use TensorBoard

The program will generate TensorFlow event files automatically.

tensorboard --logdir ./tensorboard/

Then go to http://127.0.0.1:6006 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.

./predict_client.py --host 127.0.0.1 --port 9000 --model_name dense --model_version 1

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

Contribution

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.

Core symbols most depended-on inside this repo

addInput
called by 7
golang_predict_client/src/util.go
full_connect_relu
called by 5
dense_classifier_use_queue.py
full_connect_relu
called by 5
model.py
Predict
called by 5
minimal_model/python_predict_client/prediction_service_pb2.py
full_connect
called by 4
dense_classifier_use_queue.py
inference
called by 4
dense_classifier_use_queue.py
inference
called by 4
sparse_classifier.py
inference
called by 4
dense_classifier.py

Shape

Function 97
Method 21
Class 11

Languages

Python81%
Java15%
Go4%

Modules by API surface

dense_classifier_use_queue.py15 symbols
model.py13 symbols
minimal_model/python_predict_client/prediction_service_pb2.py11 symbols
sparse_model.py7 symbols
java_predict_client/src/main/java/com/tobe/client/SparsePredictClient.java6 symbols
java_predict_client/src/main/java/com/tobe/client/DensePredictClient.java6 symbols
http_service/cancer_predict/views.py6 symbols
dense_classifier.py5 symbols
sparse_classifier.py4 symbols
minimal_model/python_predict_client/benchmark_qps.py4 symbols
util.py3 symbols
golang_predict_client/src/predict_client.go3 symbols

Dependencies from manifests, versioned

com.google.protobuf:protobuf-java3.0.0 · 1×
com.xiaomi.infra.galaxy:galaxy-hadoop1.8-SNAPSHOT · 1×
io.grpc:grpc-netty1.0.0 · 1×
io.grpc:grpc-protobuf1.0.0 · 1×
io.grpc:grpc-stub1.0.0 · 1×
junit:junit4.13.1 · 1×
org.apache.hadoop:hadoop-client
org.apache.spark:spark-core_2.101.6.1-mdh1.6.1.2 · 1×
org.apache.spark:spark-sql_2.101.6.1-mdh1.6.1.2 · 1×
org.scala-lang:scala-library2.10.5 · 1×
org.scalatest:scalatest_2.102.2.0 · 1×
org.tensorflow:tensorflow-hadoop1.0-SNAPSHOT · 1×

For agents

$ claude mcp add tensorflow_template_application \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact