Spaces
ConstantSpace
dataclass
Bases: SpaceType
Represents a constant value repeated multiple times.
This class generates a tensor containing the same constant value repeated
num
times.
Attributes:
Name | Type | Description |
---|---|---|
value |
float
|
The constant float value to be used. |
num |
int | None
|
The number of times the constant value should be repeated. Defaults to 1. |
Source code in src/einmesh/spaces.py
Distribution
dataclass
LgSpace
dataclass
Bases: LogSpace
Represents a sequence of points spaced in base 2.
Source code in src/einmesh/spaces.py
LinSpace
dataclass
Bases: SpaceType
Represents a sequence of points spaced linearly.
This class generates a tensor of num
points evenly spaced between start
and end
(inclusive).
Attributes:
Name | Type | Description |
---|---|---|
start |
float
|
The starting value of the sequence. |
end |
float
|
The ending value of the sequence. |
num |
int
|
The number of points to generate. |
Source code in src/einmesh/spaces.py
ListSpace
dataclass
Bases: SpaceType
Represents a predefined list of values.
This class generates a tensor directly from a provided list of float values. The number of points generated is equal to the length of the input list.
Attributes:
Name | Type | Description |
---|---|---|
values |
list[float]
|
A list of float values to be converted into a tensor. |
num |
int
|
The number of points, automatically set to length of values. |
Source code in src/einmesh/spaces.py
LnSpace
dataclass
Bases: LogSpace
Represents a sequence of points spaced in base e.
Source code in src/einmesh/spaces.py
LogSpace
dataclass
Bases: SpaceType
Represents a sequence of points spaced logarithmically.
This class generates a tensor of num
points between 10**start
and 10**end
(or base**start
and base**end
if base
is specified), spaced
logarithmically.
Attributes:
Name | Type | Description |
---|---|---|
start |
float
|
The starting exponent of the sequence. |
end |
float
|
The ending exponent of the sequence. |
num |
int
|
The number of points to generate. |
base |
float
|
The base of the logarithm. Defaults to 10. |
Source code in src/einmesh/spaces.py
_generate_samples(backend)
Generates the logarithmically spaced points.
NormalDistribution
dataclass
Bases: Distribution
Represents a sampling from a normal (Gaussian) distribution.
This class generates a tensor of num
random numbers sampled from a normal
distribution with the specified mean
and standard deviation std
.
Attributes:
Name | Type | Description |
---|---|---|
mean |
float
|
The mean (center) of the normal distribution. |
std |
float
|
The standard deviation (spread or width) of the normal distribution. |
num |
int
|
The number of samples to generate. |
Source code in src/einmesh/spaces.py
_generate_samples(backend)
RangeSpace
dataclass
Bases: SpaceType
Return evenly spaced values within a given interval.
This class generates a tensor of num
points evenly spaced between start
and end
(inclusive). It works like a arange function of numpy, torch or jax.
Attributes:
Name | Type | Description |
---|---|---|
start |
float
|
The starting value of the sequence. |
end |
float
|
The ending value of the sequence. |
num |
float
|
The number of points to generate. |
Source code in src/einmesh/spaces.py
_generate_samples(backend)
SpaceType
dataclass
Bases: ABC
Base class for all space types.
Source code in src/einmesh/spaces.py
_apply_operators(sample, backend)
Apply the operators to the space type.
_generate_samples(backend)
abstractmethod
_sample(backend)
_with_operator(operator, prepend=False)
Return a copy of this space with the given operator applied.
Source code in src/einmesh/spaces.py
_with_operators(operators, prepend=False)
Return a copy of this space with multiple operators applied.
Source code in src/einmesh/spaces.py
UniformDistribution
dataclass
Bases: Distribution
Represents a sampling from a uniform distribution.
This class generates a tensor of num
random numbers sampled from a uniform
distribution over the interval [low
, high
).
Attributes:
Name | Type | Description |
---|---|---|
low |
float
|
The lower boundary of the output interval. |
high |
float
|
The upper boundary of the output interval. |
num |
int
|
The number of samples to generate. |
Source code in src/einmesh/spaces.py
_generate_samples(backend)
Generates samples from the uniform distribution.