python - 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
我迷路了,感谢任何帮助,谢谢。
解决方案
尝试将扩张参数从 [1,1,1,1] 更改为 [1,1] tensorflow,除了 2 的列表。
推荐阅读
- javascript - Javascript 在新行上打印
- python - 使用 python 计算数据增强以进行深度学习时内存崩溃
- php - 无法从供应商加载 mailgun 类
- nsis - 如何使用 NSIS 将注册表值从以前版本的安装程序导出和导入到当前版本的安装程序
- flutter - Flutter - 如何从另一个小部件重建未来的小部件
- loops - 使用“rvest”进行多链接网页抓取。错误参数意味着不同的行数
- xpath - 如何根据之前 HTML 类中的文本抓取内容
- python - python中的简单蒙特卡罗模拟
- angular - 如何为 Angular“@ckeditor/ckeditor5-angular”添加插件到 CKEditor?
- javascript - 使用 select 在特定 URL 上显示 2 个不同的 div