tensorflow slim inception_v3模型错误

时间:2017-01-18 13:11:03

标签: tensorflow tf-slim

我正在尝试将tensorflow inception_v3模型用于转移学习项目。我在构建模型时遇到以下错误。 TypeError: Expected int32, got list containing Tensors of type '_Message' instead. 对inception_v1模型使用相同的脚本时不会出现相同的错误。 模型从slim.nets

导入

在CPU上运行 Tensorflow版本:0.12.1

脚本

import tensorflow as tf
slim = tf.contrib.slim
import models.inception_v3 as inception_v3

print("initializing model")
inputs=tf.placeholder(tf.float32, shape=[32,299,299,3]) 
with slim.arg_scope(inception_v3.inception_v3_arg_scope()):
    logits,endpoints = inception_v3.inception_v3(inputs, num_classes=1001, is_training=False)

trainable_vars=tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES)
for tvars in trainable_vars:
    print tvars.name 

完整错误消息

Traceback (most recent call last):
File "test.py", line 8, in <module>
logits,endpoints = inception_v3.inception_v3(inputs, num_classes=1001, is_training=False)
File "/home/ashish/projects/python/fashion-language/models/inception_v3.py", line 576, in inception_v3
depth_multiplier=depth_multiplier)
File "/home/ashish/projects/python/fashion-language/models/inception_v3.py", line 181, in inception_v3_base
net = array_ops.concat([branch_0, branch_1, branch_2, branch_3], 3)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 1075, in concat
dtype=dtypes.int32).get_shape(
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 669, in convert_to_tensor
ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py", line 176, in _constant_tensor_conversion_function
return constant(v, dtype=dtype, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py", line 165, in constant
tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 367, in make_tensor_proto
_AssertCompatible(values, dtype)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 302, in _AssertCompatible
(dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

1 个答案:

答案 0 :(得分:1)

发现我的错误,我从https://github.com/tensorflow/tensorflow/tree/master/tensorflow/contrib/slim/python/slim/nets导入模型,而更新的模型位于https://github.com/tensorflow/models/tree/master/slim/nets

仍然无法理解为什么同一个类有两个不同的存储库。必须是一个有效的理由。