title: How to examine the feature weights of a Tensorflow LinearClassifier?
body: <p>I am trying to understand the <a href="https://www.tensorflow.org/tutorials/linear" rel="nofollow noreferrer"><strong>Large-scale Linear Models with TensorFlow</strong></a> documentation. The docs motivate these models as follows:</p>
  
  <blockquote>
    <p>Linear model can be interpreted and debugged more easily than neural
    nets. <strong>You can examine the weights assigned to each feature</strong> to figure
    out what's having the biggest impact on a prediction.</p>
  </blockquote>
  
  <p>So I ran the extended code example from the accompanying <a href="https://www.tensorflow.org/tutorials/wide" rel="nofollow noreferrer"><strong>TensorFlow Linear Model Tutorial</strong></a>. In particular, I ran the <a href="https://github.com/tensorflow/tensorflow/blob/r1.3/tensorflow/examples/learn/wide_n_deep_tutorial.py" rel="nofollow noreferrer"><strong>example code from GitHub</strong></a> with the <code>model-type</code> flag set to <code>wide</code>. This correctly ran and produced <code>accuracy: 0.833733</code>, similar to the <code>accuracy: 0.83557522</code> on the Tensorflow web page.</p>
  
  <p>The example uses a <code>tf.estimator.LinearClassifier</code> to train the weights. However, in contrast to the quoted motivation of being able to examine the weights, I can't find any function to actually extract the trained weights in the <a href="https://www.tensorflow.org/api_docs/python/tf/estimator/LinearClassifier" rel="nofollow noreferrer"><strong>LinearClassifier documentation</strong></a>.</p>
  
  <p><strong>Question</strong>: how do I access the trained weights for the various feature columns in a <code>tf.estimator.LinearClassifier</code>? I'd prefer to be able to extract all the weights in a NumPy array.</p>
  
  <p><strong>Note</strong>: I am coming from an R environment where linear regression / classification models have a <code>coefs</code> method to extract learned weights. I want to be able to compare linear models in both R and TensorFlow on the same datasets. </p>