def print_tensor_summary(tensor, tag=None, n_print=21):
tensor_min = tf.reduce_min(tensor)
tensor_max = tf.reduce_max(tensor)
tensor_avg = tf.reduce_mean(tensor)
tensor_zero_fraction = tf.nn.zero_fraction(tensor)
tensor_shape = tf.shape(tensor)
tag = tag or tensor.name
tensor = tf.Print(tensor,
[tensor_min, tensor_max, tensor_avg, tensor_zero_fraction, tensor_shape, tensor],
message=(tag + ' Min, max, mean, sparsity, shape, value:'),
summarize=n_print)
return tensor
评论列表
文章目录