work_with_stagesepx icon indicating copy to clipboard operation
work_with_stagesepx copied to clipboard

执行dynamic下面的train_model.py时报错Function call stack: train_function

Open molixiaoxiao opened this issue 4 years ago • 1 comments

Mac OS:macOS Big Sur 11.0.1 Python:3.8 TensorFlow:2.4.0 执行步骤如下: 第1步:执行get_data.py生成data数据 第2步:执行train_model.py,然后就报如下错误:

2020-12-18 17:54:06.073 | DEBUG    | stagesepx.classifier.base:__init__:297 - compress rate: None
2020-12-18 17:54:06.073 | DEBUG    | stagesepx.classifier.base:__init__:298 - target size: (600, 800)
2020-12-18 17:54:06.073 | DEBUG    | stagesepx.hook:__init__:13 - start initialing: CompressHook ...
2020-12-18 17:54:06.074 | DEBUG    | stagesepx.hook:__init__:80 - compress rate: None
2020-12-18 17:54:06.074 | DEBUG    | stagesepx.hook:__init__:81 - target size: (600, 800)
2020-12-18 17:54:06.074 | DEBUG    | stagesepx.hook:__init__:13 - start initialing: GreyHook ...
2020-12-18 17:54:06.074 | DEBUG    | stagesepx.classifier.base:add_hook:319 - add hook: CompressHook
2020-12-18 17:54:06.074 | DEBUG    | stagesepx.classifier.base:add_hook:319 - add hook: GreyHook
2020-12-18 17:54:06.074 | DEBUG    | stagesepx.classifier.keras:__init__:50 - score threshold: 0.0
2020-12-18 17:54:06.074 | DEBUG    | stagesepx.classifier.keras:__init__:51 - data size: (200, 200)
2020-12-18 17:54:06.074 | DEBUG    | stagesepx.classifier.keras:__init__:52 - nb train samples: 64
2020-12-18 17:54:06.074 | DEBUG    | stagesepx.classifier.keras:__init__:53 - nb validation samples: 64
2020-12-18 17:54:06.074 | DEBUG    | stagesepx.classifier.keras:__init__:54 - epochs: 10
2020-12-18 17:54:06.075 | DEBUG    | stagesepx.classifier.keras:__init__:55 - batch size: 4
2020-12-18 17:54:06.075 | DEBUG    | stagesepx.classifier.keras:train:151 - no model can be used. build a new one.
2020-12-18 17:54:06.075 | INFO     | stagesepx.classifier.keras:create_model:99 - creating keras sequential model
2020-12-18 17:54:06.080939: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set
2020-12-18 17:54:06.081188: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-12-18 17:54:06.186 | INFO     | stagesepx.classifier.keras:create_model:129 - model created
Found 56 images belonging to 10 classes.
Found 21 images belonging to 10 classes.
2020-12-18 17:54:06.386301: I tensorflow/compiler/mlir/mlir_graph_optimization_pass.cc:116] None of the MLIR optimization passes are enabled (registered 2)
Epoch 1/10
2020-12-18 17:54:07.361360: W tensorflow/core/framework/op_kernel.cc:1763] OP_REQUIRES failed at sparse_xent_op.cc:90 : Invalid argument: Received a label value of 9 which is outside the valid range of [0, 6).  Label values: 9 4 7 0
Traceback (most recent call last):
  File "/Users/aaa/Downloads/work_with_stagesepx-master/dynamic/train_model.py", line 13, in <module>
    cl.train(data_home)
  File "/usr/local/lib/python3.8/site-packages/stagesepx/classifier/keras.py", line 178, in train
    self._model.fit(
  File "/usr/local/lib/python3.8/site-packages/tensorflow/python/keras/engine/training.py", line 1100, in fit
    tmp_logs = self.train_function(iterator)
  File "/usr/local/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 828, in __call__
    result = self._call(*args, **kwds)
  File "/usr/local/lib/python3.8/site-packages/tensorflow/python/eager/def_function.py", line 888, in _call
    return self._stateless_fn(*args, **kwds)
  File "/usr/local/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 2942, in __call__
    return graph_function._call_flat(
  File "/usr/local/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 1918, in _call_flat
    return self._build_call_outputs(self._inference_function.call(
  File "/usr/local/lib/python3.8/site-packages/tensorflow/python/eager/function.py", line 555, in call
    outputs = execute.execute(
  File "/usr/local/lib/python3.8/site-packages/tensorflow/python/eager/execute.py", line 59, in quick_execute
    tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
tensorflow.python.framework.errors_impl.InvalidArgumentError:  Received a label value of 9 which is outside the valid range of [0, 6).  Label values: 9 4 7 0
   [[node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits (defined at usr/local/lib/python3.8/site-packages/stagesepx/classifier/keras.py:178) ]] [Op:__inference_train_function_984]

Function call stack:
train_function

molixiaoxiao avatar Dec 18 '20 10:12 molixiaoxiao

https://github.com/williamfzc/stagesepx/issues/112

williamfzc avatar Dec 18 '20 10:12 williamfzc