This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HOW TO RUN IN TERMINAL: | |
# $ source tf_env_variables.sh | |
NVIDIA_DIR=$(dirname $(dirname $(python -c "import nvidia.cudnn;print(nvidia.cudnn.__file__)"))) | |
for dir in $NVIDIA_DIR/*; do | |
if [ -d "$dir/lib" ]; then | |
export LD_LIBRARY_PATH="$dir/lib:$LD_LIBRARY_PATH" | |
fi | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
# X, Y and Z are all watched variables, although they will produce a gradient (i.e. not None) only if the branch executed has uses that variable | |
with tf.GradientTape() as tape: | |
x = tf.Variable(5.0, dtype=tf.float32, name='X') | |
y = tf.Variable(6.0, dtype=tf.float32, name='Y') | |
z = tf.Variable(8.0, dtype=tf.float32, name='Z') | |
cond = tf.cond(pred = x < y, | |
true_fn = lambda: tf.add(x, z), |