SSD-Tensorflow-masterc测试时:TypeError: Can not converrt a tuple int aTensor or Operation.或_variable_v2

在使用SSD-Tensorflow-master进行测试时遇到了两个错误:1) TypeError提示不能将元组转换为Tensor或Operation;2) _variable_v2_call函数接收到意外的'collections'参数。为解决这些问题,可以将metrics.py文件中_create_local函数的variables.Variable()更改为variables.VariableV1(),并且在eval_ssd_network.py文件中添加flatten函数处理list(names_to_updates.values()),以避免报错。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在SSD-Tensorflow-master测试时报错 1

在这里插入图片描述
这里是tensorflow的新版本(我的是tensorflow-gpu–1.14.0)问题
SSD-Tensorflow-master/tf_extended/metrics.py里的51行
将_create_local函数中的

return variables.Variable()

修改为:

return variables.VariableV1()

错误2: _variable_v2_call() got an unexpected keyword argument ‘collections’

在这里插入图片描述
解决方法为:
在SSD-Tensorflow-master/eval_ssd_network.py文件中添加下面一个函数:

def flatten(x):
    result = []
    for el in x:
         if isinstance(el, tuple):
               result.extend(flatten(el))
         else:
               result.append(el)
    return result

然后 修改两行代码 318 行和 337 行的

eval_op=list(names_to_updates.values())

同时改为

eval_op=flatten(list(names_to_updates.values()))

注意,一共两行

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值