Sharing class objects in Tensorlfow
You can share final state that is one of the outputs of for example consider dynamic rnn. You get outputs,cell_final_state which you can share. You probably know about cell_final_state.c and cell_final_state.h. you can set that final state as initial state. lemme know if I cleared your question or not.
Just noticed it's such an old question. Hopefully helps future people.
TF has tf.variable_scope() that allows users to access tf.Variable() anywhere in the code. Basically every variable in TF is a global variable.
Is there a similar way to access class objects like tf.nn.rnn_cell.LSTMCell() or tf.layers.Dense()? To be more specific, can i create a new class object, let's say lstm_cell_2 (used for prediction) that uses the same weights and biases in lstm_cell_1 (used during training).
I am building an RNN to do language modeling. What i am doing right now is to return the lstm_cell_1 then pass it onto the prediction function. This works, but i want to in the end use separate tf.Graph() and tf.Session() for training, inference and prediction. Hence comes the problem of sharing Tensorflow objects.
Also, my lstm_cell is an instance of tf.nn.rnn_cell.MultiRNNCell() which doesn't take a name argument.
Thanks