【问题标题】:Stream private data to google collab TPUs from GCS将私人数据从 GCS 流式传输到 Google Collab TPU
【发布时间】:2021-07-12 09:24:15
【问题描述】:

所以我正在尝试制作一个包含 150 个类别的照片分类器。我正在尝试在 google colab TPU 上运行它,我知道我需要一个 tfdstry_gcs = True,为此我需要在 google colab 云上放置一个数据集。所以我将生成器转换为 tfds,使用

将其存储在本地
my_tf_ds = tf.data.Dataset.from_generator(datafeeder.allGenerator,
                           output_signature=(
     tf.TensorSpec(shape=(64,64,3), dtype=tf.float32),
     tf.TensorSpec(shape=(150), dtype=tf.float32)))

tf.data.experimental.save(my_tf_ds,filename)

然后我将它发送到 GCS 上的存储桶。 但是当我尝试从我的存储桶中加载它时

import tensorflow_datasets as tfds
dsFromGcs = tfds.load("pokemons",data_dir = "gs://dataset-7000")

它不起作用并提供可用的数据集,例如:

- abstract_reasoning
- accentdb
- aeslc
- aflw2k3d
- ag_news_subset
- ai2_arc
- ai2_arc_with_ir
- amazon_us_reviews
- anli
- arc

不在我的 GCS 存储桶中。

自己从本地加载时:

tfds_from_file = tf.data.experimental.load(filename, element_spec= (
     tf.TensorSpec(shape=(64,64,3), dtype=tf.float32),
     tf.TensorSpec(shape=(150), dtype=tf.float32)))

它可以工作,数据集很好。

所以我不明白为什么我不能在 gcs 上阅读它,我们可以在 GCS 上阅读 private ds 吗?或仅已定义的数据集。我还向公众公开了我的 Bucket 中的角色 Storage Legacy Bucket Reader

【问题讨论】:

    标签: tensorflow google-cloud-storage google-colaboratory tensorflow-datasets google-cloud-tpu


    【解决方案1】:

    我认为tfds.loaddata_dir 参数是模块将在您的设备上本地存储内容的位置,try_gcs 是是否流式传输数据。所以 data_dir 不能用于将模块指向您的 GCS 存储桶。

    以下是您可以尝试的一些想法:

    1. 您可以尝试these steps 将您的数据集添加到TFDS,然后您应该能够使用tfds.load 加载它
    2. 您可以使用tf.data.experimental.save(我认为您已经完成)获取正确格式的数据集,然后将其保存到GCS,然后使用tf.data.experimental.load 加载它,您说它在本地为您工作。您可以关注 these steps 安装 gcsfuse 并使用它从 GCS 将数据集下载到 Colab。
    3. 您可以尝试使用 TFRecord 加载数据集。 Here 是带有解释的代码实验室,然后 here 是代码实验室中链接的 Colab 示例

    【讨论】:

      猜你喜欢
      • 2018-04-04
      • 1970-01-01
      • 2018-10-13
      • 2021-07-01
      • 1970-01-01
      • 2020-09-03
      • 1970-01-01
      • 2021-08-03
      • 1970-01-01
      相关资源
      最近更新 更多