Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在Tensorflow中使用conv1d_转置?_Python_Tensorflow_Machine Learning_Convolution_Convolutional Neural Network - Fatal编程技术网

Python 如何在Tensorflow中使用conv1d_转置?

Python 如何在Tensorflow中使用conv1d_转置?,python,tensorflow,machine-learning,convolution,convolutional-neural-network,Python,Tensorflow,Machine Learning,Convolution,Convolutional Neural Network,conv1d_转置尚未在Tensorflow的稳定版本中,但有一个实现 我想创建一个一维反褶积网络。输入的形状是[-1,256,16],输出应该是[-11024,8]。内核的大小是5,步幅是4 我尝试用这个函数构建一个1D卷积层: (output_depth, input_depth) = (8, 16) kernel_width = 7 f_shape = [kernel_width, output_depth, input_depth] layer_1_fil

conv1d_转置
尚未在Tensorflow的稳定版本中,但有一个实现

我想创建一个一维反褶积网络。输入的形状是
[-1,256,16]
,输出应该是
[-11024,8]
。内核的大小是5,步幅是4

我尝试用这个函数构建一个1D卷积层:

    (output_depth, input_depth) = (8, 16)
    kernel_width = 7
    f_shape = [kernel_width, output_depth, input_depth]
    layer_1_filter = tf.Variable(tf.random_normal(f_shape))

    layer_1 = tf_exp.conv1d_transpose(
        x,
        layer_1_filter,
        [-1,1024,8],
        stride=4, padding="VALID"
    )
层1
的形状是
张量形状([尺寸(无)、尺寸(无)、尺寸(无)]
,但它应该是
[-11024,8]


我错了什么?如何在Tensorflow中实现1D反褶积?

此时pull请求已打开,因此API和行为可能会改变。不支持
conv1d\u transpose
的某些功能:

  • output_shape
    要求静态知道批量大小,不能通过
    -1
  • 另一方面,输出形状是动态的(这解释了
    None
    dimension)
另外,
内核的宽度=7
要求
在宽度=255
中,而不是
256
。应使
kernel\u width
小于
4
以匹配
in\u width=256
。结果是这个演示代码:

x = tf.placeholder(shape=[None, 256, 16], dtype=tf.float32)
filter = tf.Variable(tf.random_normal([3, 8, 16]))    # [kernel_width, output_depth, input_depth]
out = conv1d_transpose(x, filter, output_shape=[100, 1024, 8], stride=4, padding="VALID")

with tf.Session() as sess:
  sess.run(tf.global_variables_initializer())
  result = sess.run(out, feed_dict={x: np.zeros([100, 256, 16])})
  print(result.shape)  # prints (100, 1024, 8)
新的已添加到