0

我正在尝试将 cloudml-samples/flowers/ 中的教程代码应用于一组具有多标签的照片。环境是 Google Cloud Shell。“预处理”所有训练和评估集。开始训练任务时出错。

我通过 python 调用了 trainer.task 并返回了以下错误消息。请让我知道通过运行 gcloud beta ml 命令获得的日志信息(仅是一些通用信息)或其他任何内容是否会有所帮助。

提前感谢您的关注。

python -m trainer.task \
    --output_path gs://yelp_restaurant_photo_classification/yelp_restaurant_photo_classification/training \
    --eval_data_paths gs://yelp_restaurant_photo_classification/yelp_restaurant_photo_classification/preproc/eval* \
    --train_data_paths gs://yelp_restaurant_photo_classification/yelp_restaurant_photo_classification/preproc/train*

INFO:root:Original job data: {}
INFO:root:setting eval batch size to 100
INFO:tensorflow:global_step/sec: 0
INFO:tensorflow:global_step/sec: 0
W tensorflow/core/framework/op_kernel.cc:968] Invalid argument: Name: <unknown>, Key: label, Index: 0.  Number of int64 values != expected.  Values size: 5 but output shape: [1]
INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors.InvalidArgumentError'>, Name: <unknown>, Key: label, Index: 0.  Number of int64 values != expected.  Values size: 5 but output shape: [1]
         [[Node: inputs/ParseExample/ParseExample = ParseExample[Ndense=3, Nsparse=0, Tdense=[DT_FLOAT, DT_STRING, DT_INT64], dense_shapes=[[2048], [], [1]], sparse_types=[], _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch:1, inputs/ParseExample/ParseExample/names, inputs/ParseExample/ParseExample/dense_keys_0, inputs/ParseExample/ParseExample/dense_keys_1, inputs/ParseExample/ParseExample/dense_keys_2, inputs/ParseExample/Const, inputs/ParseExample/Reshape, inputs/ParseExample/Reshape_1)]]

Caused by op u'inputs/ParseExample/ParseExample', defined at:
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 559, in <module>
    tf.app.run()
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run
    sys.exit(main(sys.argv[:1] + flags_passthrough))
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 322, in main
    run(model, argv)
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 453, in run
    dispatch(args, model, cluster, task)
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 494, in dispatch
    Trainer(args, model, cluster, task).run_training()
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 193, in run_training
    self.args.batch_size)
  File "trainer/model.py", line 278, in build_train_graph
    return self.build_graph(data_paths, batch_size, GraphMod.TRAIN)
  File "trainer/model.py", line 232, in build_graph
    parsed = tf.parse_example(tensors.examples, features=feature_map)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/ops/parsing_ops.py", line 307, in parse_example
    dense_types, dense_defaults, dense_shapes, name)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/ops/parsing_ops.py", line 405, in _parse_example_raw
    name=name)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_parsing_ops.py", line 165, in _parse_example
    dense_shapes=dense_shapes, name=name)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 749, in apply_op
    op_def=op_def)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2380, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1298, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Name: <unknown>, Key: label, Index: 0.  Number of int64 values != expected.  Values size: 5 but output shape: [1]
         [[Node: inputs/ParseExample/ParseExample = ParseExample[Ndense=3, Nsparse=0, Tdense=[DT_FLOAT, DT_STRING, DT_INT64], dense_shapes=[[2048], [], [1]], sparse_types=[], _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch:1, inputs/ParseExample/ParseExample/names, inputs/ParseExample/ParseExample/dense_keys_0, inputs/ParseExample/ParseExample/dense_keys_1, inputs/ParseExample/ParseExample/dense_keys_2, inputs/ParseExample/Const, inputs/ParseExample/Reshape, inputs/ParseExample/Reshape_1)]]

INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors.InvalidArgumentError'>, Name: <unknown>, Key: label, Index: 0.  Number of int64 values != expected.  Values size: 5 but output shape: [1]
         [[Node: inputs/ParseExample/ParseExample = ParseExample[Ndense=3, Nsparse=0, Tdense=[DT_FLOAT, DT_STRING, DT_INT64], dense_shapes=[[2048], [], [1]], sparse_types=[], _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch:1, inputs/ParseExample/ParseExample/names, inputs/ParseExample/ParseExample/dense_keys_0, inputs/ParseExample/ParseExample/dense_keys_1, inputs/ParseExample/ParseExample/dense_keys_2, inputs/ParseExample/Const, inputs/ParseExample/Reshape, inputs/ParseExample/Reshape_1)]]

Caused by op u'inputs/ParseExample/ParseExample', defined at:
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 559, in <module>
    tf.app.run()
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run
    sys.exit(main(sys.argv[:1] + flags_passthrough))
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 322, in main
    run(model, argv)
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 453, in run
    dispatch(args, model, cluster, task)
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 494, in dispatch
    Trainer(args, model, cluster, task).run_training()
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 193, in run_training
    self.args.batch_size)
  File "trainer/model.py", line 278, in build_train_graph
    return self.build_graph(data_paths, batch_size, GraphMod.TRAIN)
  File "trainer/model.py", line 232, in build_graph
    parsed = tf.parse_example(tensors.examples, features=feature_map)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/ops/parsing_ops.py", line 307, in parse_example
    dense_types, dense_defaults, dense_shapes, name)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/ops/parsing_ops.py", line 405, in _parse_example_raw
    name=name)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_parsing_ops.py", line 165, in _parse_example
    dense_shapes=dense_shapes, name=name)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 749, in apply_op
    op_def=op_def)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2380, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1298, in __init__
    self._traceback = _extract_stack()

InvalidArgumentError (see above for traceback): Name: <unknown>, Key: label, Index: 0.  Number of int64 values != expected.  Values size: 5 but output shape: [1]
         [[Node: inputs/ParseExample/ParseExample = ParseExample[Ndense=3, Nsparse=0, Tdense=[DT_FLOAT, DT_STRING, DT_INT64], dense_shapes=[[2048], [], [1]], sparse_types=[], _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch:1, inputs/ParseExample/ParseExample/names, inputs/ParseExample/ParseExample/dense_keys_0, inputs/ParseExample/ParseExample/dense_keys_1, inputs/ParseExample/ParseExample/dense_keys_2, inputs/ParseExample/Const, inputs/ParseExample/Reshape, inputs/ParseExample/Reshape_1)]]

Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 559, in <module>
    tf.app.run()
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run
    sys.exit(main(sys.argv[:1] + flags_passthrough))
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 322, in main
    run(model, argv)
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 453, in run
    dispatch(args, model, cluster, task)
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 494, in dispatch
    Trainer(args, model, cluster, task).run_training()
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 245, in run_training
    self.global_step = session.run(to_run)[0]
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 717, in run
    run_metadata_ptr)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 915, in _run
    feed_dict_string, options, run_metadata)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 965, in _do_run
    target_list, options, run_metadata)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/client/session.py", line 985, in _do_call
    raise type(e)(node_def, op, message)
tensorflow.python.framework.errors.InvalidArgumentError: Name: <unknown>, Key: label, Index: 0.  Number of int64 values != expected.  Values size: 5 but output shape: [1]
         [[Node: inputs/ParseExample/ParseExample = ParseExample[Ndense=3, Nsparse=0, Tdense=[DT_FLOAT, DT_STRING, DT_INT64], dense_shapes=[[2048], [], [1]], sparse_types=[], _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch:1, inputs/ParseExample/ParseExample/names, inputs/ParseExample/ParseExample/dense_keys_0, inputs/ParseExample/ParseExample/dense_keys_1, inputs/ParseExample/ParseExample/dense_keys_2, inputs/ParseExample/Const, inputs/ParseExample/Reshape, inputs/ParseExample/Reshape_1)]]

Caused by op u'inputs/ParseExample/ParseExample', defined at:
  File "/usr/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 559, in <module>
    tf.app.run()
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run
    sys.exit(main(sys.argv[:1] + flags_passthrough))
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 322, in main
    run(model, argv)
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 453, in run
    dispatch(args, model, cluster, task)
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 494, in dispatch
    Trainer(args, model, cluster, task).run_training()
  File "/home/slalomconsultingsf/git/cloudml-samples/yelp_restaurant_photo_classification/trainer/task.py", line 193, in run_training
INFO:tensorflow:Error reported to Coordinator: <class 'tensorflow.python.framework.errors.InvalidArgumentError'>, Name: <unknown>, Key: label, Index:
    self.args.batch_size)
  File "trainer/model.py", line 278, in build_train_graph
    return self.build_graph(data_paths, batch_size, GraphMod.TRAIN)
  File "trainer/model.py", line 232, in build_graph
    parsed = tf.parse_example(tensors.examples, features=feature_map)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/ops/parsing_ops.py", line 307, in parse_example
    dense_types, dense_defaults, dense_shapes, name)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/ops/parsing_ops.py", line 405, in _parse_example_raw
    name=name)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/ops/gen_parsing_ops.py", line 165, in _parse_example
    dense_shapes=dense_shapes, name=name)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 749, in apply_op
    op_def=op_def)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2380, in create_op
    original_op=self._default_original_op, op_def=op_def)
  File "/home/slalomconsultingsf/.local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1298, in __init__
    self._traceback = _extract_stack()
InvalidArgumentError (see above for traceback): Name: <unknown>, Key: label, Index: 0.  Number of int64 values != expected.  Values size: 5 but outpu
t shape: [1]
         [[Node: inputs/ParseExample/ParseExample = ParseExample[Ndense=3, Nsparse=0, Tdense=[DT_FLOAT, DT_STRING, DT_INT64], dense_shapes=[[2048], [
], [1]], sparse_types=[], _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch:1, inputs/ParseExample/ParseExample/names, inputs/ParseExamp
le/ParseExample/dense_keys_0, inputs/ParseExample/ParseExample/dense_keys_1, inputs/ParseExample/ParseExample/dense_keys_2, inputs/ParseExample/Const
, inputs/ParseExample/Reshape, inputs/ParseExample/Reshape_1)]]
4

1 回答 1

0

花样本不直接支持多标签分类。我认为您的代码中的确切问题与 model.py 中的shape=[1] 有关

唉,插入多标签示例将无法使用此代码开箱即用,该代码旨在成为如何开始复杂工作流(即从检查点恢复、迁移学习、嵌入 Dataflow 等)的一个很好的示例,比图像建模瑞士军刀更重要。

您应该只需要对 model.py 进行几行更改即可让您的多标签示例正常工作。此外,我相信社区的其他成员会非常感谢您取得的任何进展,所以请考虑创建一个拉取请求,如果您获得一个同时处理多标签和单标签问题的样本!

于 2017-02-06T02:56:07.567 回答