alanyuchenhou / elephant

MIT License
3 stars 5 forks source link

node embedding extraction #40

Closed alanyuchenhou closed 7 years ago

alanyuchenhou commented 7 years ago

problem

38 requires node embedding extraction, but the original model doesn't allow easy access to the embedding.

observation

For this extraction, the model has to expose lower level operations. There're 2 monitors that can facilitate this:

approach

Try to log the embedding either as variable or as tensor using the 2 monitors.

reference

https://www.tensorflow.org/get_started/monitors#configuring_a_validationmonitor_for_streaming_evaluation

alanyuchenhou commented 7 years ago

I've been experimenting with Monitor and trying to get it to work following this reference on monitors. That reference has some obsolete code which produces error; the latest code is in the official repo

In my experiments, the monitor did log data in checkpoints, but unfortunately Tensorboard couldn't read the data logged by the monitor. I've been searching for relevant discussions online, trying to figured out why that reference doesn't not work for me as stated. I have found a relevant issue in the official repo about a pending update on the ValidationMonitor. It mentioned a alternative and temporary solution with SessionRunHook. I'll take a look at that solution.

alanyuchenhou commented 7 years ago

The final working solution is based on https://www.tensorflow.org/get_started/embedding_viz . One caveat is

embedding.tensor_name = embedding_var.name

should be replaced with

embedding.tensor_name = 'dnn/input_from_feature_columns/' + attribute + '_embedding/weights:0'

because the tensors are not explicit variable like embedding_var but implicit variable.