小编Yaf*_*faa的帖子

如何更改 tf.data.Dataset 中数据的 dtype?

我使用此 API 从目录加载了一个数据集

val_ds = tf.keras.preprocessing.image_dataset_from_directory(
  data_dir,
  validation_split=0.3,
  subset="validation",
  seed=123,
  image_size=(img_height, img_width),
  batch_size=batch_size)
Run Code Online (Sandbox Code Playgroud)

我想更改数据类型并使训练更快

我尝试过,但没有成功

for image_batch, labels_batch in train_ds:
  image_batch = tf.cast(image_batch,tf.int16)
Run Code Online (Sandbox Code Playgroud)

image-processing python-3.x deep-learning keras tensorflow

1
推荐指数
1
解决办法
2291
查看次数