Tensorflow图像分类。找到了200万个文件 但只使用了其中的 416k个

我目前正在 tensorflow 中做一个基本的图像分类算法,代码基本上完全遵循https://www.tensorflow.org/tutorials/images/classification给出的教程,除了我使用自己的数据。

我目前正在 tensorflow 中做一个基本的图像分类算法,代码基本上完全遵循https://www.tensorflow.org/tutorials/images/classification给出的教程,除了我使用自己的数据。

目前我有以下设置用于生成数据集:

#Set up information on the data
batch_size = 32
img_height = 100
img_width = 100
#Generate training dataset
train_ds = tf.keras.utils.image_dataset_from_directory(
  Directory,
  validation_split=0.8,
  subset="training",
  seed=123,
  image_size=(img_height, img_width),
  batch_size=batch_size)
#Generate val dataset
val_ds = tf.keras.utils.image_dataset_from_directory(
  Directory,
  validation_split=0.2,
  subset="validation",
  seed=123,
  image_size=(img_height, img_width),
  batch_size=batch_size)

但在终端输出中,在我们的集群上运行后,我看到以下内容:

2022-09-30 09:49:26.936639: W tensorflow/core/kernels/data/cache_dataset_ops.cc:856] 
The calling iterator did not fully read the dataset being cached. In order to avoid unexpected truncation of the dataset, the partially cached contents of the dataset  will be discarded. This can happen if you have an input pipeline similar to `dataset.cache().take(k).repeat()`. You should use `dataset.take(k).cache().repeat()` instead.
2022-09-30 09:49:26.956813: W tensorflow/core/kernels/data/cache_dataset_ops.cc:856] The calling iterator did not fully read the dataset being cached. In order to avoid unexpected truncation of the dataset, the partially cached contents of the dataset  will be discarded. This can happen if you have an input pipeline similar to `dataset.cache().take(k).repeat()`. You should use `dataset.take(k).cache().repeat()` instead.
Found 2080581 files belonging to 2 cl.
Using 416117 files for training.
Found 2080581 files belonging to 2 cl.
Using 416116 files for validation.

我没有大量的 tensorflow 经验,不能真正弄清楚如何解决这个错误,任何人都可以指出我在正确的方向?

1

您将保留 20 % 的数据用于训练(2080581 * 20% ≈ 416117),因为validation_split是 80 %。

#Generate training dataset
train_ds = tf.keras.utils.image_dataset_from_directory(
  Directory,
  validation_split=0.2,
  subset="training",
  seed=123,
  image_size=(img_height, img_width),
  batch_size=batch_size)
#Generate val dataset
val_ds = tf.keras.utils.image_dataset_from_directory(
  Directory,
  validation_split=0.2,
  subset="validation",
  seed=123,
  image_size=(img_height, img_width),
  batch_size=batch_size)

检查docs进一步的信息和此example

本站系公益性非盈利分享网址,本文来自用户投稿,不代表码文网立场,如若转载,请注明出处

(485)
这是插入排序算法的可接受的实现吗 (surprise insertion)
上一篇
具有不断增长的永久性的内部收益率计算(perpetuity formula)
下一篇

相关推荐

  • tensorflow 测试代码:如何使用TensorFlow进行机器学习测试

    TensorFlow 测试代码是用来测试TensorFlow模型的代码,它可以帮助我们检查模型的准确性和性能。下面是一个典型的TensorFlow测试代码示例:…

    2023-07-31 01:31:31
    0 88 94
  • tensorflow2.0运行1.0代码:如何使用TensorFlow 2.0运行TensorFlow 1.0代码

    示例示例0可以运行1.0代码,但是需要在代码中使用特定的接口来支持2.0。下面是一个简单的 0代码示例,用于演示如何在 0中运行它:# 0…

    2023-06-09 03:54:31
    0 94 70
  • tensorflow源码解析:TensorFlow中的深度学习模型构建

    TensorFlow源码解析是指对TensorFlow框架的源代码进行分析,以便了解其内部实现原理,并能够根据用户需要进行修改和优化。…

    2023-01-24 05:36:12
    0 96 46
  • Gpu z:Tensorflow-gpu未检测到GPU

    关于Gpu z的问题,在windows not detecting gpu中经常遇到,我有 tensorflow-gpu 版本 2.2.0 在 python 3.7.4 中安装了 Anaconda,但我的代码始终在 CPU 上运行,并且无法检测到我的 GPU。…

    2022-12-17 02:41:51
    0 61 39
  • TensorFlow变量和常量

    我是新来的 tensorflow,我不能够理解变量和常量的区别,我得到的想法,我们使用变量的方程和常量的直接值,但为什么 code # 1 只工作,为什么不 code # 2 和 # 3,请解释在哪些情况下,我们必须先运行我们的图(A),然后我们的变量(B)即…

    2022-11-11 15:12:35
    0 28 90
  • TensorFlow变量和常量

    我是新来的 tensorflow,我不能够理解变量和常量的区别,我得到的想法,我们使用变量的方程和常量的直接值,但为什么 code # 1 只工作,为什么不 code # 2 和 # 3,请解释在哪些情况下,我们必须先运行我们的图(A),然后我们的变量(B)即…

    2022-12-13 06:22:42
    0 69 37
  • tensorflow-gpu对应cuda:如何使用TensorFlow-GPU和CUDA来提升计算性能

    TensorFlow-GPU是一个基于CUDA的框架,它使用GPU来加速机器学习模型的训练。CUDA(Compute Unified Device Architecture)是NVIDIA提供的一种并行计算架构,它可以在NVIDIA的GPU上运行C或C++代码。…

    2023-05-31 04:12:24
    0 42 43
  • tensorflow gpu和cpu区别提升深度学习性能的利器

    示例示例GPU和CPU之间的主要区别是GPU可以提供更高的计算性能,而CPU可以提供更高的灵活性。GPU(图形处理器)是一种用于进行大量并行计算的硬件设备,它可以比CPU快得多。由于它们的并行性,GPU可以执行大量的计算任务,而不需要像CPU那样需要更多的时间来完成同样的任务。…

    2023-04-16 10:49:37
    0 20 89

发表评论

登录 后才能评论

评论列表(25条)