Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
replaytables-andnp
A simple replay buffer implementation in python for sampling n-step trajectories
Readme
Installation:
pip install ReplayTables-andnp
Basic usage:
from typing import NamedTuple
from ReplayTables.ReplayBuffer import ReplayBuffer
class Data(NamedTuple):
x: np.ndarray
a: np.ndarray
r: np.ndarray
buffer = ReplayBuffer(
max_size=100_000,
structure=Data,
rng=np.random.default_rng(0),
)
buffer.add(Data(x, a, r))
batch = buffer.sample(32)
print(batch.x.shape) # -> (32, d)
print(batch.a.shape) # -> (32, )
print(batch.r.shape) # -> (32, )
An implementation of prioritized experience replay from
Schaul, Tom, et al. "Prioritized experience replay." ICLR (2016).
The defaults for this implementation strictly adhere to the defaults from the original work, though several configuration options are available.
from typing import NamedTuple
from ReplayTables.PER import PERConfig, PrioritizedReplay
class Data(NamedTuple):
a: float
b: float
# all configurables are optional.
config = PERConfig(
# can also use "mean" mode to place new samples in the middle of the distribution
# or "given" mode, which requires giving the priority when the sample is added
new_priority_mode='max',
# the sampling distribution is a mixture between uniform sampling and the priority
# distribution. This specifies the weight given to the uniform sampler.
# Setting to 1 reverts this back to an inefficient form of standard uniform replay.
uniform_probability=1e-3,
# this implementation assume priorities are positive. Can scale priorities by raising to
# some power. Default is `priority**(1/2)`
priority_exponent=0.5,
# if `new_priority_mode` is 'max', then the buffer tracks the highest seen priority.
# this can cause accidental saturation if outlier priorities are observed. This provides
# an exponential decay of the max in order to prevent permanent saturation.
max_decay=1,
)
# if no config is given, defaults to original PER parameters
buffer = PrioritizedReplay(
max_size=100_000,
structure=Data,
rng=np.random.default_rng(0),
config=config,
)
buffer.add(Data(a=1, b=2))
# if `new_priority_mode` is 'given':
buffer.add(Data(a=1, b=2), priority=1.3)
batch = buffer.sample(32)
FAQs
A simple replay buffer implementation in python for sampling n-step trajectories
We found that replaytables-andnp demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.