TensorFlow supervisor prevents variable assignment: Graph is finalized and cannot be modified
By : Xander
Date : March 29 2020, 07:55 AM
To fix this issue Just as the error says, you cannot modify the graph when the graph is finalized. code :
# The graph is not allowed to change anymore.
graph.finalize()

Saving predicted tensor to image in TensorFlow  Graph finalized
By : aman
Date : March 29 2020, 07:55 AM
Any of those help for everyone with the same problem here is my solution. I don't know if this is the proper way but it works. In my predict function i created a second graph for the reshaping, slicing, encoding and saving like: code :
pred_dict = eval_results.next() #generator the predict function returns
preds = pred_dict["y"] #get the predictions from the dict
#create the second graph
g = tf.Graph()
with g.as_default():
inp = tf.Variable(preds)
reshape1 = tf.reshape(printnode, [IM_WIDTH, IM_HEIGHT, 1])
sliced = tf.slice(reshape1, [0,0,0], [ IM_WIDTH, IM_HEIGHT,1])
reshaped = tf.reshape(sliced, [IM_HEIGHT, IM_WIDTH, 1])
encoded = tf.image.encode_png(tf.image.convert_image_dtype(reshaped,tf.uint16))
outputfile = tf.write_file("/tmp/pred_output/prediction_img.png", encoded)
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
sess.run(outputfile)

Tensorflow: Graph is finalized and cannot be modified
By : Peter Chen
Date : March 29 2020, 07:55 AM
wish helps you It appears that in your case distances is a tensor and calling distances[0] attempts to create an array_slice operation on a finalized graph. The right way of handling that would be to feed distances tensor to your distances_np = session.run(distances) or call distances_np = distances.eval() providing necessary parameters to acquire some sort of numpy array and only then do indexing and/or printing on distances_np.

Getting "Graph is finalized and cannot be modified" during evaluation for pretrained RPN
By : user2657964
Date : March 29 2020, 07:55 AM
I hope this helps . I found what was causing the problem. The estimator runs training then evaluation. During training we load the pretrained weights, then after training, a checkpoint is created. The weights are then loaded from the checkpoint for evaluation at which point the weights are locked (for good reason). But then I was trying to load the weights on top of the frozen model, hence the issue.

Tensorflow : Graph is finalized and cannot be modified
By : ken_newbie
Date : March 29 2020, 07:55 AM
will be helpful for those in need The root cause for your error seems to be that MonitoredTrainingSession has finalized (frozen) the graph and your tf.global_variable_initializer() is no longer able to modify it. Having said that, there are multiple things that require attention:

