首页 > 解决方案 > Google Colabs 中的 TensorFlow 2 在模型测试中失败了预处理错误

问题描述

我试图在我的完整模型上调用 predict() 并将其传递给测试数据批次。该模型适用于我的训练和验证数据,但是当我尝试在我的测试数据上运行它时出现此错误。

我已经查看了堆栈溢出链接上的答案,但我无法就为什么我不断收到错误建立联系。

这是我运行的功能:

# Make predictions on test data batch using the loaded full model
test_predictions = loaded_full_model.predict(test_data,
                                             verbose=1)

这是返回的错误:

 14/324 [>.............................] - ETA: 39s
---------------------------------------------------------------------------
FailedPreconditionError                   Traceback (most recent call last)
<ipython-input-98-1081792ff13f> in <module>()
      1 # Make predictions on test data batch using the loaded full model
      2 test_predictions = loaded_full_model.predict(test_data,
----> 3                                              verbose=1)

8 frames
/usr/local/lib/python3.6/dist-packages/tensorflow/python/eager/execute.py in quick_execute(op_name, 
num_outputs, inputs, attrs, ctx, name)
     58     ctx.ensure_initialized()
     59     tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
---> 60                                         inputs, attrs, num_outputs)
     61   except core._NotOkStatusException as e:
     62     if name is not None:

FailedPreconditionError: 2 root error(s) found.
  (0) Failed precondition:  /content/drive/My Drive/Colab Notebooks/test/.ipynb_checkpoints; Is a 
directory
     [[{{node ReadFile}}]]
     [[IteratorGetNext]]
     [[IteratorGetNext/_2]]
  (1) Failed precondition:  /content/drive/My Drive/Colab Notebooks/test/.ipynb_checkpoints; Is a 
directory
     [[{{node ReadFile}}]]
     [[IteratorGetNext]]
0 successful operations.
0 derived errors ignored. [Op:__inference_predict_function_189545]

Function call stack:
predict_function -> predict_function

标签: google-colaboratorytensorflow2.0

解决方案


推荐阅读