Skip to main content

A Python package for generating data sets based on Hugh Perkins' TexRel (https://arxiv.org/abs/2105.12804)

Project description

texrelenv: TexRel-like environments for emergent language experiments

A Python package for generating data sets based on Hugh Perkins' TexRel.

3 example images of the data generated by this library

Getting started

You can install this package from pypi using

pip install texrelenv

See example usage below for how to use the package to generate data.

Example usage

Here is an example of how to generate 100 images based on some config options specified in a config.toml file.

Let's say you have a config.toml file that looks like the below. "grid" refers to the overall canvas of the image while "things" refers to the coloured objects that appear in images. The config options shown below are exhausted and are explained in the (Config options)[#Config options] section below

[things]
distinct_shapes = 9
distinct_colours = 9

[environment]
grid_size = 16
thing_size = 4
things_per_image = 5
hard_boundary = true
objects_can_overlap = false

[split]
hold_out_things = 0.2
hold_out_images = 0.0

A dataset can be created from the above config in the following way

from texrelenv import DataSet

data = DataSet(config_file="config.toml")

You could also pass all the config arguments as arguments when you instantiate the DataSet (they are all named the same).

Having instantiated the data set, you can generate some train images like this:

data.sample(100, 'train')

Or some test images like this:

data.sample(100, 'test')

Config options

Option Type Meaning
grid_size int The size of the square images generated, expressed as the length of the side of the square in pixels. Default is 16, for an easy drop-in replacement for MNIST-like data sets, use 28.
hard_boundary bool If true, shapes added to an image will always be fully visible. If false, they may partially be out of frame.
objects_can_overlap bool Can objects go in front of or behind one another? Default is false.
thing_size int How big are the coloured objects added to images? Expressed as the length of one side of the square canvas used to create the templates for these objects, which can also be thought of as the maximum size of an object.
distinct_shapes int
distinct_colours int blah
things_per_image int blah
rotate bool blah
flip bool blah
hold_out_things float blah
hold_out_images float blah

Contributing

To contribute to the project, please make sure you have poetry installed and before you start working on the code, set up a virtual environment, activate it and then run

poetry install

to install all dependencies including dependencies only required for development. Then update precommit hooks with

pre-commit install
pre-commit autoupdate

Pre-commit will help you to keep your code style in keeping with the rest of the project.

Please write tests for your code, store them in test/, and only commit code that passes the unit tests that already exist. You can run unit tests with

python -m unittest

(precommit will not run unit tests!)

Acknowledgements

We are hugely thankful to Hugh Perkins for coming up with the idea of TexRel in the first place, for creating the first version of PyTorch, and for doing various other cool stuff.

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

texrelenv-0.1.0.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

texrelenv-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file texrelenv-0.1.0.tar.gz.

File metadata

  • Download URL: texrelenv-0.1.0.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.9.5 Darwin/24.1.0

File hashes

Hashes for texrelenv-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c7f9b618479382cebd678f0cca1b735365981a8f84b4b27d3c3f5d4ef08d362
MD5 255e715dd5716027d95ad9b1ae856a67
BLAKE2b-256 db07315c1efcf79153eae5cd547f706f6af96138930ba5c41e323627ef7a7379

See more details on using hashes here.

File details

Details for the file texrelenv-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: texrelenv-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.9.5 Darwin/24.1.0

File hashes

Hashes for texrelenv-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9b658747d2d9d3bb2b849962adc00625b58823dc2d7e2a611d93b1a89694f83
MD5 3d6fcf8249ee4ea7a2bed62487ca7dc1
BLAKE2b-256 0d69ab4325906ab7f5a53e4c9ba843de4a0b6db1a61c591507fd42563744e235

See more details on using hashes here.

Supported by

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