【问题标题】:ValueError: input tensor must have rank 5 at least (depthwise_conv2d)ValueError:输入张量必须至少具有 5 级(depthwise_conv2d)
【发布时间】:2021-01-04 08:10:46
【问题描述】:

我正在尝试让this repo 运行。

我发现这个github issue 还没有解决,也指出了我的问题。 我正在使用 Tensorflow 1.13.1(也尝试使用 1.14)和 python 3

我得到的错误是depthwise_conv2d:

 "input tensor must have rank %d at least" % (expected_input_rank))
 ValueError: input tensor must have rank 5 at least

检查我的张量时,我得到以下信息:

input tensor: Tensor("network/concat:0", shape=(?, 180, 270, 304), dtype=float32)

 filters: <tf.Variable 'network/slim_decoder/conv2d/weights:0' shape=(3, 3, 304, 1) dtype=float32_ref>

这里是函数的定义:

@add_arg_scope

 def depthwise_conv2d(

         inputs, filters, bias=None,

         strides=list([1, 1, 1, 1]), padding='SAME', dilations=list([1, 1, 1, 1]),

         to_batch_norm=False, batch_norm_decay=0.997, is_training=True, activation_fn=None, name=None

 ):

     if isinstance(strides, int):

         strides = list([1, strides, strides, 1])

     if isinstance(dilations, int):

         dilations = list([1, dilations, dilations, 1])

     print("input tensor: " + inputs)

     print("filters: " + filters)

     output = tf.nn.depthwise_conv2d(

         input=inputs,

         filter=filters,

         strides=strides,

         padding=padding,

         rate=dilations,

         name=name

     )
 
    if bias is not None:

         output = tf.nn.bias_add(output, bias)

     if to_batch_norm:

         output = batch_norm(output, is_training, batch_norm_decay)

     if activation_fn is not None:

         output = activation_fn(output)

     return output

我迷路了,感谢任何帮助,谢谢。

【问题讨论】:

    标签: python tensorflow convolution


    【解决方案1】:

    尝试将膨胀参数从 [1,1,1,1] 更改为 [1,1] tensorflow 除了 2 的列表。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-12-19
      • 2021-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多