Problem with tf.print for tensor (unable to print single values)

ε祈祈猫儿з 提交于 2020-03-25 13:47:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!