Hi all,

I have a question about how to re-use Bayesian neural networks built with Edward.

I have built and trained a simple Bayesian neural network.

I imagine that I might want to re-use this model for analyses some time in the future. For example, I might want to save the model that I have built today, but re-use it in several months time to make predictions from a new data set that has become available.

I have saved the parameter set as follows:

saver = tf.train.Saver()

saver.save(sess, “path/fileForBayesianNeuralNetwork”)

I have re-loaded the parameter set in a new python script using the following code:

sess =tf.Session()

fname=“path/fileForBayesianNeuralNetwork”

loader = tf.train.import_meta_graph(fname+’.meta’)

loader.restore(sess,fname)

graph = tf.get_default_graph()

x_data = graph.get_tensor_by_name(“x_data:0”)

print(‘X:’,x_data)

q_W1_sample = graph.get_tensor_by_name(“q_W1/sample/Reshape:0”)

q_W1 = Normal(loc=graph.get_tensor_by_name(“q_W1/loc:0”),

scale=graph.get_tensor_by_name(“q_W1/scale:0”),

value=q_W1_sample)

q_B1_sample = graph.get_tensor_by_name(“q_B1/sample/Reshape:0”)

q_B1 = Normal(loc=graph.get_tensor_by_name(“q_B1/loc:0”),

scale=graph.get_tensor_by_name(“q_B1/scale:0”),

value=q_B1_sample)

q_W2_sample = graph.get_tensor_by_name(“q_W2/sample/Reshape:0”)

q_W2 = Normal(loc=graph.get_tensor_by_name(“q_W2/loc:0”),

scale=graph.get_tensor_by_name(“q_W2/scale:0”),

value=q_W2_sample)

q_B2_sample = graph.get_tensor_by_name(“q_B2/sample/Reshape:0”)

q_B2 = Normal(loc=graph.get_tensor_by_name(“q_B2/loc:0”),

scale=graph.get_tensor_by_name(“q_B2/scale:0”),

value=q_B2_sample)

I am not sure how I proceed from here to use the model for new predictions. Do I need to re-run the inference process with the re-loaded parameters, and will that involve creating a new and distinct model, or can I somehow re-used the saved model to make new predictions?

Many thanks for your assistance.