构造Tensorflow模型时发生错误:FailedPreconditionError

时间:2019-12-26 04:10:04

标签: python tensorflow neural-network

我正在尝试构建一个模型,以根据图像文件夹区分切片的橘子和常规的橘子。一切顺利,直到我运行命令来训练模型。代码/错误如下。

!pip install -q tf-hub-nightly==0.8.0.dev201911110007
!pip install -q git+https://github.com/tensorflow/examples

from __future__ import absolute_import, division, print_function, unicode_literals

import numpy as np

import tensorflow as tf
assert tf.__version__.startswith('2')

from tensorflow_examples.lite.model_customization.core.data_util.image_dataloader import ImageClassifierDataLoader
from tensorflow_examples.lite.model_customization.core.task import image_classifier
from tensorflow_examples.lite.model_customization.core.task.model_spec import efficientnet_b0_spec
from tensorflow_examples.lite.model_customization.core.task.model_spec import ImageModelSpec

import matplotlib.pyplot as plt

import os
oranges = os.path.abspath('/content/sample_data/oranges')

data = ImageClassifierDataLoader.from_folder(oranges)

//THIS LINE IS PRODUCING THE ERROR
model = image_classifier.create(data) 

Here is the error it produces

1 个答案:

答案 0 :(得分:0)

此问题已通过将笔记本副本保存到我的驱动器并重新打开来解决。 .ipynb文件是笔记本电脑在您手动保存时使用的检查点,这就是错误消息所指的内容。我假设笔记本的该特定会话出现了问题。无论如何,在驱动器上保存新版本并重新打开/运行代码都表明此问题已解决。