Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert placeholder to constant in TensorFlow

Tags:

tensorflow

I'm training neural networks in TensorFlow for use in a Java application. The graphs are written to a pb file using freeze_graph.py.

However, there are a number of placeholders in the graph that are used to hold dropout layer keep probabilities. I would like to convert these to constants (=1.0) when writing the graph, as then I don't need to worry about feeding these values when using the network in the Java application.

Is it possible to convert a placeholder into a constant?

like image 555
geometrikal Avatar asked Jun 01 '17 14:06

geometrikal


People also ask

What is the constant placeholder?

A constant does not change its value during its lifetime (not just a session ). Once defined (during programming), it's fixed at that. A placeholder on the other hand, does not indicate any value during graph definition (programming), but gets its value fed in at the time of session run start.

What is TensorFlow placeholder?

A placeholder is a variable in Tensorflow to which data will be assigned sometime later on. It enables us to create processes or operations without the requirement for data. Data is fed into the placeholder as the session starts, and the session is run. We can feed in data into tensorflow graphs using placeholders.


1 Answers

The thing closer to what you want is a placeholder_with_default. It is a placeholder that takes a default value when not fed.

You can either feed it with the value you want, or just forget about it and let it take the value you specified as a default.

like image 67
P-Gn Avatar answered Oct 15 '22 07:10

P-Gn