问题
here there is my code: https://github.com/Franco7Scala/RestrictedAreaImageAdversarialAttack/tree/master/src You should see test_attack.py and l2_attack.py.
Now we can go to the problem, in this place of l2_attack-py:
mask = tf.ones((batch_size, image_size, image_size, num_channels), tf.float32)
# Get input shapes
modifier_shape = tf.shape(modifier)
mask_shape = tf.shape(mask)
# Make indices grid
oo, ii, jj, kk = tf.meshgrid(tf.range(modifier_shape[0]), tf.range(modifier_shape[1]), tf.range(modifier_shape[2]), tf.range(modifier_shape[3]), indexing='ij')
# Shift indices
ii += y_window
jj += x_window
# Scatter update
mask_to_apply = tf.tensor_scatter_nd_update(mask, tf.stack([oo, ii, jj, kk], axis=-1), modifier)
tf.print(mask_to_apply)
when I do tf.print(mask_to_apply)
I have this output: Tensor("TensorScatterUpdate:0", shape=(9, 28, 28, 1), dtype=float32)
and not he values inside the tensor, How can I print these values?
来源:https://stackoverflow.com/questions/60670157/problem-with-tf-print-for-tensor-unable-to-print-single-values