Sign up to take part
Registered users can ask their own questions, contribute to discussions, and be part of the Community!
Added on August 18, 2017 10:53AM
Likes: 3
Replies: 1
To use the tensorflow in the custom python model, the code needs to provide the methods fit() and predict(), like SK-Learn.
The code below is the code that I think I need to use.
import tensorflow as tf
# 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")
# Define the training inputs
def get_train_inputs():
x = tf.constant(training_set.data)
y = tf.constant(training_set.target)
return x, y
# Fit model.
classifier.fit(input_fn=get_train_inputs, steps=2000)
What I think the problem is, I need to change the input into tf.constant and send them to the fit method.
But I have no idea how the data is retrieved or the variable name that is used in the fit method.
Does anyone have a sample code, or know the walk away round?
I am new to python, ML, DDS everything so please help.