model/official/resnet/cifar10_main.py 类型错误
model/official/resnet/cifar10_main.py TypeError
系统信息
What is the top-level directory of the model you are using: model/official/resnet
Have I written custom code (as opposed to using a stock example script provided in TensorFlow): no
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): ubuntu 16.04
TensorFlow installed from (source or binary): source
TensorFlow version (use command below): 1.4.1
Bazel version (if compiling from source): 0.6.0
CUDA/cuDNN version: 8.0/6.0
GPU model and memory: GTX 1080 Ti
Exact command to reproduce: python cifar10_main.py
描述问题
当我 运行 cifar10_main.py --data_dir /path 时,出现下一个错误(已经从 alex 的网站下载了 cifar 10):
TypeError:无法将类型对象转换为 Tensor。内容: 。考虑将元素转换为受支持的类型。
源代码/日志
INFO:tensorflow:Using config: {'_save_checkpoints_secs': 1000000000.0, '_session_config': allow_soft_placement: true , '_keep_checkpoint_max': 5, '_task_type': 'worker', '_is_chief': True, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7fed2e2588d0>, '_save_checkpoints_steps': None, '_keep_checkpoint_every_n_hours': 10000, '_service': None, '_num_ps_replicas': 0, '_tf_random_seed': None, '_master': '', '_num_worker_replicas': 1, '_task_id': 0, '_log_step_count_steps': 100, '_model_dir': '/tmp/cifar10_model', '_save_summary_steps': 100} Starting a training cycle. Traceback (most recent call last): File "cifar10_main.py", line 224, in <module> tf.app.run(argv=[sys.argv[0]] + unparsed) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "cifar10_main.py", line 208, in main resnet.resnet_main(FLAGS, cifar10_model_fn, input_function) File "/home/luis/models/official/resnet/resnet.py", line 650, in resnet_main classifier.train(input_fn=input_fn_train, hooks=[logging_hook]) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 302, in train loss = self._train_model(input_fn, hooks, saving_listeners) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 711, in _train_model features, labels, model_fn_lib.ModeKeys.TRAIN, self.config) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 694, in _call_model_fn model_fn_results = self._model_fn(features=features, **kwargs) File "cifar10_main.py", line 177, in cifar10_model_fn features = tf.reshape(features, [-1, _HEIGHT, _WIDTH, _NUM_CHANNELS]) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3938, in reshape "Reshape", tensor=tensor, shape=shape, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 513, in _apply_op_helper raise err TypeError: Failed to convert object of type <class 'tensorflow.python.data.ops.dataset_ops.PrefetchDataset'> to Tensor. Contents: <PrefetchDataset shapes: ((?, 32, 32, 3), (?, 10)), types: (tf.float32, tf.float32)>. Consider casting elements to a supported type.
我不是为什么会报错,也不是怎么解决的。
好的。我的解决方案只是升级到 tensorflow 1.6.0。好像tensorflow 1.4有很多if问题(除了上面提到的),我不建议使用
系统信息
What is the top-level directory of the model you are using: model/official/resnet
Have I written custom code (as opposed to using a stock example script provided in TensorFlow): no
OS Platform and Distribution (e.g., Linux Ubuntu 16.04): ubuntu 16.04
TensorFlow installed from (source or binary): source
TensorFlow version (use command below): 1.4.1
Bazel version (if compiling from source): 0.6.0
CUDA/cuDNN version: 8.0/6.0
GPU model and memory: GTX 1080 Ti
Exact command to reproduce: python cifar10_main.py
描述问题
当我 运行 cifar10_main.py --data_dir /path 时,出现下一个错误(已经从 alex 的网站下载了 cifar 10):
TypeError:无法将类型对象转换为 Tensor。内容: 。考虑将元素转换为受支持的类型。 源代码/日志
INFO:tensorflow:Using config: {'_save_checkpoints_secs': 1000000000.0, '_session_config': allow_soft_placement: true , '_keep_checkpoint_max': 5, '_task_type': 'worker', '_is_chief': True, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7fed2e2588d0>, '_save_checkpoints_steps': None, '_keep_checkpoint_every_n_hours': 10000, '_service': None, '_num_ps_replicas': 0, '_tf_random_seed': None, '_master': '', '_num_worker_replicas': 1, '_task_id': 0, '_log_step_count_steps': 100, '_model_dir': '/tmp/cifar10_model', '_save_summary_steps': 100} Starting a training cycle. Traceback (most recent call last): File "cifar10_main.py", line 224, in <module> tf.app.run(argv=[sys.argv[0]] + unparsed) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 48, in run _sys.exit(main(_sys.argv[:1] + flags_passthrough)) File "cifar10_main.py", line 208, in main resnet.resnet_main(FLAGS, cifar10_model_fn, input_function) File "/home/luis/models/official/resnet/resnet.py", line 650, in resnet_main classifier.train(input_fn=input_fn_train, hooks=[logging_hook]) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 302, in train loss = self._train_model(input_fn, hooks, saving_listeners) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 711, in _train_model features, labels, model_fn_lib.ModeKeys.TRAIN, self.config) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/estimator/estimator.py", line 694, in _call_model_fn model_fn_results = self._model_fn(features=features, **kwargs) File "cifar10_main.py", line 177, in cifar10_model_fn features = tf.reshape(features, [-1, _HEIGHT, _WIDTH, _NUM_CHANNELS]) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 3938, in reshape "Reshape", tensor=tensor, shape=shape, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 513, in _apply_op_helper raise err TypeError: Failed to convert object of type <class 'tensorflow.python.data.ops.dataset_ops.PrefetchDataset'> to Tensor. Contents: <PrefetchDataset shapes: ((?, 32, 32, 3), (?, 10)), types: (tf.float32, tf.float32)>. Consider casting elements to a supported type.
我不是为什么会报错,也不是怎么解决的。
好的。我的解决方案只是升级到 tensorflow 1.6.0。好像tensorflow 1.4有很多if问题(除了上面提到的),我不建议使用