您的位置:首页 > 运维架构

SSD-Tensorflow:TypeError: Can not convert a tuple into a Tensor or Operation

2017-11-14 14:08 591 查看
我在用这个模型进行评估的时候,遇见了上述这个问题,直接用github上的命令是有问题的,我的环境是python3, tensorflow 1.4,ubuntu16.04,结果就报错了:

TypeError: Can not convert a tuple into a Tensor or Operation

然后,自己对这个tensorflow编程不了解,沉寂了好长时间,我的命令是:
DATASET_DIR=tfrecords_test_v3
EVAL_DIR=logs/
CHECKPOINT_PATH=./checkpoints/VGG_VOC0712_SSD_300x300_ft_iter_120000.ckpt
python3 eval_ssd_network.py \
--eval_dir=${EVAL_DIR} \
--dataset_dir=${DATASET_DIR} \
--dataset_name=pascalvoc_2007 \
--dataset_split_name=test \
--model_name=ssd_300_vgg \
--checkpoint_path=${CHECKPOINT_PATH} \
--batch_size=1

后面,有人在github上解决了这个问题,我在此分享给大家,打开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
# Waiting loop.
slim.evaluation.evaluation_loop(
master=FLAGS.master,
checkpoint_dir=checkpoint_path,
logdir=FLAGS.eval_dir,
num_evals=num_batches,
eval_op=flatten(list(names_to_updates.values())), #这里调用flatten
variables_to_restore=variables_to_restore,
eval_interval_secs=60,
max_number_of_evaluations=np.inf,
session_config=config,
timeout=None)

# Standard evaluation loop.
start = time.time()
slim.evaluation.evaluate_once(
master=FLAGS.master,
checkpoint_path=checkpoint_path,
logdir=FLAGS.eval_dir,
num_evals=num_batches,
eval_op=flatten(list(names_to_updates.values())), #这里也调用flatten
variables_to_restore=variables_to_restore,
session_config=config)


参考文献

[1].TypeError: Can not convert a tuple into a Tensor or Operation. https://github.com/balancap/SSD-Tensorflow/issues/154
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐