无法解析序列化示例 TF记录

问题描述

我使用以下代码将 GEE 中的训练和测试数据提取到 TFRecord:(使用 sampleRegions 后)

Export.table.toCloudStorage({
collection:trainingPartition,description:'Training_Export',fileNamePrefix:trainFilePrefix,bucket:outputBucket,fileFormat:'TFRecord'});

后来,我从 colab 上的 TFRecord 文件创建了一个数据集并尝试解析数据:

size = 128
feature_columns = [
tf.io.FixedLenFeature(shape=[size,size],dtype=tf.float32) for k in featureNames
]

features_dict = dict(zip(featureNames,feature_columns))


def parse_tfrecord(example_proto):

parsed_features = tf.io.parse_single_example(example_proto,features_dict)
labels = parsed_features.pop(label)
return parsed_features,tf.cast(labels,tf.int32)

# Map the function over the dataset.
parsedDataset = trainDataset.map(parse_tfrecord,num_parallel_calls=4)

from pprint import pprint

# Print the first parsed record to check.
pprint(iter(parsedDataset).next())

我遇到的错误

InvalidArgumentError: Key: 3_B12_min.  Can't parse serialized Example.
 [[{{node ParseSingleExample/ParseExample/ParseExampleV2}}]]

这仅在我将大小设置为大于 1 的任何值时发生

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...