Skip to main content

No project description provided

Project description

PyFixedReps

Short for: Python Fixed Representations. This is a collection of unit tested implementations of common fixed representations commonly used with linear (in features) RL systems.

Benchmarks

Installing

Can be installed using pip by including this in your requirements.txt:

pip install PyFixedReps-andnp==4.1.2

I highly recommend specifying the version number when installing in order to ensure reproducibility of experiments. This library is fairly stable, so does not change often and there is little risk of missing an important change.

Tile-coder

from PyFixedReps import TileCoder

tc = TileCoder({
    # [required]
    'tiles': 2, # how many tiles in each tiling
    'tilings': 4,
    'dims': 2, # shape of the state-vector

    # [optional]
    'random_offset': True, # instead of using the default fixed-width offset, randomly generate offsets between tilings
    'input_ranges': [(-1.2, 0.5), (-0.07, 0.07)], # a vector of same length as 'dims' containing (min, max) tuples to rescale inputs
    'scale_output': True, # scales the output by number of active features
})

state = [-1.1, 0.03]
# returns an n-hot numpy array for active tiles
# if scale_output is true, then the "hot" tiles will be scaled by number of tilings
features = tc.encode(state)
print(features) # -> [0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]

# returns the indices of the n-hot active tiles
# length of the list will be equal to number of tilings
# useful for using sparse vectors for faster computation, but harder to work with than "encode"
indices = tc.get_indices(state)
print(indices) # -> [4, 12, 31, 89]

num_features = tc.features()
print(num_features) # -> 16, the length of the vector generated by "encode"

Options

  • random_offset - In most cases, having a uniform even offset is sufficient to have uncorrelated and high coverage of the statespace. Occasionally, it becomes important that the offsets are randomly generated to break any correlations or structure in the statespace.
  • input_ranges - It's important that the inputs are scaled between [0, 1] for this tile-coder to be most effective. When not scaled, we can potentially get into bad failure cases where only a small percentage of the tiles are ever active. This is true of all current tile-coder implementations. This implementation is robust to imperfect scaling by wrapping values larger than 1 back around to 0 (modular arithmetic), so as long as the units are roughly correct then good performance can still be achieved.
  • scale_output - Has the encode function scale the outputs by the norm of the feature vector so that every feature vector has unit norm. This is simply a scalar multiple of every feature vector, which is often perfectly absorbed into the stepsize parameter, the effect of this option is to make it easier to find good stepsize by decoupling number of tilings from applicable stepsize range.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

PyFixedReps_andnp-4.1.2.tar.gz (14.2 kB view details)

Uploaded Source

Built Distributions

PyFixedReps_andnp-4.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (291.7 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

PyFixedReps_andnp-4.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (290.1 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

PyFixedReps_andnp-4.1.2-cp312-cp312-macosx_11_0_arm64.whl (254.3 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

PyFixedReps_andnp-4.1.2-cp312-cp312-macosx_10_12_x86_64.whl (259.6 kB view details)

Uploaded CPython 3.12 macOS 10.12+ x86-64

PyFixedReps_andnp-4.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (292.7 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

PyFixedReps_andnp-4.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (290.5 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

PyFixedReps_andnp-4.1.2-cp311-cp311-macosx_11_0_arm64.whl (254.8 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

PyFixedReps_andnp-4.1.2-cp311-cp311-macosx_10_12_x86_64.whl (260.8 kB view details)

Uploaded CPython 3.11 macOS 10.12+ x86-64

PyFixedReps_andnp-4.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (291.8 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

PyFixedReps_andnp-4.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (289.8 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

PyFixedReps_andnp-4.1.2-cp310-cp310-macosx_11_0_arm64.whl (254.2 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

PyFixedReps_andnp-4.1.2-cp310-cp310-macosx_10_12_x86_64.whl (260.0 kB view details)

Uploaded CPython 3.10 macOS 10.12+ x86-64

File details

Details for the file PyFixedReps_andnp-4.1.2.tar.gz.

File metadata

  • Download URL: PyFixedReps_andnp-4.1.2.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.7.4

File hashes

Hashes for PyFixedReps_andnp-4.1.2.tar.gz
Algorithm Hash digest
SHA256 c6215f900df426bf1b6c818524bea8b1c86faf784f1cb9b66269229f7cc3e8b4
MD5 207a4e36ef3cb17c74ddd7a865cccd37
BLAKE2b-256 cc22cafe23cc86306fc1e6c46b79a22de744d18422ff659dd81430c67d203f77

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e203f551572a3991c6b101927ff2d2a2bbd8697ed4fdfe9035a926b14f608301
MD5 a9d2eac36336ec6b618936bdbbdb7ed5
BLAKE2b-256 7d1188a417f233231440493b27925c74512e68f90f225353a49508442da04441

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e43d5f2100a0e7f531d4dbe8e487b0fcb1f09b2327ad604e6fa5e9789ec2c9f9
MD5 4e94d96d4a1985830076e0a6de2ff39b
BLAKE2b-256 f6dcd8d12786c3a08ed935fea51697f2cc8a46ded135f19f318c41bc65a0d01c

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b4bc743078eded8014ce8d3ae3fd20bf23335918afb6a44aec600aef85617ec
MD5 9d211b250aed1400ceebda714a8951df
BLAKE2b-256 8e11c2569a30b2b2066a6d6234c1bca91972bb57d4779b23b055c34ef13d2ae4

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp312-cp312-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp312-cp312-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2249cf54d21a7ec7e0af000c4ad9d0be80d4fa36c9f3b41d6df0dcd51ed561cf
MD5 e8569e5a7cdc65372160d3de41127fd5
BLAKE2b-256 1c307f70dd9ee6099a4af01738f7584406b8bc5315626970de1d8e5e3318cfb6

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 500ec892c8f63d9d36266dbba0572d618432b386de41808927bbeb43979f59f7
MD5 d01cee4c4e581b40a1bb9fcee70dc0ce
BLAKE2b-256 34d3b66ee448dbb32176bae4d5788f33beb1a36990025f0b5588319b2e140ed6

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 89db8fad13330d2e8e0a3447bb1b4e0de85805670901a2fcb7170d1573c4bfa8
MD5 c2e39f3bb51c6e5b47ee895ce844358a
BLAKE2b-256 08e004e6b9f08644b6b1095b3b90564887d2adb05d3845748a7683fca2edf735

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0318eb6fd24cc0c3784561029828f76dcfdf26e7ee9391c686cb47f4f6db3f81
MD5 46cbd7787e0bf1aa85c52fe53b8dc734
BLAKE2b-256 07f2982a4f0a3df9422b3d9ba22d1e2eff1e4036b7b84394105e4978151ace22

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp311-cp311-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp311-cp311-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 c046ce3325ca40fcba8f074c26a616296bca52f4b476220053be1e6d3d1542aa
MD5 def8160335ab9ccaa5048adcf11f2b46
BLAKE2b-256 715fcd7829da6092be4694f0387df5294ef1a368c36725d7600a0f374c81f1de

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f51e610e15dd0af071175cf0153f1fea3ac87c49bdb849d4bfc1303cc445733
MD5 22e7f235855887d11e9bedc5730f509f
BLAKE2b-256 6f054a2bb89ebd9c7993022aa1d310d5684340ef5e675e83a9b9e1b55118c198

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1bcd6e6f7c86b90b1ab1777274c93d1b620a96d6235e32deb078b93c7fca62de
MD5 e42849dfc429ee58d974ddf1ff0df2c9
BLAKE2b-256 48c5c3c29143bfa2bb56ac90c0cb35be43320ab22d0e14bcb76d043ee3cbe478

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 91de4237359d2574bae38451f5fa21485c3a8373c43f5642ecadfb2f175b94b0
MD5 0af9bf1fdd0e0754d1756017987fc38b
BLAKE2b-256 4542a060a45ab66ab277b8cbbb73ca1a35d68a2368035d9e5bd52141476dc2a7

See more details on using hashes here.

File details

Details for the file PyFixedReps_andnp-4.1.2-cp310-cp310-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for PyFixedReps_andnp-4.1.2-cp310-cp310-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 db2826cfc6812f7bde61bfe9de424dfe252e7ebeeb317eeeb80e056bf76819da
MD5 ba45d5f44d82388884e4eca255a23af2
BLAKE2b-256 5554568c890f954972b5d9f80a59c0a537052ff27c7b1e8e1485a657c234dba7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page