ValueError:输入张量必须至少具有等级5depthwise_conv2d

问题描述

我正在尝试运行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]),padding='SAME',dilations=list([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,1])

     if isinstance(dilations,int):

         dilations = list([1,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

我迷路了,不胜感激,谢谢。

解决方法

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