首页 > 解决方案 > ValueError:输入张量必须至少具有 5 级(depthwise_conv2d)

问题描述

我正试图让这个 repo运行。

我发现这个github 问题尚未解决,也指出了我的问题。我正在使用 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

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

标签: pythontensorflowconvolution

解决方案


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


推荐阅读