In this gist, we first defines a function f0
, then construct the computation graph of from the first to the fourth derivative by calling diff
function from Owl's Algorithmic Differentiation module. This computation graph is then passed to Tensorflow for executation.
This is a recreation of a exsiting Owl AD module example. See the doc for more details.
- Step 1 : running OCaml script
tf_convert_diff.ml
, which generates a filetf_convert_diff.pbtxt
in current directory. - Step 2 : make sure
tf_convert_diff.pbtxt
andtf_convert_diff.py
in the same graph; make sure Tensorflow/numpy etc. is installed. - Step 3 : execute
python tf_convert_diff.py
, and the expected output is a saved imagetf_convert_diff.png
in the current directory.
Here we only assume the python script writer knows where to find the output node (in collection "result") and the placeholder names (x
).
There could be many posssible source of error at this stage, one of which could be incompatible tensorflow version; in that case,
probably find this line in test_cgraph.pbtxt : tensorflow_version: "1.12.0"
and then change the version number.
Also, Tensorflow may yield some warning messages about version/dataset etc.
Current scripts may also ignore some factors like file/directory location.
Expected output image: