我正在尝试创建一个自动编码器解码器框架。 下面是我正在使用的代码
# Define convolution layers
def conv(layer_name, input_X, shape, strides, padding = "SAME"):
with tf.variable_scope(layer_name):
W = tf.get_variable("W", shape = shape, dtype=tf.float32)
return tf.nn.conv2d(input_X, W, strides, padding), W
# Layer1 convolution
encoder_layer1, W1 = conv("encode_layer1", X, [28, 28, 1, 10], [2,2,2,2])
我遇到以下错误
InvalidArgumentError (see above for traceback): Current implementation does not yet support strides in the batch and depth dimensions.
[[Node: encode_layer1/Conv2D = Conv2D[T=DT_FLOAT, data_format="NHWC", dilations=[1, 1, 1, 1], padding="SAME", strides=[2, 2, 2, 2], use_cudnn_on_gpu=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_X_0_0, encode_layer1/W/read)]]
答案 0 :(得分:1)
必须具有跨度[0] =跨度[3] =1。对于相同水平跨度和顶点跨度的最常见情况,跨度= [1,stride,stride,1]。
strides [0]是批处理尺寸,strides [3]是通道(或深度)尺寸。
尝试将步幅设置为[1、2、2、1]。