After training using tf.contrib.learn.DNNClassifier.fit how to export as protobuf to use in android?
I want to add this as exported to android. I know it is not very useful but I would still like to know.
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import tensorflow as tf
from tensorflow.contrib.layers import create_feature_spec_for_parsing
from tensorflow.contrib.learn.python.learn.utils import input_fn_utils
import numpy as np
import os
os.environ['TF_CPP_MIN_LOG_LEVEL']='2'
#===========================================================
training_set_data = np.array([[5.0,2.3,3.3,1.0],[4.9,2.5,4.5,1.7],[4.9,3.1,1.5,0.1],[6.9,3.1,5.1,2.3],[6.7,3.1,4.4,1.4],[5.1,3.7,1.5,0.4]], dtype=float)
training_set_target = np.array([1,2,0,2,1,0], dtype=int)
test_set_data = np.array([[5.9,3.0,4.2,1.5],[6.9,3.1,5.4,2.1],[5.1,3.3,1.7,0.5],[6.2,2.9,4.3,1.3],[5.5,4.2,1.4,0.2],[6.3,2.8,5.1,1.5]], dtype=float)
test_set_target = np.array([1,2,0,2,1,0], dtype=int)
#===========================================================
# Specify that all features have real-value data
feature_columns = [tf.contrib.layers.real_valued_column("", dimension=4)]
# Build 3 layer DNN with 10, 20, 10 units respectively.
classifier = tf.contrib.learn.DNNClassifier(feature_columns=feature_columns,hidden_units=[10, 20, 10],n_classes=3,model_dir="/tmp/iris_model")
# Fit model.
classifier.fit(x=training_set_data,y=training_set_target,steps=200)
# Evaluate accuracy.
accuracy_score = classifier.evaluate(x=test_set_data,y=test_set_target)["accuracy"]
print('Accuracy: {0:f}'.format(accuracy_score))
# Classify two new flower samples.
new_samples = np.array([[6.4, 3.2, 4.5, 1.5], [5.8, 3.1, 5.0, 1.7]], dtype=float)
y = list(classifier.predict(new_samples, as_iterable=True))
print('Predictions: {}'.format(str(y)))
#==========================================================
# CODE FROM HERE IS CAUSING ME ERROR. . . Frankly I dont understand this. . .
feature_columns = wide_columns + deep_columns
feature_spec = create_feature_spec_for_parsing(feature_columns)
serving_input_fn =input_fn_utils.build_parsing_serving_input_fn(feature_spec)
servable_model_dir = "/tmp/serving_savemodel"
servable_model_path=classifier.export_savedmodel(servable_model_dir,serving_input_fn)