+3 votes

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],
  # 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.

asked by anonymous

Please log in or register to answer this question.

619 questions
626 answers
373 users