使用TensorFlow遍历目录并获取需要在训练神经网络中使用的图像。
train_ds = tf.keras.preprocessing.image_dataset_from_directory(
wk_dir,
labels="inferred",
label_mode="int",
class_names=None,
color_mode="grayscale",
batch_size=batches,
image_size=image_dim,
shuffle=True,
seed=1968,
validation_split=0.2,
subset="training",
interpolation="bilinear",
follow_links=False,
)
发现3个类别共127561个文件。 使用102049个文件进行训练。
结果 - 它有效了...现在我正在尝试将其输入到一个模型中,但不确定如何管理它...
print(train_ds)
<BatchDataset shapes: ((None, 576, 432, None), (None,)), types: (tf.float32, tf.int32)>
我的数组里有两个元素吗?第一个有4个元素,其中2个为空,第二个元素是分类吗?
我尝试拆分BatchDatashape,但出现错误TypeError:'BatchDataset'对象不可订阅
如何操作一个类型为python.data.ops.dataset_ops.BatchDataset的TF对象?