Documentation
¶
Overview ¶
Package data is a collection of tools that facilitate data loading and preprocessing.
Index ¶
- func Download(url, path string) (size int64, err error)
- func DownloadAndUntarIfMissing(url, baseDir, tarFile, dataDir, checkHash string) error
- func DownloadAndUnzipIfMissing(url, zipFile, unzipBaseDir, targetUnzipDir, checkHash string) error
- func DownloadIfMissing(url, path, checkHash string) error
- func FileExists(path string) bool
- func ReplaceTildeInDir(dir string) string
- func Untar(baseDir, tarFile string) error
- func Unzip(zipFile, zipBaseDir string) error
- func ValidateChecksum(path, checkHash string) error
- type ParallelDataset
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DownloadAndUntarIfMissing ¶
DownloadAndUntarIfMissing downloads tarFile from given url, if file not there yet, and then untar it if the target directory is missing.
If checkHash is provided, it checks that the file has the hash or fail.
func DownloadAndUnzipIfMissing ¶
DownloadAndUnzipIfMissing downloads zipFile from given url, if file not there yet, and then unzip it under directory `unzipBaseDir`. If the target `targetUnzipDir` directory is missing.
If checkHash is provided, it checks that the file has the hash or fail.
func DownloadIfMissing ¶
DownloadIfMissing will check if the path exists already, and if not it will download the file from the given URL.
If checkHash is provided, it checks that the file has the hash or fail.
func FileExists ¶
FileExists returns true if file or directory exists.
func ReplaceTildeInDir ¶
ReplaceTildeInDir by the user's home directory. Returns dir if it doesn't start with "~".
func Untar ¶
Untar file, using decompression flags according to suffix: .gz for gzip, bz2 for bzip2.
func ValidateChecksum ¶
ValidateChecksum verifies that the checksum of the file in the given path matches the checksum given. If it fails, it will remove the file (!) and return and error.
Types ¶
type ParallelDataset ¶
type ParallelDataset struct {
Dataset train.Dataset
// Parallelism is the number of goroutines started generating examples.
Parallelism int
// BufferSize is the size of the cache of pre-generated batches.
BufferSize int
// contains filtered or unexported fields
}
ParallelDataset is a wrapper around a `train.Dataset` that parallelize calls to Yield.
func NewParallelDataset ¶
func NewParallelDataset(ds train.Dataset, parallelism, bufferSize int) *ParallelDataset
NewParallelDataset starts building a ParallelDataset that can be used to parallelize any train.Dataset, as long as the underlying dataset ds is thread-safe.
parallelism is the number of goroutines to start, each calling `ds.Yield()` in parallel to accelerate the generation of batches. Set to 0, and it will use the number of cores in the system plus 1.
bufferSize is the space reserved to keep pre-generated batches. This is on top of the batches being generated in each goroutine.
To avoid leaking goroutines, call ParallelDataset.Cancel when exiting.
func (*ParallelDataset) Name ¶
func (pd *ParallelDataset) Name() string
Name implements train.Dataset.