0

我正在尝试将 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.
4

1 回答 1

1

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

仍然不明白为什么同一个类有两个不同的存储库。一定是一个正当的理由。

于 2017-01-18T16:16:51.810 回答