tfr
is a lightweight command-line TFRecords
processor that
reads serialized .tfrecord
files and outputs to stdout in JSON format.
Binaries are available from the releases page.
If you have Go installed, just run go get
.
go get github.com/emla2805/tfr
On MacOs, use Homebrew.
brew tap emla2805/tfr
brew install tfr
Parse a single file on the terminal
tfr data_tfrecord-00000-of-00001
or, read from stdin
cat data_tfrecord-00000-of-00001 | tfr -n 1
tfr
is best used with other great tools like jq,
gsutil and gunzip
.
gsutil cat gs://<bucket>/<path>/data_tfrecord-00000-of-00001.gz | gunzip | tfr -n 1 | jq .
tfr data_tfrecord-00000-of-00001 | jq '.features.feature | to_entries | map( {(.key): .value[].value} ) | add'
{
"age": [
29
],
"movie": [
"The Shawshank Redemption",
"Fight Club"
],
"movie_ratings": [
9,
9.7
]
}