Closed ZhouM1118 closed 2 years ago
If your data is SequenceExamples, then shouldn't you use tf.train.SequenceExample() in the line below (when you read back the record):
example = tf.train.Example() ==> example = tf.train.SequenceExample()
I solved the problem, thanks a lot. There is another question, can I generate tfrecord files in ELWC format use spark-tfrecord? for example
serialized = [
example_list_with_context = {
context {
features {
feature {
key: "query_length"
value { int64_list { value: 3 } }
}
}
}
examples {
features {
feature {
key: "unigrams"
value { bytes_list { value: "tensorflow" } }
}
feature {
key: "utility"
value { float_list { value: 0.0 } }
}
}
}
examples {
features {
feature {
key: "unigrams"
value { bytes_list { value: ["learning" "to" "rank" } }
}
feature {
key: "utility"
value { float_list { value: 1.0 } }
}
}
}
}
example_list_with_context = {
context {
features {
feature {
key: "query_length"
value { int64_list { value: 2 } }
}
}
}
examples {
features {
feature {
key: "unigrams"
value { bytes_list { value: ["gbdt"] } }
}
feature {
key: "utility"
value { float_list { value: 0.0 } }
}
}
}
examples {
features {
feature {
key: "unigrams"
value { bytes_list { value: ["neural", "networks"] } }
}
feature {
key: "utility"
value { float_list { value: 1.0 } }
}
}
}
}
]
I don't have experience with ELWC format. If it can be re-cast to SequenceExample or Example, then it is easy to generate. But if not, then it may be hard.
ok I got it. Thanks again for your help and reply!
I save tfrecord data in SequenceExample format with
writeDF.write.mode(writeMode).format("tfrecord").option("recordType", "SequenceExample")
, then I read tfrecord data withoutput is
but I expected output is
like https://github.com/tensorflow/ranking/blob/master/tensorflow_ranking/python/data.py SequenceExample format. so how to save tfrecord data like above SequenceExample format? Thanks for your reply and help!