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
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相关文章推荐
- TensorFlow踩坑记:Can not convert a ndarray into a Tensor or Operation.
- Python Theano TypeError: Cannot convert Type TensorType(float64, vector) (of Variable Subtensor{int64:int64:}.0) into Type TensorType(float64, matrix)
- Cannot interpret feed_dict key as Tensor: Can not convert a method into a Tensor.
- 方天ERP 解决委外产品入库 提示:could not convert variant of type(null) into type (double)
- TypeError: view must be a callable or a list/tuple in the case of include()
- 使用mysql-connector-java.jar连接MySql时出现:Error while retrieving metadata for procedure columns: java.sql.SQLException: Parameter/Column name pattern can not be NULL or empty.
- checking host system type... configure: error: can not guess host type; you must specify one
- Error:The type or namespace name 'Office' does not exist in the namespace 'Microsoft' 解决方法
- TypeError: 'bases' is null or not an object。IE8 bug 腐朽的对象
- 'Could not convert variant of type (Array Byte) into type (Integer)
- Message BT123 - Target host or target server & is not defined in an operation type
- TypeError: view must be a callable or a list/tuple in the case of include()
- Error: Could not load type 'microsoft.teamfoundation.workitemtracking.client.workitemtypedeniedornotexistexception'
- Uncaught TypeError: Super expression must either be null or a function, not undefine
- CSharp_DevExpress_"Can not load 7-zip library or internal COM error! Message: failed to load librar"
- native: tensorflow_jni.cc:153 Could not create TensorFlow Graph: Not found: Op type not registered '
- 使用SevenZipSharp出现“Can not load 7-zip library or internal COM error! Message: DLL file does not exist.”的解决方案
- ERROR: a parameter or an operation is not supported by the underlying object
- SSD Tensorflow:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start
- SharePoint Designer Can not perform this operation.The file is no longer checked out or has been del