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?
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With