0

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.)

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

right, got it. as you said, i re-wrote W as numpy tensor (W = W.eval()) within the session and returned from function call / fed into pandas.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.