title: how to save a DNN model with tensorflow
body: <p>I have code that trains a DNN network. I don't want to train this network every time, because it uses too much time. How can I save the model?</p>
  
  <pre><code>def train_model(filename, validation_ratio=0.):
      # define model to be trained
      columns = [tf.contrib.layers.real_valued_column(str(col),
                                                      dtype=tf.int8)
                 for col in FEATURE_COLS]
      classifier = tf.contrib.learn.DNNClassifier(
          feature_columns=columns,
          hidden_units=[100, 100],
          n_classes=N_LABELS,
          dropout=0.3)
  
      # load and split data
      print( 'Loading training data.')
      data = load_batch(filename)
      overall_size = data.shape[0]
      learn_size = int(overall_size * (1 - validation_ratio))
      learn, validation = np.array_split(data, [learn_size])
      print( 'Finished loading data. Samples count = {}'.format(overall_size))
  
      # learning
      print( 'Training using batch of size {}'.format(learn_size))
      classifier.fit(input_fn=lambda: pipeline(learn),
                     steps=learn_size)
  
      if validation_ratio &gt; 0:
          validate_model(classifier, learn, validation)
  
      return classifier
  </code></pre>
  
  <p>After running this function, I get a <code>DNNClassifier</code> which I want to save.</p>