I add print OP in GRU source code, and want to debug the input of GRU, and also want to debug with some operation inside GRU, But this print nothing. Dose tf.print don't work inside this source code of GRU. I hope someone can give me some suggesstion. Thank you very much!
def call(self, inputs, state):
"""Gated recurrent unit (GRU) with nunits cells."""
import tensorflow as tf
print_GRU = tf.print(inputs) #<<<<<<<<<<<<<<<<<< add print OP HERE
with tf.control_dependencies([print_GRU]):
gate_inputs = math_ops.matmul(
array_ops.concat([inputs, state], 1), self._gate_kernel)
# gate_inputs = math_ops.matmul(
# array_ops.concat([inputs, state], 1), self._gate_kernel)
gate_inputs = nn_ops.bias_add(gate_inputs, self._gate_bias)
value = math_ops.sigmoid(gate_inputs)
r, u = array_ops.split(value=value, num_or_size_splits=2, axis=1)
r_state = r * state
candidate = math_ops.matmul(
array_ops.concat([inputs, r_state], 1), self._candidate_kernel)
candidate = nn_ops.bias_add(candidate, self._candidate_bias)
c = self._activation(candidate)
new_h = u * state + (1 - u) * c
return new_h, new_h
Inside call
, use this line:
tf.py_function(func=tf.print, inp=[inputs], Tout=[])
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.