hasktorch-indef-0.0.1.0: Core Hasktorch abstractions wrapping FFI bindings

Copyright(c) Sam Stites 2017
LicenseBSD3
Maintainersam@stites.io
Stabilityexperimental
Portabilitynon-portable
Safe HaskellNone
LanguageHaskell2010

Torch.Indef.Dynamic.Tensor.Random.TH

Description

Torch provides accurate mathematical random generation, based on Mersenne Twister random number generator.

FIXME: verify these are all correct -- I am working off of <https://github.com/torch/torch7/blob/aed31711c6b8846b8337a263a7f9f998697994e7/doc/random.md random.md> from torch/torch7.

Synopsis

Documentation

_random :: Dynamic -> Generator -> IO () Source #

call C-level random

random :: Dims (d :: [Nat]) -> Generator -> IO Dynamic Source #

Returns a tensor of specified size with random numbers from [1,2^mantissa].

_clampedRandom :: Integral a => Dynamic -> Generator -> Ord2Tuple a -> IO () Source #

call C-level clampedRandom

clampedRandom Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> Ord2Tuple Integer

(minbound, maxBound)

-> IO Dynamic 

Returns a tensor of specified size with random numbers from [minBound,maxBound].

_cappedRandom :: Integral a => Dynamic -> Generator -> a -> IO () Source #

call C-level cappedRandom

cappedRandom Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> Word64

maxbound

-> IO Dynamic 

Returns a tensor of specified size with random numbers from [0,maxBound].

_geometric :: Dynamic -> Generator -> HsAccReal -> IO () Source #

call C-level geometric

geometric Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> OpenUnit HsAccReal

p, where 0 < p < 1

-> IO Dynamic 

Returns a random tensor according to a geometric distribution p(i) = (1-p) * p^(i-1). p must satisfy 0 < p < 1.

_bernoulli :: Dynamic -> Generator -> HsAccReal -> IO () Source #

call C-level bernoulli

bernoulli Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> ClosedUnit HsAccReal

p, where 0 <= p <= 1

-> IO Dynamic 

Returns a tensor filled with elements which are 1 with probability p and 0 with probability 1-p. p must satisfy 0 <= p <= 1.

_bernoulli_FloatTensor :: Dynamic -> Generator -> FloatDynamic -> IO () Source #

call C-level bernoulli_FloatTensor

bernoulli_FloatTensor Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> FloatDynamic

float tensor of p values, where 0 <= p <= 1

-> IO Dynamic 

Undocumented in Lua. It is assumed that this returns a tensor filled with elements which are 1 with probability p and 0 with probability 1-p, where p comes from the FloatDynamic tensor. All ps must satisfy 0 <= p <= 1. It is uncertain if the output dimensions and the FloatDynamic tensor dimensions need to match.

_bernoulli_DoubleTensor :: Dynamic -> Generator -> DoubleDynamic -> IO () Source #

call C-level bernoulli_DoubleTensor

bernoulli_DoubleTensor Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> DoubleDynamic

double tensor of p values, where 0 <= p <= 1

-> IO Dynamic 

Undocumented in Lua. It is assumed that this returns a tensor filled with elements which are 1 with probability p and 0 with probability 1-p, where p comes from the DoubleDynamic tensor. All ps must satisfy 0 <= p <= 1. It is uncertain if the output dimensions and the DoubleDynamic tensor dimensions need to match.

_uniform :: Dynamic -> Generator -> Ord2Tuple HsAccReal -> IO () Source #

call C-level uniform

uniform Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> Ord2Tuple HsAccReal

tuple of (a, b) representing the [a,b) interval.

-> IO Dynamic 

Returns a tensor filled with values according to uniform distribution on [a,b).

_normal :: Dynamic -> Generator -> HsAccReal -> Positive HsAccReal -> IO () Source #

call C-level normal

normal Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> HsAccReal

mean

-> Positive HsAccReal

standard deviation.

-> IO Dynamic 

Returns a tensor filled with values according to a normal distribution with the given mean and standard deviation stdv. stdv must be positive.

_normal_means :: Dynamic -> Generator -> Dynamic -> Positive HsAccReal -> IO () Source #

call C-level normal_means

normal_means Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> Dynamic

tensor of means

-> Positive HsAccReal

standard deviation.

-> IO Dynamic 

Same as normal, taking a tensor of means to use instead of a scalar.

FIXME: It is uncertain if the output dimensions and mean tensor dimensions need to match.

_normal_stddevs :: Dynamic -> Generator -> HsAccReal -> Dynamic -> IO () Source #

call C-level normal_stddevs

normal_stddevs Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> HsAccReal

mean

-> Dynamic

tensor of standard deviations

-> IO Dynamic 

Same as normal, taking a tensor of standard deviations to use instead of a scalar. All standard deviations must be positive.

FIXME: It is uncertain if the output dimensions and stddv tensor dimensions need to match.

_normal_means_stddevs :: Dynamic -> Generator -> Dynamic -> Dynamic -> IO () Source #

call C-level normal_means_stddevs

normal_means_stddevs Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> Dynamic

tensor of means

-> Dynamic

tensor of standard deviations

-> IO Dynamic 

Same as normal, taking a tensor of standard deviations and tensor of means to use instead of a scalar values. All standard deviations must be positive.

FIXME: It is uncertain if all of the tensor dimensions need to match.

_exponential :: Dynamic -> Generator -> HsAccReal -> IO () Source #

call C-level exponential

exponential Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> HsAccReal

lambda

-> IO Dynamic 

Returns a tensor filled with values according to the exponential distribution p(x) = lambda * exp(-lambda * x).

_standard_gamma :: Dynamic -> Generator -> Dynamic -> IO () Source #

call C-level standard_gamma

standard_gamma Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> Dynamic 
-> IO Dynamic 

Draw samples from a standard Gamma distribution.

PyTorch's standard_gamma function mostly references Numpy's. Documentation can be found here: numpy.random.standard_gamma

I (stites) am not sure at the moment if the tensor argument is a tensor of parameters (in which case, can we replace it with something safer?), or a datasource.

FIXME(stites): This is an undocumented feature as far as I can tell. Someone should update this with a more thorough investigation.

_cauchy :: Dynamic -> Generator -> HsAccReal -> HsAccReal -> IO () Source #

call C-level cauchy

cauchy Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> HsAccReal

median

-> HsAccReal

sigma

-> IO Dynamic 

Returns a tensor filled with values according to the Cauchy distribution p(x) = sigma/(pi*(sigma^2 + (x-median)^2))

_logNormal :: Dynamic -> Generator -> HsAccReal -> Positive HsAccReal -> IO () Source #

call C-level logNormal

logNormal Source #

Arguments

:: Dims (d :: [Nat])

size of tensor to create

-> Generator

generator

-> HsAccReal

mean

-> Positive HsAccReal

standard deviation.

-> IO Dynamic 

Returns a tensor filled with values according to the log-normal distribution with the given mean and standard deviation stdv. mean and stdv are the corresponding mean and standard deviation of the underlying normal distribution, and not of the returned distribution.

stdv must be positive.

_multinomial :: LongDynamic -> Generator -> Dynamic -> Int -> Int -> IO () Source #

call C-level multinomial

_multinomialAliasSetup :: Dynamic -> LongDynamic -> Dynamic -> IO () Source #

call C-level multinomialAliasSetup

_multinomialAliasDraw :: LongDynamic -> Generator -> LongDynamic -> Dynamic -> IO () Source #

call C-level multinomialAliasDraw

data OpenUnit x #

Datatype to represent the open unit interval: 0 < x < 1. Any OpenUnit inhabitant must satisfy being in the interval.

FIXME: replace with numhask.

Instances
Eq x => Eq (OpenUnit x) 
Instance details

Defined in Torch.Types.Numeric

Methods

(==) :: OpenUnit x -> OpenUnit x -> Bool #

(/=) :: OpenUnit x -> OpenUnit x -> Bool #

Ord x => Ord (OpenUnit x) 
Instance details

Defined in Torch.Types.Numeric

Methods

compare :: OpenUnit x -> OpenUnit x -> Ordering #

(<) :: OpenUnit x -> OpenUnit x -> Bool #

(<=) :: OpenUnit x -> OpenUnit x -> Bool #

(>) :: OpenUnit x -> OpenUnit x -> Bool #

(>=) :: OpenUnit x -> OpenUnit x -> Bool #

max :: OpenUnit x -> OpenUnit x -> OpenUnit x #

min :: OpenUnit x -> OpenUnit x -> OpenUnit x #

Show x => Show (OpenUnit x) 
Instance details

Defined in Torch.Types.Numeric

Methods

showsPrec :: Int -> OpenUnit x -> ShowS #

show :: OpenUnit x -> String #

showList :: [OpenUnit x] -> ShowS #

openUnit :: (Ord x, Num x) => x -> Maybe (OpenUnit x) #

smart constructor to place a number in the open unit interval.

openUnitValue :: OpenUnit x -> x #

Get a value from the open unit interval.

data ClosedUnit x #

Datatype to represent the closed unit interval: 0 =< x =< 1. Any ClosedUnit inhabitant must satisfy being in the interval.

FIXME: replace with numhask.

Instances
Eq x => Eq (ClosedUnit x) 
Instance details

Defined in Torch.Types.Numeric

Methods

(==) :: ClosedUnit x -> ClosedUnit x -> Bool #

(/=) :: ClosedUnit x -> ClosedUnit x -> Bool #

Ord x => Ord (ClosedUnit x) 
Instance details

Defined in Torch.Types.Numeric

Show x => Show (ClosedUnit x) 
Instance details

Defined in Torch.Types.Numeric

closedUnit :: (Ord x, Num x) => x -> Maybe (ClosedUnit x) #

smart constructor to place a number in the closed unit interval.

closedUnitValue :: ClosedUnit x -> x #

Get a value from the closed unit interval.

data Positive x #

Datatype to represent a generic positive number: 0 =< x.

FIXME: replace with numhask.

Instances
Eq x => Eq (Positive x) 
Instance details

Defined in Torch.Types.Numeric

Methods

(==) :: Positive x -> Positive x -> Bool #

(/=) :: Positive x -> Positive x -> Bool #

Ord x => Ord (Positive x) 
Instance details

Defined in Torch.Types.Numeric

Methods

compare :: Positive x -> Positive x -> Ordering #

(<) :: Positive x -> Positive x -> Bool #

(<=) :: Positive x -> Positive x -> Bool #

(>) :: Positive x -> Positive x -> Bool #

(>=) :: Positive x -> Positive x -> Bool #

max :: Positive x -> Positive x -> Positive x #

min :: Positive x -> Positive x -> Positive x #

Show x => Show (Positive x) 
Instance details

Defined in Torch.Types.Numeric

Methods

showsPrec :: Int -> Positive x -> ShowS #

show :: Positive x -> String #

showList :: [Positive x] -> ShowS #

positive :: (Ord x, Num x) => x -> Maybe (Positive x) #

smart constructor to place a number in a positive bound.

positiveValue :: Positive x -> x #

Get a value from the positive bound.

data Ord2Tuple x #

Datatype to represent an ordered pair of numbers, (a, b), where a <= b.

FIXME: replace with numhask.

Instances
Eq x => Eq (Ord2Tuple x) 
Instance details

Defined in Torch.Types.Numeric

Methods

(==) :: Ord2Tuple x -> Ord2Tuple x -> Bool #

(/=) :: Ord2Tuple x -> Ord2Tuple x -> Bool #

Show x => Show (Ord2Tuple x) 
Instance details

Defined in Torch.Types.Numeric

ord2Tuple :: (Ord x, Num x) => (x, x) -> Maybe (Ord2Tuple x) #

smart constructor to place two values in an ordered tuple.

ord2TupleValue :: Ord2Tuple x -> (x, x) #

Get the values of an ordered tuple.