lmart999
lmart999

Reputation: 7081

TensorFlow tensor to Pandas dataframe

My model learns W:

W = tf.Variable(tf.truncated_normal([pixels,h1],stddev=np.sqrt(2.0 / (pixels))))

I return W from a function that runs my TF graph / session.

In my notebook, I checked type of W:

type(W)
out: tensorflow.python.ops.variables.Variable

I also checked dimensionality of W:

W.get_shape()
out: TensorShape([Dimension(3072), Dimension(1024)])

I'd like to convert W into a Pandas dataframe (for examination, etc.).

How can I do this?

(Saw this answer on converting tensor to numpy with eval(), which could then be written to pandas of course. But that operation only seemed to work within the TF session.)

Upvotes: 0

Views: 6682

Answers (1)

Hugh Perkins
Hugh Perkins

Reputation: 8622

variables only exist within a session. they are defined in the graph, as operations, but dont actually store any values as such, in the graph . they only have values when a session is created from the graph, and initialize operation called (or load is called).

Of course, once you've loaded the value from the varaible, in a session, using eval, you're free to dispose of the session, and use the resulting numpy tensor jsut as any normal numpy tensor.

Upvotes: 1

Related Questions