我正在尝试将具有以下属性的张量写入 PNG 文件。
type(adv_x)
<class 'tensorflow.python.framework.ops.EagerTensor'>
adv_x.shape
(1, 600, 800, 3)
tf.rank(adv_x)
tf.Tensor(4, shape=(), dtype=int32)
Run Code Online (Sandbox Code Playgroud)
我知道如何将张量显示为图像 ( plt.imshow(adv_x[0])),但我想将其写入文件,以便最终得到 600 x 800 像素的 RGB .PNG 文件。
提前致谢。