Exemple #1
0
 def random(self, size=None):
     return JaxArray(
         jr.uniform(self.split_key(),
                    shape=_size2shape(size),
                    minval=0.,
                    maxval=1.))
Exemple #2
0
def fftfreq(n, d=1.0):
    return JaxArray(jax.numpy.fft.fftfreq(n=n, d=d))
Exemple #3
0
def ifft(a, n=None, axis=-1, norm=None):
    a = as_device_array(a)
    return JaxArray(jax.numpy.fft.ifft(a=a, n=n, axis=axis, norm=norm))
Exemple #4
0
def standard_normal(size=None):
    return JaxArray(jr.normal(DEFAULT.split_key(), shape=_size2shape(size)))
Exemple #5
0
def uniform(low=0.0, high=1.0, size=None):
    return JaxArray(
        jr.uniform(DEFAULT.split_key(),
                   shape=_size2shape(size),
                   minval=low,
                   maxval=high))
Exemple #6
0
def poisson(lam=1.0, size=None):
    return JaxArray(
        jr.poisson(DEFAULT.split_key(), lam=lam, shape=_size2shape(size)))
Exemple #7
0
def standard_exponential(size=None):
    return JaxArray(
        jr.exponential(DEFAULT.split_key(), shape=_size2shape(size)))
Exemple #8
0
 def bernoulli(self, p, size=None):
     return JaxArray(
         jr.bernoulli(self.split_key(), p=p, shape=_size2shape(size)))
Exemple #9
0
def rand(*dn):
    return JaxArray(
        jr.uniform(DEFAULT.split_key(), shape=dn, minval=0., maxval=1.))
Exemple #10
0
 def pareto(self, a, size=None):
     return JaxArray(
         jr.pareto(self.split_key(), b=a, shape=_size2shape(size)))
Exemple #11
0
 def truncated_normal(self, lower, upper, size, scale=1.):
     rands = jr.truncated_normal(self.split_key(),
                                 lower=lower,
                                 upper=upper,
                                 shape=_size2shape(size))
     return JaxArray(rands * scale)
Exemple #12
0
 def laplace(self, loc=0.0, scale=1.0, size=None):
     assert loc == 0.
     assert scale == 1.
     return JaxArray(jr.laplace(self.split_key(), shape=_size2shape(size)))
Exemple #13
0
 def shuffle(self, x, axis=0):
     x = x.value if isinstance(x, JaxArray) else x
     return JaxArray(jr.shuffle(self.split_key(), x, axis=axis))
Exemple #14
0
 def permutation(self, x):
     x = x.value if isinstance(x, JaxArray) else x
     return JaxArray(jr.permutation(self.split_key(), x))
Exemple #15
0
def normal(loc=0.0, scale=1.0, size=None):
    return JaxArray(
        jr.normal(DEFAULT.split_key(), shape=_size2shape(size)) * scale + loc)
Exemple #16
0
def randn(*dn):
    return JaxArray(jr.normal(DEFAULT.split_key(), shape=dn))
Exemple #17
0
def pareto(a, size=None):
    return JaxArray(
        jr.pareto(DEFAULT.split_key(), b=a, shape=_size2shape(size)))
Exemple #18
0
def random_sample(size=None):
    return JaxArray(
        jr.uniform(DEFAULT.split_key(),
                   shape=_size2shape(size),
                   minval=0.,
                   maxval=1.))
Exemple #19
0
def standard_cauchy(size=None):
    return JaxArray(jr.cauchy(DEFAULT.split_key(), shape=_size2shape(size)))
Exemple #20
0
def shuffle(x):
    x = x.value if isinstance(x, JaxArray) else x
    return JaxArray(jr.permutation(DEFAULT.split_key(), x))
Exemple #21
0
def standard_gamma(shape, size=None):
    return JaxArray(
        jr.gamma(DEFAULT.split_key(), a=shape, shape=_size2shape(size)))
Exemple #22
0
def beta(a, b, size=None):
    a = a.value if isinstance(a, JaxArray) else a
    b = b.value if isinstance(b, JaxArray) else b
    return JaxArray(
        jr.beta(DEFAULT.split_key(), a=a, b=b, shape=_size2shape(size)))
Exemple #23
0
def standard_t(df, size=None):
    return JaxArray(jr.t(DEFAULT.split_key(), df=df, shape=_size2shape(size)))
Exemple #24
0
def exponential(scale=1.0, size=None):
    assert scale == 1.
    return JaxArray(
        jr.exponential(DEFAULT.split_key(), shape=_size2shape(size)))
Exemple #25
0
def fft2(a, s=None, axes=(-2, -1), norm=None):
    a = as_device_array(a)
    return JaxArray(jax.numpy.fft.fft2(a=a, s=s, axes=axes, norm=norm))
Exemple #26
0
def gamma(shape, scale=1.0, size=None):
    assert scale == 1.
    return JaxArray(
        jr.gamma(DEFAULT.split_key(), a=shape, shape=_size2shape(size)))
Exemple #27
0
def fftshift(x, axes=None):
    if isinstance(x, JaxArray): x = x.value
    return JaxArray(jax.numpy.fft.fftshift(x=x, axes=axes))
Exemple #28
0
def logistic(loc=0.0, scale=1.0, size=None):
    assert loc == 0.
    assert scale == 1.
    return JaxArray(jr.logistic(DEFAULT.split_key(), shape=_size2shape(size)))
Exemple #29
0
def ifftn(a, s=None, axes=None, norm=None):
    a = as_device_array(a)
    return JaxArray(jax.numpy.fft.ifftn(a=a, s=s, axes=axes, norm=norm))
Exemple #30
0
 def randn(self, *dn):
     return JaxArray(jr.normal(self.split_key(), shape=dn))