小编Sil*_*jor的帖子

从 tfRecords 中提取特征时找不到特征

我尝试使用 tfRecords 存储两个 numpy 数组和一些元信息,并将其加载为 tf.data.TFRecordDataset 以使用非常方便的批处理。此外,数组对于张量流和我的内存来说太大了,无法处理,所以它是剩下的少数选择之一。

def toTfRecords(Hdf5NormalizedImage, Hdf5GroundTruth):
        featureList = keys(Hdf5NormalizedImage)
        gtList = keys(Hdf5GroundTruth)

    writer = tf.python_io.TFRecordWriter('../src/tfRecord.tfrecords')
    for i in tqdm(range(featureList.__len__())):
        featurePadded = np.zeros(shape=(448, 448, 3))

        feature = Hdf5NormalizedImage[featureList[i]][:]
        groundtruth = Hdf5GroundTruth[featureList[i]][:]

        padded = featurePadded[:feature.shape[0], :feature.shape[1], :feature.shape[2]] = feature
        padMap = padded.shape
        grdMap = groundtruth.shape

        features = {
            'feature': tf.train.Feature(float_list=(tf.train.FloatList(value = feature))),
            'groundtruth': tf.train.Feature(float_list=(tf.train.FloatList(value = groundtruth))),
            'padMap': tf.train.Feature(float_list=(tf.train.FloatList(value = padMap))),
            'grdMap': tf.train.Feature(float_list=(tf.train.FloatList(value = grdMap))),
        }

        example = tf.train.Example(features=tf.train.Features(feature=features))
        writer.write(example.SerializeToString())
    writer.close()
    return

def parse_proto(example_proto):
    features = {
        'feature': tf.FixedLenFeature([], …
Run Code Online (Sandbox Code Playgroud)

python tensorflow tensorflow-datasets

6
推荐指数
0
解决办法
941
查看次数

标签 统计

python ×1

tensorflow ×1

tensorflow-datasets ×1