【发布时间】:2018-12-07 03:08:20
【问题描述】:
如何从列表中创建张量流记录?
从documentation 看来,这似乎是可能的。还有这个example,他们使用来自numpy的.tostring()将一个numpy数组转换为一个字节数组。但是,当我尝试传入时:
labels = np.asarray([[1,2,3],[4,5,6]])
...
example = tf.train.Example(features=tf.train.Features(feature={
'height': _int64_feature(rows),
'width': _int64_feature(cols),
'depth': _int64_feature(depth),
'label': _int64_feature(labels[index]),
'image_raw': _bytes_feature(image_raw)}))
writer.write(example.SerializeToString())
我得到错误:
TypeError: array([1, 2, 3]) has type type 'numpy.ndarray', but expected one of: (type 'int', type 'long')
这并不能帮助我弄清楚如何将整数列表存储到 tfrecord 中。我试过浏览文档。
【问题讨论】:
标签: python tensorflow