You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NotFoundError:指定训练目录不存在的问题解决求助

NotFoundError:指定训练目录不存在的问题解决求助

大家好,我是韩国开发者,英文写作不太熟练,还请大家多多包涵🙏。

我在运行代码时遇到了一个错误,具体报错信息如下:

NotFoundError: Could not find directory C://Users/Admin/Downloads/assignment2/train

想请教各位前辈,这个问题该怎么解决呢?

下面是我编写的代码:

import os
import tensorflow as tf
from tensorflow import keras

base_dir = 'C:/Users/Admin/Downloads/assignment2'

train_dir = os.path.join(base_dir, 'train')
test_dir = os.path.join(base_dir, 'test')

batch_size = 32
num_of_train_imgs = 3934
num_of_test_imgs = 1966
img_height = 50
img_width = 50

train_ds = tf.keras.preprocessing.image_dataset_from_directory(
train_dir,
validation_split=0.2,
subset="training",
seed=123,
image_size=(img_height, img_width),
batch_size=num_of_train_imgs)

val_ds = tf.keras.preprocessing.image_dataset_from_directory(
train_dir,
validation_split=0.2,
subset="validation",
seed=123,
image_size=(img_height, img_width),
batch_size=num_of_train_imgs)

test_ds = tf.keras.preprocessing.image_dataset_from_directory(
test_dir,
image_size=(img_height, img_width),
batch_size=num_of_test_imgs)

备注:内容来源于stack exchange,提问作者park

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.22 11:48:06