mnist-idx-0.1.2.8: Read and write IDX data that is used in e.g. the MNIST database.

CopyrightChristof Schramm
LicenseGPLv3
MaintainerChristof Schramm <christof.schramm@campus.lmu.de>
StabilityExperimental
PortabilityShoud work with all major haskell implementations
Safe HaskellNone
LanguageHaskell2010

Data.IDX.Internal

Description

An internal package, the API contained here should not be used and is subject to possibly breaking changes. Use these functions and types at your own risk.

The safe interface is in IDX

Synopsis

Documentation

data IDXData Source #

Datatype for storing IDXData. Internally data is always stored either as Int or Double unboxed vectors. However when binary serialization is used, the data is serialized according to the IDXContentType.

newtype IDXLabels Source #

A data type that holds Int labels for a set of IDXData

Constructors

IDXLabels (Vector Int) 

idxType :: IDXData -> IDXContentType Source #

Return the what type the data is stored in

idxDimensions :: IDXData -> Vector Int Source #

Return an unboxed Vector of Int dimensions

isIDXIntegral :: IDXData -> Bool Source #

Return wether the data in this IDXData value is stored as integral values

isIDXReal :: IDXData -> Bool Source #

Return wether the data in this IDXData value is stored as double values

idxIntContent :: IDXData -> Vector Int Source #

Return contained ints, if no ints are contained, convert content to ints by using round. Data is stored like in a C-array, i.e. the last index changes first.

idxDoubleContent :: IDXData -> Vector Double Source #

Return contained doubles, if no doubles are contained convert the content to double by using fromIntegral. Data is stored like in a C-array, i.e. the last index changes first.

readContent Source #

Arguments

:: Unbox a 
=> (Int -> Get (Vector a))

To Get a chunk of size n

-> Int

Chunk size

-> Int

Expected input

-> Get (Vector a) 

Helper function to read a (possibly big) vector of binary values as chunks. Strictly evaluates each chunk and then concatenates the chunks, does not leak space.

buildIntResult Source #

Arguments

:: Integral a 
=> Int

Expected number of entries

-> IDXContentType

Description of content

-> Vector Int

Dimension sizes

-> Get a

Monadic action to get content element

-> Get IDXData 

Helper function for parsing integer data from the IDX content. Returns a full IDX result.

buildDoubleResult Source #

Arguments

:: Real a 
=> Int

Expected number of entries

-> IDXContentType

Description of content

-> Vector Int

Dimension sizes

-> Get a

Monadic action to get content element

-> Get IDXData 

Helper function for parsing real number data from the IDX content.

putIntegral :: IDXContentType -> Int -> Put Source #

Put values that are saved as Int

putReal :: IDXContentType -> Double -> Put Source #

Put real values that are saved as Double