gpt4 book ai didi

python - 如何使用 TensorFlow 数据集获取 Omniglot 数据对

转载 作者:行者123 更新时间:2023-11-30 08:48:08 28 4
gpt4 key购买 nike

我正在使用具有结构的omniglot数据集

 Omniglot
||______
| |
class_0 class_1 ... class_N
| |_______...______________|
| | |
class_0 examples class_1 examples class_n examples

我正在尝试使用 tensorflow 数据集来获取示例对,如果它们来自相同的示例文件夹,则将它们标记为 0;如果它们来自不同的示例文件夹,则将它们标记为 1。

当我执行时'''omn​​i_train = tfds.load(name="omniglot", split=tfds.Split.TRAIN)omn​​i_example,=omni_train.take(1)'''

我得到输出

<TakeDataset shapes: {image: (105, 105, 3), alphabet: (), alphabet_char_id: (), label: ()}, types: {image: tf.uint8, alphabet: tf.int64, alphabet_char_id: tf.int64, label: tf.int64}>

我明白了,但是我可以修改它,以便它生成随机对吗?

它有字母表和alphabet_char_id,这意味着它可能是一个简单的映射,只要字母表和字母表字符id匹配对,那么标签就是0或1,而不是集合中的第n个字符目前是。

我的目标是通过我已经编写的暹罗神经网络传递该对和标签。

最佳答案

我只是将它转储到 numpy 中,然后基于它编写一个生成器,希望这个要点能以某种方式有所帮助。 https://gist.github.com/chychen/c8249b38cce94ae6a641260b81b23f78

关于python - 如何使用 TensorFlow 数据集获取 Omniglot 数据对,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57211963/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com