Skip to main content
# Priority Memory

A prioritized sampling tool for priority memory replay.

The implementation is based on sum tree, or segmentation tree.

- Set the priority of each sample at anytime.
- When you do not know the priority of the sample, you can append
them to the buffer, and they will show up in the next sampling batch.
- When the buffer is full, drop the samples with lowest priority.

The time complexity for sampling a batch with batch size m
from a dataset with n samples is O(mlogn), for setting priority
for the batch is O(mlogn).


# Usage

> pip install priority_memory

```python

from priority_memory import FastPriorReplayBuffer

buffer = FastPriorReplayBuffer(8000)
buffer.append(features=[0.1, 0.1, 0.1], prior=1)
buffer.append(features=[0.2, 0.2, 0.2], prior=2)
buffer.append(features=[0.3, 0.3, 0.3], prior=3)
buffer.append(features=[0.4, 0.4, 0.4], prior=4)
indexes, data, weights = buffer.sample_with_weights(batch_size=2)

mae = [10, 20]
buffer.set_weights(indexes, mae)

```

Release files for priority-memory 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for priority-memory 0.0.2
File Size Uploaded
priority_memory-0.0.2.tar.gz 7.4 kB Details

Release files / priority_memory-0.0.2.tar.gz

Download URL priority_memory-0.0.2.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
902b9cf6050a723a8659709151ee1ac7ed38a90553f2ddd3bbfdd6310d6c98f8
BLAKE2b-256 checksum
How to use checksums
c88ee5ba48ab51e7f4255016aa9c8f1e1843d38e3826f682462ede90b49b62fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/38.4.0 requests-toolbelt/0.8.0 tqdm/4.23.1 CPython/3.6.4

Release history Release notifications | RSS feed

This release

0.0.2 This release

1 release file

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page