Documentation ¶
Overview ¶
Package tfdata provides interfaces to interact with TFRecord files and TFExamples.
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
Package tfdata provides interfaces to interact with TFRecord files and TFExamples.
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
Package tfdata provides interfaces to interact with TFRecord files and TFExamples.
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
Package tfdata provides interface to interact with TFRecord files and TExamples ¶
Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved.
Index ¶
- Constants
- Variables
- type Sample
- type SampleChannel
- type SampleReadWriter
- type SampleReader
- type SampleWriter
- type TFExample
- func (e *TFExample) AddBytes(name string, bs ...[]byte)
- func (e *TFExample) AddBytesList(name string, bs [][]byte)
- func (e *TFExample) AddFloat(name string, floats ...float32)
- func (e *TFExample) AddFloatList(name string, floats []float32)
- func (e *TFExample) AddImage(name string, img image.Image) error
- func (e *TFExample) AddInt(name string, ints ...int)
- func (e *TFExample) AddInt64(name string, ints ...int64)
- func (e *TFExample) AddInt64List(name string, ints []int64)
- func (e *TFExample) AddIntList(name string, ints []int)
- func (e *TFExample) GetBytesList(name string) []byte
- func (e *TFExample) GetFeature(name string) *proto.Feature
- func (e *TFExample) GetFloat(name string) float32
- func (e *TFExample) GetFloatList(name string) []float32
- func (e *TFExample) GetImage(name string) (image.Image, error)
- func (e *TFExample) GetInt64(name string) int64
- func (e *TFExample) GetInt64List(name string) []int64
- func (e *TFExample) HasFeature(name string) bool
- func (e *TFExample) SetFeature(name string, feature *proto.Feature)
- type TFExampleChannel
- type TFExampleReadWriter
- type TFExampleReader
- type TFExampleWriter
- type TFFeatureEnum
- type TFFeatureType
- type TFRecordReader
- type TFRecordReaderInterface
- type TFRecordWriter
- func (w *TFRecordWriter) Write(p []byte) (n int, err error)
- func (w *TFRecordWriter) WriteExample(example *TFExample) (n int, err error)
- func (w *TFRecordWriter) WriteExamples(ch <-chan *TFExample) error
- func (w *TFRecordWriter) WriteMessage(message protoreflect.ProtoMessage) (n int, err error)
- func (w *TFRecordWriter) WriteMessages(reader TFExampleReader) error
- func (w *TFRecordWriter) WriteMessagesAsync(reader TFExampleReader, numWorkers int) error
- type TFRecordWriterInterface
- type TypesMap
Constants ¶
const KeyEntry = "__key__"
Variables ¶
var FeatureType = &TFFeatureEnum{}
Functions ¶
This section is empty.
Types ¶
type SampleChannel ¶
type SampleChannel struct {
// contains filtered or unexported fields
}
func NewSampleChannel ¶
func NewSampleChannel(bufSize int) *SampleChannel
func (*SampleChannel) Close ¶
func (c *SampleChannel) Close()
func (*SampleChannel) Read ¶
func (c *SampleChannel) Read() (*Sample, error)
func (*SampleChannel) Write ¶
func (c *SampleChannel) Write(sample *Sample) error
type SampleReadWriter ¶
type SampleReadWriter interface { SampleReader SampleWriter }
type SampleReader ¶
SampleReader / SampleWriter Returns io.EOF if there's nothing left to be read
type SampleWriter ¶
type TFExample ¶
TFExample is a wrapper over proto.Example struct generated by protoc from TensorFlow tf.Example proto files. It is a golang representation of tf.Example datastructure. It includes functions for adding elements to tf.Example.Features.
func NewTFExample ¶
func NewTFExample() *TFExample
NewTFExample initializes empty TFExample and returns it.
func (*TFExample) AddBytesList ¶
func (*TFExample) AddFloatList ¶
func (*TFExample) AddInt64List ¶
func (*TFExample) AddIntList ¶
func (*TFExample) GetBytesList ¶
func (*TFExample) GetFloatList ¶
func (*TFExample) GetInt64List ¶
func (*TFExample) HasFeature ¶
type TFExampleChannel ¶
type TFExampleChannel struct {
// contains filtered or unexported fields
}
func NewTFExampleChannel ¶
func NewTFExampleChannel(bufSize int) *TFExampleChannel
func (*TFExampleChannel) Close ¶
func (c *TFExampleChannel) Close()
func (*TFExampleChannel) Read ¶
func (c *TFExampleChannel) Read() (*TFExample, error)
func (*TFExampleChannel) Write ¶
func (c *TFExampleChannel) Write(example *TFExample) error
type TFExampleReadWriter ¶
type TFExampleReadWriter interface { TFExampleReader TFExampleWriter }
type TFExampleReader ¶
TFExampleReader / TFExampleWriter Returns io.EOF if there's nothing left to be read
type TFExampleWriter ¶
type TFFeatureEnum ¶
type TFFeatureEnum struct { INT64 *cmn.TFFeatureInt INT64LIST *cmn.TFFeatureIntList FLOAT32 *cmn.TFFeatureFloat FLOAT32LIST *cmn.TFFeatureFloatList BYTES *cmn.TFFeatureBytes BYTESLIST *cmn.TFFeatureBytesList }
type TFFeatureType ¶
type TFFeatureType interface {
FeatureType() int
}
type TFRecordReader ¶
type TFRecordReader struct {
// contains filtered or unexported fields
}
TFRecordReader implements TFRecordReader interface It reads objects from reader r and verify checksums with c
func NewTFRecordReader ¶
func NewTFRecordReader(r io.Reader) *TFRecordReader
NewTFRecordReader creates and initializes TFRecordReader with writer w and CRC checksumming method. Returns pointer to created TFRecordReader
func (*TFRecordReader) Read ¶
func (r *TFRecordReader) Read() (*TFExample, error)
func (*TFRecordReader) ReadAllExamples ¶
func (r *TFRecordReader) ReadAllExamples(expectedSize ...int) ([]*TFExample, error)
ReadAllExamples reads examples from TFRecord until EOF and loads them into memory If error occurred it terminates immediately without reading subsequent samples Returns slice of examples and error if occurred.
func (*TFRecordReader) ReadExamples ¶
func (r *TFRecordReader) ReadExamples(writer TFExampleWriter) error
ReadExamples reads and puts into ch examples from TFRecord one-by-one It error occurred, ReadExamples terminates immediately, without processing subsequent samples. ReadExamples closes ch upon termination.
type TFRecordReaderInterface ¶
type TFRecordReaderInterface interface { ReadNext(protobuf.Message) error Read() (*TFExample, error) ReadAllExamples(expectedSize ...int) ([]*TFExample, error) ReadExamples(writer TFExampleWriter) error }
TFRecordReaderInterface is an interface which reads objects from TFRecord format TFRecord format is described here: https://www.tensorflow.org/tutorials/load_data/tfrecord#tfrecords_format_details
type TFRecordWriter ¶
type TFRecordWriter struct {
// contains filtered or unexported fields
}
TFRecordWriter implements TFRecordWriter interface It writes objects into writer w with checksums provided by c
func NewTFRecordWriter ¶
func NewTFRecordWriter(w io.Writer) *TFRecordWriter
NewTFRecordWriter creates and initializes TFRecordWriter with writer w and CRC checksumming method. Returns pointer to created TFRecordWriter
func (*TFRecordWriter) Write ¶
func (w *TFRecordWriter) Write(p []byte) (n int, err error)
Write writes p into writer into format specified in https://www.tensorflow.org/tutorials/load_data/tfrecord#tfrecords_format_details. If any of underlying writes to internal writer fails, number or already written bytes and error is returned Write is not atomic, meaning that underlying write error might leave internal writer in invalid TFRecord state Returns total number of written bytes and error if occurred
func (*TFRecordWriter) WriteExample ¶
func (w *TFRecordWriter) WriteExample(example *TFExample) (n int, err error)
func (*TFRecordWriter) WriteExamples ¶
func (w *TFRecordWriter) WriteExamples(ch <-chan *TFExample) error
WriteExamples behaves the same as WriteMessages but operates on channel of TFExamples
func (*TFRecordWriter) WriteMessage ¶
func (w *TFRecordWriter) WriteMessage(message protoreflect.ProtoMessage) (n int, err error)
WriteMessage marshals message and writes it to TFRecord
func (*TFRecordWriter) WriteMessages ¶
func (w *TFRecordWriter) WriteMessages(reader TFExampleReader) error
WriteMessages reads and writes to TFRecord messages one-by-one from ch and terminates when ch is closed and empty. WriteMessages doesn't close ch itself. Returns error immediately if occurred, without processing subsequent messages
func (*TFRecordWriter) WriteMessagesAsync ¶
func (w *TFRecordWriter) WriteMessagesAsync(reader TFExampleReader, numWorkers int) error
Reads TFExamples from reader asynchronously and writes synchronously to w.Writer TFRecordWriter is last element of a pipeline, if it makes Reads asynchronously All underlying readers will be called asynchronously. They all should be async-safe Almost all of transformations
type TFRecordWriterInterface ¶
type TFRecordWriterInterface interface { io.Writer WriteMessage(protobuf.Message) (n int, err error) WriteExample(*TFExample) (n int, err error) WriteMessages(reader TFExampleReader) error }
TFRecordWriterInterface is an interface which writes objects in TFRecord format. TFRecord format is described here: https://www.tensorflow.org/tutorials/load_data/tfrecord#tfrecords_format_details
type TypesMap ¶
type TypesMap map[string]TFFeatureType
Defines types mapping of Sample entries to TFExample. TypesMap key corresponds to Sample key and TFFeatureType is one of: TFFeatureType.INT64, TFFeatureType.INT64LIST, TFFeatureType.FLOAT32, TFFeatureType.FLOAT32LIST, TFFeatureType.FLOAT32, TFFeatureType.FLOAT32LIST, TFFeatureType.BYTES, TFFeatureType.BYTESLIST