numcodecs_wasm_stochastic_rounding
Classes:
-
StochasticRounding–Codec that stochastically rounds the data to the nearest multiple of
StochasticRounding
StochasticRounding(precision, seed, _version='1.0.0')
Codec that stochastically rounds the data to the nearest multiple of
precision on encoding and passes through the input unchanged during
decoding.
The nearest representable multiple is chosen such that the absolute difference between the original value and the rounded value do not exceed the precision. Therefore, the rounded value may have a non-zero remainder.
This codec first hashes the input array data and shape to then seed a
pseudo-random number generator that is used to sample the stochasticity for
rounding. Therefore, passing in the same input with the same seed will
produce the same stochasticity and thus the same encoded output.
| Parameters: |
|
|---|
Methods:
-
decode–Decode the data in
buf. -
encode–Encode the data in
buf. -
from_config–Instantiate the codec from a configuration
dict. -
get_config–Returns the configuration of the codec.
codec_id
class-attribute
instance-attribute
codec_id = 'stochastic-rounding.rs'
decode
decode(buf, out=None)
Decode the data in buf.
| Parameters: |
|
|---|
| Returns: |
|
|---|
encode
encode(buf)
Encode the data in buf.
| Parameters: |
|
|---|
| Returns: |
|
|---|
from_config
classmethod
from_config(config)
get_config
get_config()
Returns the configuration of the codec.
numcodecs.registry.get_codec(config)
can be used to reconstruct this codec from the returned config.
| Returns: |
|
|---|