How do I use DNNEstimator from tensorflow?

FixIT21 report abuse

When researching which algorithm to use in the text classification I stumbled upon usage of DNNClassifier. As I understand it is different from text classifiers from nltk. I already have my text embedded, but can`t quite figure what is the 'input_fn' argument passed to fit function. What is this function and how do I use DNNClassifier properly?

Answers

CarlosCV report abuse __ edited

input_fn is a function where you convert your data to 'tf.data.Dataset' and configure how your data is served to the model (shuffling, repeats, etc.).

Here's an example how can it be defined:

def train_input_fn(): 
dataset = tf.data.Dataset.from_tensor_slices((dict(x_train), y_train)) 
dataset = dataset.shuffle(1000).repeat().batch(10) 
return dataset

You can find out more in this article: https://medium.com/datadriveninvestor/tensorflow-dnnclassifier-4e68df3df00

Hope, that helps. Cheers.

Add Answer

Need support?

Just drop us an email to ... Show more