使用 tf.pad() 填充 MNIST 数据集

Ank*_*ava 3 python-3.x tensorflow tensorflow-datasets

如何填充 MNIST 数据集图像的大小(?,28,28,1)并将tf.pad()其放入(?,32,32,1)张量流中?

Max*_*Max 5

这取决于你打算如何填充它。例子是这样的:

# Assuming input is a tensor with shape (?, 28, 28, 1)
output = tf.pad(input, [[0, 0], [2,2], [2,2], [0,0]])
# print(tf.shape(output)) should be (?, 32, 32, 1)
Run Code Online (Sandbox Code Playgroud)