TypeError: Expected int32, got list containing Tensors of type '_Message' instead.

在训练 tensorflow-0.11 时出现了 TypeError: Expected int32, got list containing Tensors of type '_Message' instead. 的错误

输出如下:

Traceback (most recent call last):
  File "train_image_classifier-dist.py", line 656, in <module>
    tf.app.run()
  File "/home/docker/tensorflow-0.11/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 43, in run
    sys.exit(main(sys.argv[:1] + flags_passthrough))
  File "train_image_classifier-dist.py", line 512, in main
    clones = model_deploy.create_clones(deploy_config, clone_fn, [batch_queue])
  File "/home/docker/tensorflow-master/tensorflow_models/slim/deployment/model_deploy.py", line 195, in create_clones
    outputs = model_fn(*args, **kwargs)
  File "train_image_classifier-dist.py", line 496, in clone_fn
    logits, end_points = network_fn(images)
  File "/home/docker/tensorflow-master/tensorflow_models/slim/nets/nets_factory.py", line 105, in network_fn
    return func(images, num_classes, is_training=is_training)
  File "/home/docker/tensorflow-master/tensorflow_models/slim/nets/inception_v3.py", line 576, in inception_v3
    depth_multiplier=depth_multiplier)
  File "/home/docker/tensorflow-master/tensorflow_models/slim/nets/inception_v3.py", line 181, in inception_v3_base
    net = array_ops.concat([branch_0, branch_1, branch_2, branch_3], 3)
  File "/home/docker/tensorflow-0.11/lib/python2.7/site-packages/tensorflow/python/ops/array_ops.py", line 1121, in concat
    dtype=dtypes.int32).get_shape(
  File "/home/docker/tensorflow-0.11/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 645, in convert_to_tensor
    as_ref=False)
  File "/home/docker/tensorflow-0.11/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 710, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/home/docker/tensorflow-0.11/lib/python2.7/site-packages/tensorflow/python/framework/constant_op.py", line 176, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/home/docker/tensorflow-0.11/lib/python2.7/site-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 "/home/docker/tensorflow-0.11/lib/python2.7/site-packages/tensorflow/python/framework/tensor_util.py", line 367, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "/home/docker/tensorflow-0.11/lib/python2.7/site-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.

这是因为版本不兼容的问题,我用的脚本是适用于tensorflow 1.0的


解决方法:

将inception_v3.py 中的

net = array_ops.concat([branch_0, branch_1, branch_2, branch_3], 3)

均改为

net = array_ops.concat(3, [branch_0, branch_1, branch_2, branch_3])

解决 ^^


你可能感兴趣的:(tensorflow)