cloudml再训练开始 - 接收有效范围之外的标签值(cloudml retraining inc

2019-09-27 17:20发布

我下面的花朵教程对谷歌云毫升再培训开始。 我可以运行教程,火车,预测,就好了。

然后,我取代了鲜花数据集对我自己的测试数据集。 光学字符识别的图像数字。

当训练模型我收到错误:

Invalid argument: Received a label value of 13 which is outside the valid range of [0, 6). Label values: 6 3 2 7 3 7 6 6 12 6 5 2 3 6 8 8 8 8 4 6 5 13 7 4 8 12 5 2 4 12 12 8 8 8 12 6 4 2 12 4 3 8 2 6 8 12 2 8 4 6 2 4 12 5 5 7 6 2 2 3 2 8 2 5 2 8 2 7 4 12 8 4 2 4 8 2 2 8 2 8 7 6 8 3 5 5 5 8 8 2 5 3 9 8 5 8 3 2 5 4

培训和eval数据集的格式如下:

root@e925cd9502c0:~/MeerkatReader/cloudML# head training_dataGCS.csv
gs://api-project-773889352370-ml/TrainingData/0_2.jpg,H
gs://api-project-773889352370-ml/TrainingData/0_4.jpg,One
gs://api-project-773889352370-ml/TrainingData/0_5.jpg,Five

该字典文件看起来像这样

$ cat cloudML/dict.txt
Eight
F
Five
Forward_slash
Four
H
Nine
One
Seven
Six
Three
Two
Zero

我原本有标签像1,2,3,4和/,但我把它们改成字符串的情况下,他们是特殊字符(尤其是/)。 我可以看到一个有些类似的消息在这里 ,但曾与基于零的索引做。

有什么奇怪的消息是,确实有13种标签类型。 不知怎的,tensorflow正在寻找只有7(0-6)。 我的问题是什么样的格式错误可能会使tensorflow想有更少的标签再有。 我可以证实,无论是测试和训练数据80-20分有所有的标注类(虽然在不同的频率)。

我是从谷歌提供最近的码头工人内部版本。

`docker run -it -p "127.0.0.1:8080:8080" --entrypoint=/bin/bash  gcr.io/cloud-datalab/datalab:local-20161227

我使用提交培训工作

  # Submit training job.
gcloud beta ml jobs submit training "$JOB_ID" \
  --module-name trainer.task \
  --package-path trainer \
  --staging-bucket "$BUCKET" \
  --region us-central1 \
  -- \
  --output_path "${GCS_PATH}/training" \
  --eval_data_paths "${GCS_PATH}/preproc/eval*" \
  --train_data_paths "${GCS_PATH}/preproc/train*"

完整的错误:

Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'>, Received a label value of 13 which is outside the valid range of [0, 6). Label values: 6 3 2 7 3 7 6 6 12 6 5 2 3 6 8 8 8 8 4 6 5 13 7 4 8 12 5 2 4 12 12 8 8 8 12 6 4 2 12 4 3 8 2 6 8 12 2 8 4 6 2 4 12 5 5 7 6 2 2 3 2 8 2 5 2 8 2 7 4 12 8 4 2 4 8 2 2 8 2 8 7 6 8 3 5 5 5 8 8 2 5 3 9 8 5 8 3 2 5 4 [[Node: evaluate/xentropy/xentropy = SparseSoftmaxCrossEntropyWithLogits[T=DT_FLOAT, Tlabels=DT_INT64, _device="/job:master/replica:0/task:0/cpu:0"](final_ops/input/Wx_plus_b/fully_connected_1/BiasAdd, inputs/Squeeze)]] Caused by op u'evaluate/xentropy/xentropy', 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 "/root/.local/lib/python2.7/site-packages/trainer/task.py", line 545, in <module> tf.app.run() File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 43, in run sys.exit(main(sys.argv[:1] + flags_passthrough)) File "/root/.local/lib/python2.7/site-packages/trainer/task.py", line 308, in main run(model, argv) File "/root/.local/lib/python2.7/site-packages/trainer/task.py", line 439, in run dispatch(args, model, cluster, task) File "/root/.local/lib/python2.7/site-packages/trainer/task.py", line 480, in dispatch Trainer(args, model, cluster, task).run_training() File "/root/.local/lib/python2.7/site-packages/trainer/task.py", line 187, in run_training self.args.batch_size) File "/root/.local/lib/python2.7/site-packages/trainer/model.py", line 278, in build_train_graph return self.build_graph(data_paths, batch_size, GraphMod.TRAIN) File "/root/.local/lib/python2.7/site-packages/trainer/model.py", line 256, in build_graph loss_value = loss(logits, labels) File "/root/.local/lib/python2.7/site-packages/trainer/model.py", line 396, in loss logits, labels, name='xentropy') File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/nn_ops.py", line 1544, in sparse_softmax_cross_entropy_with_logits precise_logits, labels, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_nn_ops.py", line 2376, in _sparse_softmax_cross_entropy_with_logits features=features, labels=labels, name=name) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2238, in create_op original_op=self._default_original_op, op_def=op_def) File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1130, in __init__ self._traceback = _extract_stack() InvalidArgumentError (see above for traceback): Received a label value of 13 which is outside the valid range of [0, 6). Label values: 6 3 2 7 3 7 6 6 12 6 5 2 3 6 8 8 8 8 4 6 5 13 7 4 8 12 5 2 4 12 12 8 8 8 12 6 4 2 12 4 3 8 2 6 8 12 2 8 4 6 2 4 12 5 5 7 6 2 2 3 2 8 2 5 2 8 2 7 4 12 8 4 2 4 8 2 2 8 2 8 7 6 8 3 5 5 5 8 8 2 5 3 9 8 5 8 3 2 5 4 [[Node: evaluate/xentropy/xentropy = SparseSoftmaxCrossEntropyWithLogits[T=DT_FLOAT, Tlabels=DT_INT64, _device="/job:master/replica:0/task:0/cpu:0"](final_ops/input/Wx_plus_b/fully_connected_1/BiasAdd, inputs/Squeeze)]]

一切看起来都还好我斗

而救了我的日志事件。

Answer 1:

我认为你需要指定--label_count 13时,您提交的培训工作。 该标志应后,去第二组后产生的标志的--因为它需要传递给你的代码正在执行,而不是gcloud /云ML。

问题是,TensorFlow训练代码需要知道有多少输出logits使它开始通过数据步进之前; 所以它不能从前处理工序检查中间文件。

让我知道,如果这有助于。



Answer 2:

具体型号和指定-后标志model.py :文件

def create_model():
  """Factory method that creates model to be used by generic task.py."""
  parser = argparse.ArgumentParser()
  # Label count needs to correspond to nubmer of labels in dictionary used
  # during preprocessing.
  parser.add_argument('--label_count', type=int, default=5)
  parser.add_argument('--dropout', type=float, default=0.5)
  parser.add_argument(
      '--inception_checkpoint_file',
      type=str,
      default=DEFAULT_INCEPTION_CHECKPOINT)
  args, task_args = parser.parse_known_args()
  override_if_not_in_args('--max_steps', '1000', task_args)
  override_if_not_in_args('--batch_size', '100', task_args)
  override_if_not_in_args('--eval_set_size', '370', task_args)
  override_if_not_in_args('--eval_interval_secs', '2', task_args)
  override_if_not_in_args('--log_interval_secs', '2', task_args)
  override_if_not_in_args('--min_train_eval_rate', '2', task_args)
  return Model(args.label_count, args.dropout,
               args.inception_checkpoint_file), task_args

注意,你可以改变的事情就像LABEL_COUNT,辍学,MAX_STEPS等,影响模型的培训。

HTH。



文章来源: cloudml retraining inception - received a label value outside the valid range