我试图将不同大小的图像保存到tf记录中.我发现即使图像大小不同,我仍然可以加载它们FixedLenFeature.
通过检查文档FixedLenFeature和VarLenFeature,我发现差异似乎是VarLenFeauture返回稀疏张量.
任何人都可以说明一些应该使用的情况FixedLenFeature或VarLenFeature?
我想使用Tensorflow的数据集API来读取变量长度列表的TFRecords文件.这是我的代码.
def _int64_feature(value):
# value must be a numpy array.
return tf.train.Feature(int64_list=tf.train.Int64List(value=value))
def main1():
# Write an array to TFrecord.
# a is an array which contains lists of variant length.
a = np.array([[0, 54, 91, 153, 177],
[0, 50, 89, 147, 196],
[0, 38, 79, 157],
[0, 49, 89, 147, 177],
[0, 32, 73, 145]])
writer = tf.python_io.TFRecordWriter('file')
for i in range(a.shape[0]): # i = 0 ~ 4
x_train = a[i]
feature = {'i': _int64_feature(np.array([i])), 'data': _int64_feature(x_train)}
# Create …Run Code Online (Sandbox Code Playgroud) 我正在尝试通过张量流对象检测API训练自定义数据集。数据集包含numpy ndarray格式(uint8)的40k训练图像和标签。训练数据集shape = 2([40000,23456])且标签shape = 1([0 ...,3])。我想为此数据集生成tfrecord。我怎么做?我不喜欢tensorflow。
我有一个大数据集(300.000 个示例 x 33.000 个特征),这当然不适合内存。数据以 HDF5 格式保存。这些值大多为零(稀疏数据)。它们看起来像这样:
Attr1 52 52 52 52 52 52 52 52 ...
Attr2 umb umb umb umb umb umb umb umb ...
CellID TGC-1 TGG-1 CAG-1 TTC-1 GTG-1 GTA-1 CAA-1 CAC-1 ...
Acc Gene ...
243485 RP11-.3 0 0 0 0 0 0 0 0 ...
237613 FAM138A 0 0 0 0 0 0 0 0 ...
186092 OR4F5 0 0 0 0 0 0 0 0 ...
238009 RP11-.7 0 0 0 0 0 …Run Code Online (Sandbox Code Playgroud) 我的数据集有不同的目录,每个目录对应一个类.每个目录中有不同数量的.tfrecords.我的问题是如何从每个目录中采样5个图像(每个.tfrecord文件对应一个图像)?我的另一个问题是如何对这些目录中的5个进行采样,然后从每个目录中采样5个图像.
我只想用tf.data.dataset来做.所以我希望有一个数据集,我从中得到一个迭代器,iterator.next()给我一批25个图像,包含5个类的5个样本.