问题描述
我使用以下代码将 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 (将#修改为@)